From d8adc6e1871936981e9ad5ac8e10e57f677e3faf Mon Sep 17 00:00:00 2001 From: Matthew Zeitlin <37011898+mzeitlin11@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:35:37 -0400 Subject: [PATCH] wip --- .github/workflows/async-stripe.yml | 6 + Cargo.toml | 3 +- async-stripe/Cargo.toml | 11 +- async-stripe/src/client/base/async_std.rs | 21 +- async-stripe/src/client/base/tokio.rs | 28 +- .../src/client/base/tokio_blocking.rs | 4 +- async-stripe/src/client/stripe.rs | 18 +- async-stripe/src/error.rs | 2 + crate_info.md | 5 - examples/checkout.rs | 104 - examples/connect.rs | 58 - examples/endpoints/Cargo.toml | 19 +- examples/endpoints/src/connect.rs | 1 - generated/stripe_billing/.rustfmt.toml | 7 + generated/stripe_billing/Cargo.toml | 2 + .../billing_portal_configuration/requests.rs | 249 +- .../src/billing_portal_configuration/types.rs | 147 +- .../src/billing_portal_session/requests.rs | 48 +- .../src/billing_portal_session/types.rs | 157 +- .../src/credit_note/requests.rs | 448 +- .../src/credit_note_line_item/requests.rs | 11 +- .../stripe_billing/src/invoice/requests.rs | 4915 +++++++---------- .../src/invoice_item/requests.rs | 81 +- .../src/invoice_line_item/requests.rs | 50 +- generated/stripe_billing/src/mod.rs | 31 +- generated/stripe_billing/src/plan/requests.rs | 99 +- .../src/portal_business_profile.rs | 98 +- .../src/portal_customer_update.rs | 116 +- .../stripe_billing/src/portal_features.rs | 117 +- ...ws_after_completion_hosted_confirmation.rs | 90 +- .../portal_flows_after_completion_redirect.rs | 90 +- .../src/portal_flows_coupon_offer.rs | 90 +- .../stripe_billing/src/portal_flows_flow.rs | 138 +- .../src/portal_flows_flow_after_completion.rs | 122 +- .../portal_flows_flow_subscription_cancel.rs | 94 +- .../portal_flows_flow_subscription_update.rs | 90 +- ..._flows_flow_subscription_update_confirm.rs | 98 +- .../src/portal_flows_retention.rs | 117 +- ...ws_subscription_update_confirm_discount.rs | 94 +- ..._flows_subscription_update_confirm_item.rs | 99 +- .../stripe_billing/src/portal_invoice_list.rs | 90 +- .../stripe_billing/src/portal_login_page.rs | 94 +- .../src/portal_payment_method_update.rs | 90 +- .../src/portal_subscription_cancel.rs | 145 +- ...portal_subscription_cancellation_reason.rs | 118 +- .../src/portal_subscription_pause.rs | 90 +- .../src/portal_subscription_update.rs | 148 +- .../src/portal_subscription_update_product.rs | 94 +- .../stripe_billing/src/quote/requests.rs | 672 +-- .../src/subscription/requests.rs | 1554 ++---- .../src/subscription_item/requests.rs | 309 +- .../src/subscription_schedule/requests.rs | 828 +-- .../stripe_billing/src/tax_id/requests.rs | 606 +- .../src/test_helpers_test_clock/requests.rs | 130 +- .../src/usage_record/requests.rs | 12 +- .../stripe_billing/src/usage_record/types.rs | 106 +- .../src/usage_record_summary/requests.rs | 21 +- generated/stripe_checkout/.rustfmt.toml | 7 + generated/stripe_checkout/Cargo.toml | 2 + .../checkout_acss_debit_mandate_options.rs | 184 +- ...ckout_acss_debit_payment_method_options.rs | 178 +- .../checkout_affirm_payment_method_options.rs | 115 +- ...fterpay_clearpay_payment_method_options.rs | 115 +- .../checkout_alipay_payment_method_options.rs | 115 +- ...ut_au_becs_debit_payment_method_options.rs | 115 +- ...ckout_bacs_debit_payment_method_options.rs | 115 +- ...ckout_bancontact_payment_method_options.rs | 115 +- .../checkout_boleto_payment_method_options.rs | 119 +- .../src/checkout_card_installments_options.rs | 91 +- .../checkout_card_payment_method_options.rs | 135 +- ...checkout_cashapp_payment_method_options.rs | 115 +- ...ce_bank_transfer_payment_method_options.rs | 167 +- ...customer_balance_payment_method_options.rs | 151 +- .../checkout_eps_payment_method_options.rs | 115 +- .../checkout_fpx_payment_method_options.rs | 115 +- ...checkout_giropay_payment_method_options.rs | 115 +- ...heckout_grab_pay_payment_method_options.rs | 115 +- .../checkout_ideal_payment_method_options.rs | 115 +- .../checkout_klarna_payment_method_options.rs | 115 +- ...checkout_konbini_payment_method_options.rs | 119 +- .../checkout_link_payment_method_options.rs | 115 +- .../checkout_oxxo_payment_method_options.rs | 119 +- .../checkout_p24_payment_method_options.rs | 115 +- .../checkout_paynow_payment_method_options.rs | 115 +- .../checkout_paypal_payment_method_options.rs | 152 +- .../checkout_pix_payment_method_options.rs | 90 +- ...kout_revolut_pay_payment_method_options.rs | 82 +- ...ckout_sepa_debit_payment_method_options.rs | 115 +- .../src/checkout_session/requests.rs | 845 +-- .../src/checkout_session/types.rs | 641 ++- ...checkout_session_payment_method_options.rs | 286 +- .../checkout_sofort_payment_method_options.rs | 115 +- .../checkout_swish_payment_method_options.rs | 6 - ..._us_bank_account_payment_method_options.rs | 149 +- generated/stripe_checkout/src/mod.rs | 11 +- ...pages_checkout_session_after_expiration.rs | 90 +- ...ckout_session_after_expiration_recovery.rs | 102 +- ...nt_pages_checkout_session_automatic_tax.rs | 122 +- .../payment_pages_checkout_session_consent.rs | 142 +- ...ges_checkout_session_consent_collection.rs | 145 +- ...es_checkout_session_currency_conversion.rs | 102 +- ...nt_pages_checkout_session_custom_fields.rs | 151 +- ...checkout_session_custom_fields_dropdown.rs | 94 +- ...es_checkout_session_custom_fields_label.rs | 120 +- ..._checkout_session_custom_fields_numeric.rs | 98 +- ...s_checkout_session_custom_fields_option.rs | 94 +- ...ges_checkout_session_custom_fields_text.rs | 98 +- ...ment_pages_checkout_session_custom_text.rs | 103 +- ...s_checkout_session_custom_text_position.rs | 90 +- ...pages_checkout_session_customer_details.rs | 141 +- ...pages_checkout_session_invoice_creation.rs | 94 +- ...pages_checkout_session_invoice_settings.rs | 120 +- ..._session_payment_method_reuse_agreement.rs | 70 - ...heckout_session_phone_number_collection.rs | 90 +- ...out_session_shipping_address_collection.rs | 119 +- ...nt_pages_checkout_session_shipping_cost.rs | 113 +- ..._pages_checkout_session_shipping_option.rs | 94 +- .../payment_pages_checkout_session_tax_id.rs | 118 +- ...ages_checkout_session_tax_id_collection.rs | 90 +- ...nt_pages_checkout_session_total_details.rs | 106 +- ...ession_total_details_resource_breakdown.rs | 94 +- generated/stripe_connect/.rustfmt.toml | 7 + generated/stripe_connect/Cargo.toml | 2 + .../stripe_connect/src/account/requests.rs | 760 ++- .../src/account_link/requests.rs | 133 +- .../stripe_connect/src/account_link/types.rs | 98 +- .../src/account_session/requests.rs | 99 +- .../src/account_session/types.rs | 106 +- .../src/application_fee/requests.rs | 15 +- .../src/application_fee_refund/requests.rs | 105 +- .../src/apps_secret/requests.rs | 209 +- .../stripe_connect/src/apps_secret/types.rs | 128 +- .../stripe_connect/src/capability/requests.rs | 31 +- ...edded_account_session_create_components.rs | 93 +- .../src/connect_embedded_base_config_claim.rs | 91 +- .../src/connect_embedded_base_features.rs | 2 - .../src/connect_embedded_payments_config.rs | 6 - .../src/connect_embedded_payments_features.rs | 10 - .../src/connect_embedded_payouts_config.rs | 6 - .../src/connect_embedded_payouts_features.rs | 12 - .../src/country_spec/requests.rs | 15 +- .../stripe_connect/src/country_spec/types.rs | 122 +- ...country_spec_verification_field_details.rs | 94 +- .../src/country_spec_verification_fields.rs | 94 +- .../src/external_account/requests.rs | 86 +- .../stripe_connect/src/login_link/requests.rs | 12 +- .../stripe_connect/src/login_link/types.rs | 94 +- generated/stripe_connect/src/mod.rs | 26 +- .../stripe_connect/src/person/requests.rs | 76 +- .../src/secret_service_resource_scope.rs | 119 +- .../stripe_connect/src/topup/requests.rs | 116 +- .../stripe_connect/src/transfer/requests.rs | 147 +- .../src/transfer_reversal/requests.rs | 125 +- generated/stripe_core/.rustfmt.toml | 7 + generated/stripe_core/Cargo.toml | 4 +- generated/stripe_core/src/balance/types.rs | 120 +- generated/stripe_core/src/balance_amount.rs | 99 +- .../src/balance_amount_by_source_type.rs | 101 +- .../stripe_core/src/balance_amount_net.rs | 99 +- generated/stripe_core/src/balance_detail.rs | 90 +- .../src/balance_transaction/requests.rs | 19 +- .../stripe_core/src/cash_balance/requests.rs | 18 +- generated/stripe_core/src/charge/requests.rs | 144 +- .../stripe_core/src/customer/requests.rs | 1164 ++-- .../customer_balance_transaction/requests.rs | 80 +- .../requests.rs | 59 +- .../stripe_core/src/customer_session/mod.rs | 5 - .../src/customer_session/requests.rs | 58 - .../stripe_core/src/customer_session/types.rs | 22 - .../customer_session_resource_components.rs | 6 - ...resource_components_resource_buy_button.rs | 6 - ...ource_components_resource_pricing_table.rs | 6 - generated/stripe_core/src/dispute/requests.rs | 23 +- generated/stripe_core/src/event/requests.rs | 13 +- generated/stripe_core/src/file/requests.rs | 11 +- .../stripe_core/src/file_link/requests.rs | 99 +- generated/stripe_core/src/mandate/requests.rs | 6 +- generated/stripe_core/src/mod.rs | 38 +- .../src/payment_intent/requests.rs | 3644 +++--------- .../src/payment_source/requests.rs | 24 +- generated/stripe_core/src/payout/requests.rs | 81 +- generated/stripe_core/src/refund/requests.rs | 67 +- .../stripe_core/src/setup_attempt/requests.rs | 18 +- .../stripe_core/src/setup_intent/requests.rs | 1966 +------ generated/stripe_core/src/token/requests.rs | 49 +- generated/stripe_core/src/token/types.rs | 131 +- generated/stripe_fraud/.rustfmt.toml | 7 + generated/stripe_fraud/Cargo.toml | 2 + .../src/deleted_radar_value_list.rs | 95 +- .../src/deleted_radar_value_list_item.rs | 95 +- generated/stripe_fraud/src/mod.rs | 3 + .../src/radar_early_fraud_warning/requests.rs | 18 +- .../src/radar_early_fraud_warning/types.rs | 123 +- .../src/radar_value_list/requests.rs | 63 +- .../src/radar_value_list/types.rs | 153 +- .../src/radar_value_list_item/requests.rs | 64 +- .../src/radar_value_list_item/types.rs | 117 +- generated/stripe_fraud/src/review/requests.rs | 17 +- generated/stripe_issuing/.rustfmt.toml | 7 + generated/stripe_issuing/Cargo.toml | 2 + .../src/issuing_authorization/requests.rs | 436 +- .../src/issuing_card/requests.rs | 1272 ++--- .../src/issuing_cardholder/requests.rs | 1185 +--- .../src/issuing_dispute/requests.rs | 71 +- .../src/issuing_token/requests.rs | 31 +- .../src/issuing_transaction/requests.rs | 491 +- generated/stripe_issuing/src/mod.rs | 3 + generated/stripe_misc/.rustfmt.toml | 7 + generated/stripe_misc/Cargo.toml | 10 +- .../src/apple_pay_domain/requests.rs | 73 +- .../stripe_misc/src/apple_pay_domain/types.rs | 102 +- ...bank_connections_resource_accountholder.rs | 124 +- .../src/bank_connections_resource_balance.rs | 132 +- ...ource_balance_api_resource_cash_balance.rs | 90 +- ...rce_balance_api_resource_credit_balance.rs | 90 +- ...nk_connections_resource_balance_refresh.rs | 122 +- ...s_resource_link_account_session_filters.rs | 90 +- ..._connections_resource_ownership_refresh.rs | 118 +- ...onnections_resource_transaction_refresh.rs | 80 - ...transaction_resource_status_transitions.rs | 7 - .../stripe_misc/src/climate_order/mod.rs | 5 - .../stripe_misc/src/climate_order/requests.rs | 173 - .../stripe_misc/src/climate_order/types.rs | 179 - .../stripe_misc/src/climate_product/mod.rs | 5 - .../src/climate_product/requests.rs | 60 - .../stripe_misc/src/climate_product/types.rs | 32 - .../src/climate_removals_beneficiary.rs | 5 - .../src/climate_removals_location.rs | 13 - .../src/climate_removals_order_deliveries.rs | 13 - .../src/climate_removals_products_price.rs | 9 - .../stripe_misc/src/climate_supplier/mod.rs | 5 - .../src/climate_supplier/requests.rs | 60 - .../stripe_misc/src/climate_supplier/types.rs | 81 - .../src/deleted_apple_pay_domain.rs | 95 +- .../src/deleted_webhook_endpoint.rs | 95 +- .../stripe_misc/src/ephemeral_key/requests.rs | 38 +- .../stripe_misc/src/ephemeral_key/types.rs | 107 +- .../stripe_misc/src/exchange_rate/requests.rs | 11 +- .../stripe_misc/src/exchange_rate/types.rs | 94 +- .../financial_connections_account/requests.rs | 217 +- .../financial_connections_account/types.rs | 343 +- .../financial_connections_account_owner.rs | 122 +- ...financial_connections_account_ownership.rs | 98 +- .../financial_connections_session/requests.rs | 59 +- .../financial_connections_session/types.rs | 181 +- .../financial_connections_transaction/mod.rs | 5 - .../requests.rs | 91 - .../types.rs | 92 - ...rting_finance_report_run_run_parameters.rs | 135 +- ...lato_data_document_report_date_of_birth.rs | 98 +- ...to_data_document_report_expiration_date.rs | 98 +- ...gelato_data_document_report_issued_date.rs | 98 +- .../src/gelato_data_id_number_report_date.rs | 98 +- .../src/gelato_data_verified_outputs_date.rs | 98 +- .../stripe_misc/src/gelato_document_report.rs | 191 +- .../src/gelato_document_report_error.rs | 116 +- .../src/gelato_id_number_report.rs | 167 +- .../src/gelato_id_number_report_error.rs | 116 +- .../src/gelato_report_document_options.rs | 128 +- .../src/gelato_report_id_number_options.rs | 82 +- .../stripe_misc/src/gelato_selfie_report.rs | 123 +- .../src/gelato_selfie_report_error.rs | 115 +- .../src/gelato_session_document_options.rs | 128 +- .../src/gelato_session_id_number_options.rs | 82 +- .../src/gelato_session_last_error.rs | 114 +- .../src/gelato_verification_report_options.rs | 96 +- .../gelato_verification_session_options.rs | 96 +- .../src/gelato_verified_outputs.rs | 139 +- .../identity_verification_report/requests.rs | 49 +- .../src/identity_verification_report/types.rs | 161 +- .../identity_verification_session/requests.rs | 280 +- .../identity_verification_session/types.rs | 201 +- generated/stripe_misc/src/mod.rs | 35 +- .../src/reporting_report_run/requests.rs | 97 +- .../src/reporting_report_run/types.rs | 132 +- .../src/reporting_report_type/requests.rs | 41 +- .../src/reporting_report_type/types.rs | 127 +- .../src/scheduled_query_run/requests.rs | 15 +- .../src/scheduled_query_run/types.rs | 138 +- .../src/sigma_scheduled_query_run_error.rs | 90 +- .../src/tax_calculation/requests.rs | 112 +- .../stripe_misc/src/tax_calculation/types.rs | 166 +- .../src/tax_calculation_line_item.rs | 163 +- ..._registrations_resource_country_options.rs | 431 +- ...ce_country_options_ca_province_standard.rs | 90 +- ...rations_resource_country_options_canada.rs | 124 +- ...ations_resource_country_options_default.rs | 116 +- ...ns_resource_country_options_eu_standard.rs | 131 +- ...rations_resource_country_options_europe.rs | 121 +- ...ons_resource_country_options_simplified.rs | 116 +- ..._resource_country_options_united_states.rs | 140 +- ..._country_options_us_local_amusement_tax.rs | 90 +- ...urce_country_options_us_local_lease_tax.rs | 90 +- .../tax_product_resource_customer_details.rs | 160 +- ...source_customer_details_resource_tax_id.rs | 120 +- .../src/tax_product_resource_jurisdiction.rs | 124 +- ...roduct_resource_line_item_tax_breakdown.rs | 166 +- ...uct_resource_line_item_tax_rate_details.rs | 122 +- .../tax_product_resource_postal_address.rs | 117 +- .../src/tax_product_resource_tax_breakdown.rs | 136 +- ..._resource_tax_calculation_shipping_cost.rs | 147 +- .../tax_product_resource_tax_rate_details.rs | 124 +- ..._product_resource_tax_settings_defaults.rs | 118 +- ...oduct_resource_tax_settings_head_office.rs | 90 +- ...ct_resource_tax_settings_status_details.rs | 96 +- ...settings_status_details_resource_active.rs | 82 +- ...ettings_status_details_resource_pending.rs | 90 +- ...transaction_line_item_resource_reversal.rs | 90 +- ...ource_tax_transaction_resource_reversal.rs | 90 +- ..._resource_tax_transaction_shipping_cost.rs | 147 +- .../src/tax_registration/requests.rs | 248 +- .../stripe_misc/src/tax_registration/types.rs | 148 +- .../stripe_misc/src/tax_settings/types.rs | 127 +- .../src/tax_transaction/requests.rs | 178 +- .../stripe_misc/src/tax_transaction/types.rs | 175 +- .../src/tax_transaction_line_item.rs | 196 +- .../src/verification_session_redaction.rs | 112 +- .../src/webhook_endpoint/requests.rs | 287 +- .../stripe_misc/src/webhook_endpoint/types.rs | 143 +- generated/stripe_payment/.rustfmt.toml | 7 + generated/stripe_payment/Cargo.toml | 2 + .../src/bank_account/requests.rs | 586 +- generated/stripe_payment/src/card/requests.rs | 537 +- generated/stripe_payment/src/mod.rs | 27 +- .../src/payment_link/requests.rs | 857 +-- .../src/payment_method/requests.rs | 471 +- ...thod_config_resource_display_preference.rs | 146 +- ...nfig_resource_payment_method_properties.rs | 94 +- .../payment_method_configuration/requests.rs | 2704 ++++----- .../src/payment_method_configuration/types.rs | 400 +- .../src/payment_method_domain/requests.rs | 76 +- .../src/payment_method_domain/types.rs | 132 +- ...d_domain_resource_payment_method_status.rs | 122 +- ..._resource_payment_method_status_details.rs | 90 +- .../stripe_payment/src/source/requests.rs | 221 +- .../src/source_mandate_notification.rs | 147 +- ...ce_mandate_notification_acss_debit_data.rs | 91 +- ...ce_mandate_notification_bacs_debit_data.rs | 91 +- ...ce_mandate_notification_sepa_debit_data.rs | 101 +- generated/stripe_product/.rustfmt.toml | 7 + generated/stripe_product/Cargo.toml | 2 + .../stripe_product/src/coupon/requests.rs | 89 +- generated/stripe_product/src/mod.rs | 3 + .../stripe_product/src/price/requests.rs | 186 +- .../stripe_product/src/product/requests.rs | 230 +- .../src/promotion_code/requests.rs | 141 +- .../src/shipping_rate/requests.rs | 54 +- .../stripe_product/src/tax_code/requests.rs | 11 +- .../stripe_product/src/tax_rate/requests.rs | 31 +- generated/stripe_shared/.rustfmt.toml | 7 + generated/stripe_shared/Cargo.toml | 3 + generated/stripe_shared/src/account.rs | 286 +- .../src/account_annual_revenue.rs | 12 - .../account_bacs_debit_payments_settings.rs | 94 +- .../src/account_branding_settings.rs | 102 +- .../src/account_business_profile.rs | 139 +- .../stripe_shared/src/account_capabilities.rs | 371 +- .../account_capability_future_requirements.rs | 127 +- .../src/account_capability_requirements.rs | 127 +- .../src/account_card_issuing_settings.rs | 91 +- .../src/account_card_payments_settings.rs | 108 +- .../src/account_dashboard_settings.rs | 94 +- .../src/account_decline_charge_on.rs | 94 +- .../src/account_future_requirements.rs | 127 +- .../src/account_invoices_settings.rs | 6 - .../src/account_monthly_estimated_revenue.rs | 94 +- .../src/account_payments_settings.rs | 112 +- .../src/account_payout_settings.rs | 98 +- .../stripe_shared/src/account_requirements.rs | 127 +- .../src/account_requirements_alternative.rs | 94 +- .../src/account_requirements_error.rs | 250 +- .../account_sepa_debit_payments_settings.rs | 91 +- .../stripe_shared/src/account_settings.rs | 139 +- .../src/account_terms_of_service.rs | 99 +- .../src/account_tos_acceptance.rs | 106 +- .../src/account_treasury_settings.rs | 91 +- .../account_unification_account_controller.rs | 119 +- generated/stripe_shared/src/address.rs | 117 +- generated/stripe_shared/src/api_errors.rs | 305 +- generated/stripe_shared/src/api_version.rs | 20 +- generated/stripe_shared/src/application.rs | 94 +- .../stripe_shared/src/application_fee.rs | 152 +- .../src/application_fee_refund.rs | 122 +- generated/stripe_shared/src/automatic_tax.rs | 119 +- .../stripe_shared/src/balance_transaction.rs | 207 +- .../src/balance_transaction_source.rs | 140 +- generated/stripe_shared/src/bank_account.rs | 225 +- .../stripe_shared/src/billing_details.rs | 102 +- .../stripe_shared/src/cancellation_details.rs | 140 +- generated/stripe_shared/src/capability.rs | 145 +- generated/stripe_shared/src/card.rs | 299 +- .../card_issuing_account_terms_of_service.rs | 99 +- .../card_mandate_payment_method_details.rs | 82 +- generated/stripe_shared/src/cash_balance.rs | 102 +- generated/stripe_shared/src/charge.rs | 395 +- .../stripe_shared/src/charge_fraud_details.rs | 96 +- generated/stripe_shared/src/charge_outcome.rs | 127 +- .../stripe_shared/src/charge_transfer_data.rs | 94 +- .../src/checkout_session_item.rs | 144 +- .../src/connect_account_reference.rs | 63 - .../src/connect_collection_transfer.rs | 106 +- generated/stripe_shared/src/coupon.rs | 208 +- .../stripe_shared/src/coupon_applies_to.rs | 90 +- .../src/coupon_currency_option.rs | 90 +- generated/stripe_shared/src/credit_note.rs | 327 +- .../src/credit_note_line_item.rs | 202 +- .../src/credit_note_tax_amount.rs | 132 +- .../stripe_shared/src/currency_option.rs | 134 +- .../stripe_shared/src/custom_unit_amount.rs | 98 +- generated/stripe_shared/src/customer.rs | 291 +- .../stripe_shared/src/customer_acceptance.rs | 127 +- ...tomer_balance_customer_balance_settings.rs | 118 +- ...saction_resource_adjusted_for_overdraft.rs | 94 +- ...resource_applied_to_payment_transaction.rs | 90 +- ...transaction_resource_funded_transaction.rs | 93 +- ...nded_transaction_resource_bank_transfer.rs | 181 +- ...bank_transfer_resource_eu_bank_transfer.rs | 104 +- ...bank_transfer_resource_gb_bank_transfer.rs | 104 +- ...bank_transfer_resource_jp_bank_transfer.rs | 104 +- ...bank_transfer_resource_us_bank_transfer.rs | 148 +- ...ource_refunded_from_payment_transaction.rs | 90 +- ...saction_resource_transferred_to_balance.rs | 5 - ...urce_unapplied_from_payment_transaction.rs | 90 +- .../src/customer_balance_transaction.rs | 171 +- .../src/customer_cash_balance_transaction.rs | 234 +- generated/stripe_shared/src/customer_tax.rs | 119 +- .../src/customer_tax_location.rs | 119 +- .../stripe_shared/src/deleted_account.rs | 95 +- .../stripe_shared/src/deleted_bank_account.rs | 100 +- generated/stripe_shared/src/deleted_card.rs | 100 +- generated/stripe_shared/src/deleted_coupon.rs | 95 +- .../stripe_shared/src/deleted_customer.rs | 95 +- .../stripe_shared/src/deleted_discount.rs | 138 +- .../src/deleted_external_account.rs | 95 +- .../stripe_shared/src/deleted_invoice.rs | 95 +- .../stripe_shared/src/deleted_invoiceitem.rs | 95 +- .../src/deleted_payment_source.rs | 95 +- generated/stripe_shared/src/deleted_person.rs | 95 +- generated/stripe_shared/src/deleted_plan.rs | 95 +- .../stripe_shared/src/deleted_product.rs | 95 +- .../src/deleted_subscription_item.rs | 95 +- generated/stripe_shared/src/deleted_tax_id.rs | 95 +- .../src/deleted_test_helpers_test_clock.rs | 95 +- .../src/destination_details_unimplemented.rs | 2 - generated/stripe_shared/src/discount.rs | 137 +- .../src/discounts_resource_discount_amount.rs | 94 +- generated/stripe_shared/src/dispute.rs | 204 +- .../stripe_shared/src/dispute_evidence.rs | 250 +- .../src/dispute_evidence_details.rs | 102 +- .../src/dispute_payment_method_details.rs | 118 +- .../dispute_payment_method_details_card.rs | 94 +- generated/stripe_shared/src/email_sent.rs | 94 +- generated/stripe_shared/src/error.rs | 90 +- generated/stripe_shared/src/event.rs | 263 +- .../stripe_shared/src/external_account.rs | 95 +- .../src/external_account_requirements.rs | 102 +- generated/stripe_shared/src/fee.rs | 108 +- generated/stripe_shared/src/file.rs | 162 +- generated/stripe_shared/src/file_link.rs | 127 +- .../stripe_shared/src/funding_instructions.rs | 124 +- .../src/funding_instructions_bank_transfer.rs | 122 +- ...g_instructions_bank_transfer_aba_record.rs | 98 +- ...uctions_bank_transfer_financial_address.rs | 185 +- ..._instructions_bank_transfer_iban_record.rs | 102 +- ...ructions_bank_transfer_sort_code_record.rs | 98 +- ..._instructions_bank_transfer_spei_record.rs | 98 +- ...instructions_bank_transfer_swift_record.rs | 98 +- ...nstructions_bank_transfer_zengin_record.rs | 122 +- generated/stripe_shared/src/invoice.rs | 663 ++- .../src/invoice_installments_card.rs | 90 +- generated/stripe_shared/src/invoice_item.rs | 221 +- .../src/invoice_item_threshold_reason.rs | 94 +- .../stripe_shared/src/invoice_line_item.rs | 253 +- .../src/invoice_line_item_period.rs | 94 +- .../src/invoice_mandate_options_card.rs | 120 +- ...voice_payment_method_options_acss_debit.rs | 120 +- ...thod_options_acss_debit_mandate_options.rs | 112 +- ...voice_payment_method_options_bancontact.rs | 114 +- .../invoice_payment_method_options_card.rs | 122 +- ...payment_method_options_customer_balance.rs | 122 +- ..._options_customer_balance_bank_transfer.rs | 100 +- ..._balance_bank_transfer_eu_bank_transfer.rs | 128 +- .../invoice_payment_method_options_konbini.rs | 82 +- ..._payment_method_options_us_bank_account.rs | 123 +- ..._us_bank_account_linked_account_options.rs | 145 +- .../src/invoice_rendering_pdf.rs | 111 +- .../src/invoice_setting_custom_field.rs | 94 +- .../src/invoice_setting_customer_setting.rs | 102 +- .../src/invoice_setting_quote_setting.rs | 91 +- .../src/invoice_setting_rendering_options.rs | 90 +- ...ing_subscription_schedule_phase_setting.rs | 97 +- ...e_setting_subscription_schedule_setting.rs | 95 +- .../stripe_shared/src/invoice_tax_amount.rs | 132 +- .../src/invoice_threshold_reason.rs | 94 +- .../src/invoice_transfer_data.rs | 94 +- .../src/invoices_from_invoice.rs | 94 +- .../src/invoices_invoice_rendering.rs | 94 +- .../src/invoices_payment_method_options.rs | 117 +- .../src/invoices_payment_settings.rs | 124 +- .../src/invoices_resource_invoice_tax_id.rs | 118 +- ...ices_resource_line_items_credited_items.rs | 94 +- ...s_resource_line_items_proration_details.rs | 90 +- .../src/invoices_shipping_cost.rs | 113 +- .../src/invoices_status_transitions.rs | 102 +- .../src/issuing_authorization.rs | 277 +- .../issuing_authorization_amount_details.rs | 94 +- ..._authorization_authentication_exemption.rs | 147 +- .../issuing_authorization_merchant_data.rs | 137 +- .../src/issuing_authorization_network_data.rs | 98 +- .../issuing_authorization_pending_request.rs | 122 +- .../src/issuing_authorization_request.rs | 167 +- .../issuing_authorization_three_d_secure.rs | 112 +- .../src/issuing_authorization_treasury.rs | 98 +- ...issuing_authorization_verification_data.rs | 221 +- generated/stripe_shared/src/issuing_card.rs | 310 +- .../src/issuing_card_apple_pay.rs | 116 +- .../issuing_card_authorization_controls.rs | 510 +- .../src/issuing_card_google_pay.rs | 116 +- .../src/issuing_card_shipping.rs | 233 +- .../src/issuing_card_shipping_customs.rs | 90 +- .../src/issuing_card_spending_limit.rs | 324 +- .../stripe_shared/src/issuing_card_wallets.rs | 98 +- .../stripe_shared/src/issuing_cardholder.rs | 228 +- .../src/issuing_cardholder_address.rs | 90 +- ...suing_cardholder_authorization_controls.rs | 512 +- .../src/issuing_cardholder_card_issuing.rs | 93 +- .../src/issuing_cardholder_company.rs | 90 +- .../src/issuing_cardholder_id_document.rs | 94 +- .../src/issuing_cardholder_individual.rs | 107 +- .../src/issuing_cardholder_individual_dob.rs | 98 +- .../src/issuing_cardholder_requirements.rs | 156 +- .../src/issuing_cardholder_spending_limit.rs | 324 +- ...ssuing_cardholder_user_terms_acceptance.rs | 100 +- .../src/issuing_cardholder_verification.rs | 90 +- .../stripe_shared/src/issuing_dispute.rs | 164 +- .../src/issuing_dispute_canceled_evidence.rs | 192 +- .../src/issuing_dispute_duplicate_evidence.rs | 117 +- .../src/issuing_dispute_evidence.rs | 161 +- .../issuing_dispute_fraudulent_evidence.rs | 94 +- ...e_merchandise_not_as_described_evidence.rs | 141 +- .../issuing_dispute_not_received_evidence.rs | 136 +- .../src/issuing_dispute_other_evidence.rs | 124 +- ...spute_service_not_as_described_evidence.rs | 112 +- .../src/issuing_dispute_treasury.rs | 94 +- .../src/issuing_network_token_address.rs | 94 +- .../src/issuing_network_token_device.rs | 147 +- .../src/issuing_network_token_mastercard.rs | 104 +- .../src/issuing_network_token_network_data.rs | 134 +- .../src/issuing_network_token_visa.rs | 103 +- .../issuing_network_token_wallet_provider.rs | 242 +- generated/stripe_shared/src/issuing_token.rs | 208 +- .../stripe_shared/src/issuing_transaction.rs | 260 +- .../src/issuing_transaction_amount_details.rs | 94 +- .../src/issuing_transaction_flight_data.rs | 112 +- .../issuing_transaction_flight_data_leg.rs | 117 +- .../src/issuing_transaction_fuel_data.rs | 104 +- .../src/issuing_transaction_lodging_data.rs | 94 +- .../src/issuing_transaction_network_data.rs | 98 +- .../issuing_transaction_purchase_details.rs | 106 +- .../src/issuing_transaction_receipt_data.rs | 102 +- .../src/issuing_transaction_treasury.rs | 94 +- .../stripe_shared/src/legal_entity_company.rs | 237 +- .../src/legal_entity_company_verification.rs | 90 +- ...al_entity_company_verification_document.rs | 102 +- .../stripe_shared/src/legal_entity_dob.rs | 98 +- .../src/legal_entity_japan_address.rs | 122 +- .../src/legal_entity_person_verification.rs | 116 +- ...gal_entity_person_verification_document.rs | 102 +- .../src/legal_entity_ubo_declaration.rs | 98 +- generated/stripe_shared/src/level3.rs | 121 +- .../stripe_shared/src/level3_line_items.rs | 117 +- .../src/line_items_discount_amount.rs | 94 +- .../src/line_items_tax_amount.rs | 122 +- .../linked_account_options_us_bank_account.rs | 149 +- generated/stripe_shared/src/mandate.rs | 178 +- .../stripe_shared/src/mandate_acss_debit.rs | 168 +- .../src/mandate_au_becs_debit.rs | 90 +- .../stripe_shared/src/mandate_bacs_debit.rs | 174 +- .../stripe_shared/src/mandate_cashapp.rs | 82 +- generated/stripe_shared/src/mandate_link.rs | 82 +- .../stripe_shared/src/mandate_multi_use.rs | 82 +- .../src/mandate_payment_method_details.rs | 148 +- generated/stripe_shared/src/mandate_paypal.rs | 94 +- .../stripe_shared/src/mandate_sepa_debit.rs | 94 +- .../stripe_shared/src/mandate_single_use.rs | 94 +- .../src/mandate_us_bank_account.rs | 120 +- generated/stripe_shared/src/mod.rs | 83 +- generated/stripe_shared/src/networks.rs | 97 +- .../src/notification_event_data.rs | 99 +- .../src/notification_event_request.rs | 94 +- .../stripe_shared/src/offline_acceptance.rs | 82 +- .../stripe_shared/src/online_acceptance.rs | 94 +- .../stripe_shared/src/package_dimensions.rs | 102 +- .../src/payment_flows_amount_details.rs | 91 +- ...yment_flows_amount_details_resource_tip.rs | 91 +- ...utomatic_payment_methods_payment_intent.rs | 123 +- ..._automatic_payment_methods_setup_intent.rs | 119 +- ...nt_flows_private_payment_methods_alipay.rs | 82 +- ..._private_payment_methods_alipay_details.rs | 99 +- ...ed_authorization_extended_authorization.rs | 137 +- ...authorization_incremental_authorization.rs | 137 +- ...rprise_features_overcapture_overcapture.rs | 137 +- ..._card_details_api_resource_multicapture.rs | 124 +- ...lows_private_payment_methods_klarna_dob.rs | 98 +- generated/stripe_shared/src/payment_intent.rs | 443 +- .../src/payment_intent_card_processing.rs | 91 +- .../src/payment_intent_next_action.rs | 237 +- ...tent_next_action_alipay_handle_redirect.rs | 102 +- .../src/payment_intent_next_action_boleto.rs | 102 +- ...ent_next_action_card_await_notification.rs | 94 +- ...happ_handle_redirect_or_display_qr_code.rs | 98 +- ...ment_intent_next_action_cashapp_qr_code.rs | 98 +- ...tion_display_bank_transfer_instructions.rs | 147 +- ...intent_next_action_display_oxxo_details.rs | 98 +- .../src/payment_intent_next_action_konbini.rs | 98 +- ...t_intent_next_action_konbini_familymart.rs | 95 +- ...yment_intent_next_action_konbini_lawson.rs | 95 +- ...ent_intent_next_action_konbini_ministop.rs | 95 +- ...nt_intent_next_action_konbini_seicomart.rs | 95 +- ...yment_intent_next_action_konbini_stores.rs | 102 +- ...tent_next_action_paynow_display_qr_code.rs | 102 +- ..._intent_next_action_pix_display_qr_code.rs | 117 +- ...t_next_action_promptpay_display_qr_code.rs | 102 +- ...ment_intent_next_action_redirect_to_url.rs | 94 +- ...wish_handle_redirect_or_display_qr_code.rs | 11 - ...ayment_intent_next_action_swish_qr_code.rs | 12 - ...t_next_action_verify_with_microdeposits.rs | 126 +- ..._next_action_wechat_pay_display_qr_code.rs | 112 +- ...tion_wechat_pay_redirect_to_android_app.rs | 122 +- ...t_action_wechat_pay_redirect_to_ios_app.rs | 90 +- .../payment_intent_payment_method_options.rs | 328 +- ...ntent_payment_method_options_acss_debit.rs | 152 +- ...nt_payment_method_options_au_becs_debit.rs | 115 +- ...ment_intent_payment_method_options_blik.rs | 132 +- ...ment_intent_payment_method_options_card.rs | 382 +- ...yment_intent_payment_method_options_eps.rs | 115 +- ...ment_intent_payment_method_options_link.rs | 148 +- ...thod_options_mandate_options_acss_debit.rs | 153 +- ...thod_options_mandate_options_sepa_debit.rs | 82 +- ...ntent_payment_method_options_sepa_debit.rs | 123 +- ...ent_intent_payment_method_options_swish.rs | 73 - ..._payment_method_options_us_bank_account.rs | 191 +- .../src/payment_intent_processing.rs | 118 +- ...intent_processing_customer_notification.rs | 94 +- generated/stripe_shared/src/payment_link.rs | 387 +- ...payment_links_resource_after_completion.rs | 127 +- .../payment_links_resource_automatic_tax.rs | 94 +- ...yment_links_resource_completed_sessions.rs | 7 - ...e_completion_behavior_confirmation_page.rs | 90 +- ...s_resource_completion_behavior_redirect.rs | 90 +- ...yment_links_resource_consent_collection.rs | 145 +- .../payment_links_resource_custom_fields.rs | 149 +- ...t_links_resource_custom_fields_dropdown.rs | 90 +- ..._resource_custom_fields_dropdown_option.rs | 94 +- ...ment_links_resource_custom_fields_label.rs | 118 +- ...nt_links_resource_custom_fields_numeric.rs | 94 +- ...yment_links_resource_custom_fields_text.rs | 94 +- .../src/payment_links_resource_custom_text.rs | 100 +- ...ent_links_resource_custom_text_position.rs | 90 +- ...payment_links_resource_invoice_creation.rs | 94 +- ...payment_links_resource_invoice_settings.rs | 120 +- ...ment_links_resource_payment_intent_data.rs | 168 +- ...resource_payment_method_reuse_agreement.rs | 68 - ..._links_resource_phone_number_collection.rs | 90 +- .../payment_links_resource_restrictions.rs | 4 - ...ks_resource_shipping_address_collection.rs | 115 +- .../payment_links_resource_shipping_option.rs | 94 +- ...ayment_links_resource_subscription_data.rs | 101 +- ...urce_subscription_data_invoice_settings.rs | 4 - ...ayment_links_resource_tax_id_collection.rs | 90 +- .../payment_links_resource_transfer_data.rs | 94 +- generated/stripe_shared/src/payment_method.rs | 402 +- .../src/payment_method_acss_debit.rs | 112 +- .../src/payment_method_affirm.rs | 82 +- .../src/payment_method_afterpay_clearpay.rs | 82 +- .../src/payment_method_au_becs_debit.rs | 98 +- .../src/payment_method_bacs_debit.rs | 98 +- .../src/payment_method_bancontact.rs | 82 +- .../stripe_shared/src/payment_method_blik.rs | 82 +- .../src/payment_method_boleto.rs | 90 +- .../stripe_shared/src/payment_method_card.rs | 161 +- .../src/payment_method_card_checks.rs | 98 +- .../src/payment_method_card_present.rs | 177 +- .../payment_method_card_present_networks.rs | 94 +- .../src/payment_method_card_wallet.rs | 162 +- ...ethod_card_wallet_amex_express_checkout.rs | 82 +- .../payment_method_card_wallet_apple_pay.rs | 82 +- .../payment_method_card_wallet_google_pay.rs | 82 +- .../src/payment_method_card_wallet_link.rs | 82 +- .../payment_method_card_wallet_masterpass.rs | 102 +- .../payment_method_card_wallet_samsung_pay.rs | 82 +- ...ayment_method_card_wallet_visa_checkout.rs | 102 +- .../src/payment_method_cashapp.rs | 94 +- ...iz_payment_method_configuration_details.rs | 94 +- .../src/payment_method_customer_balance.rs | 82 +- .../src/payment_method_details.rs | 378 +- ...ment_method_details_ach_credit_transfer.rs | 102 +- .../src/payment_method_details_ach_debit.rs | 141 +- .../src/payment_method_details_acss_debit.rs | 118 +- .../src/payment_method_details_affirm.rs | 82 +- ...ayment_method_details_afterpay_clearpay.rs | 94 +- .../payment_method_details_au_becs_debit.rs | 103 +- .../src/payment_method_details_bacs_debit.rs | 102 +- .../src/payment_method_details_bancontact.rs | 151 +- .../src/payment_method_details_blik.rs | 82 +- .../src/payment_method_details_boleto.rs | 90 +- .../src/payment_method_details_card.rs | 314 +- .../src/payment_method_details_card_checks.rs | 98 +- ...ayment_method_details_card_installments.rs | 90 +- ...t_method_details_card_installments_plan.rs | 148 +- ...yment_method_details_card_network_token.rs | 90 +- .../payment_method_details_card_present.rs | 240 +- ...ent_method_details_card_present_offline.rs | 90 +- ...ent_method_details_card_present_receipt.rs | 167 +- .../src/payment_method_details_card_wallet.rs | 166 +- ...tails_card_wallet_amex_express_checkout.rs | 82 +- ...nt_method_details_card_wallet_apple_pay.rs | 82 +- ...t_method_details_card_wallet_google_pay.rs | 82 +- ...payment_method_details_card_wallet_link.rs | 82 +- ...t_method_details_card_wallet_masterpass.rs | 102 +- ..._method_details_card_wallet_samsung_pay.rs | 82 +- ...ethod_details_card_wallet_visa_checkout.rs | 102 +- .../src/payment_method_details_cashapp.rs | 94 +- ...payment_method_details_customer_balance.rs | 82 +- .../src/payment_method_details_eps.rs | 114 +- .../src/payment_method_details_fpx.rs | 140 +- .../src/payment_method_details_giropay.rs | 102 +- .../src/payment_method_details_grabpay.rs | 90 +- .../src/payment_method_details_ideal.rs | 167 +- .../payment_method_details_interac_present.rs | 217 +- ..._method_details_interac_present_receipt.rs | 167 +- .../src/payment_method_details_klarna.rs | 94 +- .../src/payment_method_details_konbini.rs | 90 +- .../payment_method_details_konbini_store.rs | 112 +- .../src/payment_method_details_link.rs | 90 +- .../src/payment_method_details_multibanco.rs | 94 +- .../src/payment_method_details_oxxo.rs | 90 +- .../src/payment_method_details_p24.rs | 125 +- .../src/payment_method_details_paynow.rs | 90 +- .../src/payment_method_details_paypal.rs | 112 +- .../src/payment_method_details_pix.rs | 91 +- .../src/payment_method_details_promptpay.rs | 90 +- .../src/payment_method_details_revolut_pay.rs | 82 +- ...ent_method_details_sepa_credit_transfer.rs | 98 +- .../src/payment_method_details_sepa_debit.rs | 117 +- .../src/payment_method_details_sofort.rs | 156 +- .../payment_method_details_stripe_account.rs | 82 +- .../src/payment_method_details_swish.rs | 10 - .../payment_method_details_us_bank_account.rs | 165 +- .../src/payment_method_details_wechat.rs | 82 +- .../src/payment_method_details_wechat_pay.rs | 94 +- .../src/payment_method_details_zip.rs | 82 +- .../stripe_shared/src/payment_method_eps.rs | 110 +- .../stripe_shared/src/payment_method_fpx.rs | 136 +- .../src/payment_method_giropay.rs | 82 +- .../src/payment_method_grabpay.rs | 82 +- .../stripe_shared/src/payment_method_ideal.rs | 144 +- .../src/payment_method_interac_present.rs | 182 +- .../src/payment_method_klarna.rs | 90 +- .../src/payment_method_konbini.rs | 82 +- .../stripe_shared/src/payment_method_link.rs | 95 +- .../src/payment_method_options_affirm.rs | 145 +- ...ayment_method_options_afterpay_clearpay.rs | 148 +- .../src/payment_method_options_alipay.rs | 113 +- .../src/payment_method_options_bacs_debit.rs | 115 +- .../src/payment_method_options_bancontact.rs | 143 +- .../src/payment_method_options_boleto.rs | 117 +- ...ayment_method_options_card_installments.rs | 98 +- ...ent_method_options_card_mandate_options.rs | 204 +- .../payment_method_options_card_present.rs | 94 +- .../src/payment_method_options_cashapp.rs | 142 +- ...payment_method_options_customer_balance.rs | 148 +- ..._options_customer_balance_bank_transfer.rs | 151 +- ...ptions_customer_balance_eu_bank_account.rs | 114 +- .../src/payment_method_options_fpx.rs | 113 +- .../src/payment_method_options_giropay.rs | 115 +- .../src/payment_method_options_grabpay.rs | 115 +- .../src/payment_method_options_ideal.rs | 113 +- .../payment_method_options_interac_present.rs | 82 +- .../src/payment_method_options_klarna.rs | 144 +- .../src/payment_method_options_konbini.rs | 137 +- .../src/payment_method_options_oxxo.rs | 117 +- .../src/payment_method_options_p24.rs | 113 +- .../src/payment_method_options_paynow.rs | 113 +- .../src/payment_method_options_paypal.rs | 148 +- .../src/payment_method_options_pix.rs | 121 +- .../src/payment_method_options_promptpay.rs | 115 +- .../src/payment_method_options_revolut_pay.rs | 82 +- .../src/payment_method_options_sofort.rs | 141 +- ...options_us_bank_account_mandate_options.rs | 62 - .../src/payment_method_options_wechat_pay.rs | 145 +- .../src/payment_method_options_zip.rs | 113 +- .../stripe_shared/src/payment_method_oxxo.rs | 82 +- .../stripe_shared/src/payment_method_p24.rs | 113 +- .../src/payment_method_paynow.rs | 82 +- .../src/payment_method_paypal.rs | 94 +- .../stripe_shared/src/payment_method_pix.rs | 82 +- .../src/payment_method_promptpay.rs | 82 +- .../src/payment_method_revolut_pay.rs | 82 +- .../src/payment_method_sepa_debit.rs | 117 +- .../src/payment_method_sofort.rs | 90 +- .../stripe_shared/src/payment_method_swish.rs | 2 - .../src/payment_method_us_bank_account.rs | 178 +- .../payment_method_us_bank_account_blocked.rs | 140 +- ...t_method_us_bank_account_status_details.rs | 91 +- .../src/payment_method_wechat_pay.rs | 82 +- .../stripe_shared/src/payment_method_zip.rs | 82 +- generated/stripe_shared/src/payment_source.rs | 101 +- generated/stripe_shared/src/payout.rs | 264 +- .../src/paypal_seller_protection.rs | 137 +- generated/stripe_shared/src/period.rs | 94 +- generated/stripe_shared/src/person.rs | 317 +- .../src/person_additional_tos_acceptance.rs | 98 +- .../src/person_additional_tos_acceptances.rs | 90 +- .../src/person_future_requirements.rs | 117 +- .../stripe_shared/src/person_relationship.rs | 122 +- .../stripe_shared/src/person_requirements.rs | 117 +- generated/stripe_shared/src/plan.rs | 299 +- generated/stripe_shared/src/plan_tier.rs | 112 +- .../stripe_shared/src/platform_tax_fee.rs | 104 +- generated/stripe_shared/src/price.rs | 293 +- generated/stripe_shared/src/price_tier.rs | 112 +- generated/stripe_shared/src/product.rs | 219 +- .../stripe_shared/src/product_feature.rs | 91 +- generated/stripe_shared/src/promotion_code.rs | 147 +- .../src/promotion_code_currency_option.rs | 90 +- .../promotion_codes_resource_restrictions.rs | 110 +- generated/stripe_shared/src/quote.rs | 339 +- .../src/quotes_resource_automatic_tax.rs | 120 +- .../src/quotes_resource_computed.rs | 94 +- .../src/quotes_resource_from_quote.rs | 94 +- .../src/quotes_resource_recurring.rs | 134 +- .../src/quotes_resource_status_transitions.rs | 98 +- ...rce_subscription_data_subscription_data.rs | 102 +- .../src/quotes_resource_total_details.rs | 103 +- ...source_total_details_resource_breakdown.rs | 94 +- .../src/quotes_resource_transfer_data.rs | 98 +- .../src/quotes_resource_upfront.rs | 103 +- .../stripe_shared/src/radar_radar_options.rs | 91 +- .../src/radar_review_resource_location.rs | 106 +- .../src/radar_review_resource_session.rs | 102 +- generated/stripe_shared/src/recurring.rs | 183 +- generated/stripe_shared/src/refund.rs | 227 +- .../src/refund_destination_details.rs | 64 - .../src/refund_destination_details_card.rs | 73 - .../src/refund_destination_details_generic.rs | 7 - .../stripe_shared/src/refund_next_action.rs | 96 +- .../src/refund_next_action_display_details.rs | 94 +- .../stripe_shared/src/reserve_transaction.rs | 102 +- generated/stripe_shared/src/review.rs | 195 +- generated/stripe_shared/src/rule.rs | 98 +- .../src/schedules_phase_automatic_tax.rs | 94 +- .../src/sepa_debit_generated_from.rs | 94 +- generated/stripe_shared/src/setup_attempt.rs | 194 +- .../setup_attempt_payment_method_details.rs | 184 +- ...tempt_payment_method_details_acss_debit.rs | 82 +- ...pt_payment_method_details_au_becs_debit.rs | 82 +- ...tempt_payment_method_details_bacs_debit.rs | 82 +- ...tempt_payment_method_details_bancontact.rs | 151 +- ...p_attempt_payment_method_details_boleto.rs | 82 +- ...tup_attempt_payment_method_details_card.rs | 161 +- ...empt_payment_method_details_card_checks.rs | 98 +- ...mpt_payment_method_details_card_present.rs | 90 +- ...empt_payment_method_details_card_wallet.rs | 126 +- ..._attempt_payment_method_details_cashapp.rs | 82 +- ...up_attempt_payment_method_details_ideal.rs | 167 +- ...p_attempt_payment_method_details_klarna.rs | 82 +- ...tup_attempt_payment_method_details_link.rs | 82 +- ...p_attempt_payment_method_details_paypal.rs | 82 +- ...tempt_payment_method_details_sepa_debit.rs | 82 +- ...p_attempt_payment_method_details_sofort.rs | 151 +- ..._payment_method_details_us_bank_account.rs | 82 +- generated/stripe_shared/src/setup_intent.rs | 303 +- .../src/setup_intent_next_action.rs | 126 +- ...etup_intent_next_action_redirect_to_url.rs | 94 +- ...t_next_action_verify_with_microdeposits.rs | 122 +- .../setup_intent_payment_method_options.rs | 123 +- ...ntent_payment_method_options_acss_debit.rs | 151 +- ...etup_intent_payment_method_options_card.rs | 156 +- ...ent_method_options_card_mandate_options.rs | 216 +- ...etup_intent_payment_method_options_link.rs | 90 +- ...thod_options_mandate_options_acss_debit.rs | 186 +- ...thod_options_mandate_options_sepa_debit.rs | 82 +- ...up_intent_payment_method_options_paypal.rs | 90 +- ...ntent_payment_method_options_sepa_debit.rs | 94 +- ..._payment_method_options_us_bank_account.rs | 126 +- generated/stripe_shared/src/shipping.rs | 111 +- generated/stripe_shared/src/shipping_rate.rs | 187 +- .../src/shipping_rate_currency_option.rs | 116 +- .../src/shipping_rate_delivery_estimate.rs | 94 +- .../shipping_rate_delivery_estimate_bound.rs | 116 +- .../src/shipping_rate_fixed_amount.rs | 106 +- generated/stripe_shared/src/source.rs | 356 +- .../src/source_code_verification_flow.rs | 94 +- generated/stripe_shared/src/source_order.rs | 108 +- .../stripe_shared/src/source_order_item.rs | 120 +- generated/stripe_shared/src/source_owner.rs | 127 +- .../stripe_shared/src/source_receiver_flow.rs | 117 +- .../stripe_shared/src/source_redirect_flow.rs | 102 +- .../stripe_shared/src/source_transaction.rs | 179 +- ...ce_transaction_ach_credit_transfer_data.rs | 106 +- ...ce_transaction_chf_credit_transfer_data.rs | 117 +- ...ce_transaction_gbp_credit_transfer_data.rs | 129 +- .../source_transaction_paper_check_data.rs | 96 +- ...e_transaction_sepa_credit_transfer_data.rs | 101 +- .../src/source_type_ach_credit_transfer.rs | 135 +- .../src/source_type_ach_debit.rs | 125 +- .../src/source_type_acss_debit.rs | 147 +- .../stripe_shared/src/source_type_alipay.rs | 101 +- .../src/source_type_au_becs_debit.rs | 101 +- .../src/source_type_bancontact.rs | 123 +- .../stripe_shared/src/source_type_card.rs | 207 +- .../src/source_type_card_present.rs | 270 +- .../stripe_shared/src/source_type_eps.rs | 96 +- .../stripe_shared/src/source_type_giropay.rs | 106 +- .../stripe_shared/src/source_type_ideal.rs | 106 +- .../stripe_shared/src/source_type_klarna.rs | 270 +- .../src/source_type_multibanco.rs | 158 +- .../stripe_shared/src/source_type_p24.rs | 91 +- .../src/source_type_sepa_credit_transfer.rs | 165 +- .../src/source_type_sepa_debit.rs | 129 +- .../stripe_shared/src/source_type_sofort.rs | 129 +- .../src/source_type_three_d_secure.rs | 228 +- .../stripe_shared/src/source_type_wechat.rs | 101 +- generated/stripe_shared/src/subscription.rs | 392 +- .../src/subscription_automatic_tax.rs | 94 +- .../src/subscription_billing_thresholds.rs | 94 +- .../src/subscription_details_data.rs | 90 +- .../stripe_shared/src/subscription_item.rs | 133 +- .../subscription_item_billing_thresholds.rs | 90 +- ...ubscription_payment_method_options_card.rs | 150 +- ...scription_pending_invoice_item_interval.rs | 118 +- .../src/subscription_schedule.rs | 236 +- .../subscription_schedule_add_invoice_item.rs | 99 +- ...ubscription_schedule_configuration_item.rs | 119 +- .../subscription_schedule_current_phase.rs | 94 +- ...bscription_schedule_phase_configuration.rs | 282 +- ...ion_schedules_resource_default_settings.rs | 207 +- ...resource_default_settings_automatic_tax.rs | 94 +- .../src/subscription_transfer_data.rs | 94 +- ...ns_resource_billing_cycle_anchor_config.rs | 13 - ...subscriptions_resource_pause_collection.rs | 118 +- ...iptions_resource_payment_method_options.rs | 117 +- ...subscriptions_resource_payment_settings.rs | 152 +- .../subscriptions_resource_pending_update.rs | 112 +- ...scriptions_trials_resource_end_behavior.rs | 114 +- ...riptions_trials_resource_trial_settings.rs | 90 +- generated/stripe_shared/src/tax_code.rs | 98 +- .../src/tax_deducted_at_source.rs | 102 +- generated/stripe_shared/src/tax_i_ds_owner.rs | 75 - generated/stripe_shared/src/tax_id.rs | 150 +- .../stripe_shared/src/tax_id_verification.rs | 119 +- generated/stripe_shared/src/tax_rate.rs | 225 +- .../src/test_helpers_test_clock.rs | 143 +- .../src/three_d_secure_details.rs | 249 +- .../src/three_d_secure_details_charge.rs | 314 +- .../stripe_shared/src/three_d_secure_usage.rs | 90 +- generated/stripe_shared/src/topup.rs | 196 +- generated/stripe_shared/src/transfer.rs | 186 +- generated/stripe_shared/src/transfer_data.rs | 95 +- .../stripe_shared/src/transfer_reversal.rs | 132 +- .../stripe_shared/src/transfer_schedule.rs | 104 +- .../stripe_shared/src/transform_quantity.rs | 115 +- .../stripe_shared/src/transform_usage.rs | 115 +- .../src/us_bank_account_networks.rs | 116 +- .../stripe_shared/src/usage_record_summary.rs | 117 +- generated/stripe_terminal/.rustfmt.toml | 7 + generated/stripe_terminal/Cargo.toml | 2 + .../src/deleted_terminal_configuration.rs | 95 +- .../src/deleted_terminal_location.rs | 95 +- .../src/deleted_terminal_reader.rs | 95 +- generated/stripe_terminal/src/mod.rs | 3 + .../src/terminal_configuration/requests.rs | 302 +- .../src/terminal_configuration/types.rs | 132 +- ...ation_resource_currency_specific_config.rs | 101 +- ...on_resource_device_type_specific_config.rs | 91 +- ...n_configuration_resource_offline_config.rs | 90 +- ...guration_configuration_resource_tipping.rs | 213 +- .../src/terminal_connection_token/requests.rs | 5 +- .../src/terminal_connection_token/types.rs | 95 +- .../src/terminal_location/requests.rs | 280 +- .../src/terminal_location/types.rs | 118 +- .../src/terminal_reader/requests.rs | 510 +- .../src/terminal_reader/types.rs | 206 +- .../terminal_reader_reader_resource_cart.rs | 102 +- ...rminal_reader_reader_resource_line_item.rs | 98 +- ...l_reader_reader_resource_process_config.rs | 96 +- ..._resource_process_payment_intent_action.rs | 95 +- ...er_reader_resource_process_setup_config.rs | 82 +- ...er_resource_process_setup_intent_action.rs | 100 +- ...al_reader_reader_resource_reader_action.rs | 190 +- ...r_reader_resource_refund_payment_action.rs | 159 +- ...ader_resource_set_reader_display_action.rs | 120 +- ...l_reader_reader_resource_tipping_config.rs | 91 +- generated/stripe_treasury/.rustfmt.toml | 7 + generated/stripe_treasury/Cargo.toml | 2 + .../stripe_treasury/src/inbound_transfers.rs | 122 +- ..._payment_method_details_us_bank_account.rs | 195 +- generated/stripe_treasury/src/mod.rs | 3 + ...utbound_payments_payment_method_details.rs | 131 +- ...ayment_method_details_financial_account.rs | 118 +- ..._payment_method_details_us_bank_account.rs | 195 +- ...tbound_transfers_payment_method_details.rs | 126 +- ..._payment_method_details_us_bank_account.rs | 199 +- ...ayment_method_details_financial_account.rs | 118 +- .../src/treasury_credit_reversal/requests.rs | 30 +- .../src/treasury_credit_reversal/types.rs | 195 +- .../src/treasury_debit_reversal/requests.rs | 111 +- .../src/treasury_debit_reversal/types.rs | 217 +- .../treasury_financial_account/requests.rs | 199 +- .../src/treasury_financial_account/types.rs | 233 +- .../treasury_financial_account_features.rs | 144 +- ..._financial_accounts_resource_aba_record.rs | 112 +- ...l_accounts_resource_aba_toggle_settings.rs | 125 +- ...l_accounts_resource_ach_toggle_settings.rs | 125 +- ...ury_financial_accounts_resource_balance.rs | 98 +- ...accounts_resource_closed_status_details.rs | 114 +- ...ial_accounts_resource_financial_address.rs | 151 +- ...s_resource_financial_addresses_features.rs | 91 +- ...ial_accounts_resource_inbound_transfers.rs | 91 +- ...ial_accounts_resource_outbound_payments.rs | 96 +- ...al_accounts_resource_outbound_transfers.rs | 96 +- ...accounts_resource_platform_restrictions.rs | 138 +- ...ancial_accounts_resource_status_details.rs | 90 +- ...ncial_accounts_resource_toggle_settings.rs | 125 +- ...resource_toggles_setting_status_details.rs | 168 +- .../src/treasury_inbound_transfer/requests.rs | 237 +- .../src/treasury_inbound_transfer/types.rs | 230 +- ...ound_transfers_resource_failure_details.rs | 111 +- ..._inbound_transfer_resource_linked_flows.rs | 90 +- ...nd_transfer_resource_status_transitions.rs | 99 +- .../src/treasury_outbound_payment/requests.rs | 544 +- .../src/treasury_outbound_payment/types.rs | 240 +- ...bound_payment_resource_end_user_details.rs | 94 +- ...und_payment_resource_status_transitions.rs | 102 +- ...bound_payments_resource_returned_status.rs | 118 +- .../treasury_outbound_transfer/requests.rs | 374 +- .../src/treasury_outbound_transfer/types.rs | 218 +- ...und_transfers_resource_returned_details.rs | 118 +- ...d_transfers_resource_status_transitions.rs | 102 +- .../src/treasury_received_credit/requests.rs | 55 +- .../src/treasury_received_credit/types.rs | 284 +- ..._received_credits_resource_linked_flows.rs | 120 +- ...eived_credits_resource_reversal_details.rs | 122 +- ...d_credits_resource_source_flows_details.rs | 131 +- ...ved_credits_resource_status_transitions.rs | 90 +- .../src/treasury_received_debit/requests.rs | 54 +- .../src/treasury_received_debit/types.rs | 284 +- ...ts_resource_debit_reversal_linked_flows.rs | 90 +- ...y_received_debits_resource_linked_flows.rs | 102 +- ...ceived_debits_resource_reversal_details.rs | 122 +- ...ived_debits_resource_status_transitions.rs | 90 +- ...reasury_shared_resource_billing_details.rs | 98 +- ...tails_initiating_payment_method_details.rs | 209 +- ..._payment_method_details_us_bank_account.rs | 98 +- .../src/treasury_transaction/requests.rs | 59 +- .../src/treasury_transaction/types.rs | 202 +- .../treasury_transaction_entry/requests.rs | 59 +- .../src/treasury_transaction_entry/types.rs | 191 +- ...transaction_resource_status_transitions.rs | 94 +- ...ry_transactions_resource_balance_impact.rs | 98 +- ...sury_transactions_resource_flow_details.rs | 166 +- openapi/src/codegen.rs | 16 + openapi/src/object_writing.rs | 6 +- openapi/src/rust_object.rs | 97 +- openapi/src/rust_type.rs | 28 +- openapi/src/spec_inference.rs | 8 +- openapi/src/stripe_object.rs | 4 + openapi/src/templates/cargo_toml.rs | 12 +- openapi/src/templates/derives.rs | 42 - openapi/src/templates/enums.rs | 98 +- openapi/src/templates/miniserde.rs | 297 + openapi/src/templates/mod.rs | 3 +- openapi/src/templates/object_trait.rs | 12 +- openapi/src/templates/object_writer.rs | 62 +- openapi/src/templates/structs.rs | 19 +- openapi/src/templates/utils.rs | 10 +- openapi/src/types.rs | 4 + openapi/src/url_finder.rs | 6 +- openapi/src/webhook.rs | 35 +- stripe_types/Cargo.toml | 8 +- stripe_types/src/currency.rs | 1 + stripe_types/src/deser.rs | 26 + stripe_types/src/expandable.rs | 95 + stripe_types/src/ids.rs | 25 + stripe_types/src/lib.rs | 8 + stripe_types/src/miniserde_helpers.rs | 248 + stripe_types/src/pagination.rs | 178 +- stripe_types/src/params.rs | 38 + stripe_webhook/Cargo.toml | 14 +- stripe_webhook/src/error.rs | 4 +- stripe_webhook/src/generated/mod.rs | 1744 ++++-- stripe_webhook/src/webhook.rs | 17 +- tests/Cargo.toml | 19 +- tests/tests/it/deser.rs | 204 +- tests/tests/it/price.rs | 7 +- 1096 files changed, 119509 insertions(+), 32269 deletions(-) delete mode 100644 examples/checkout.rs delete mode 100644 examples/connect.rs create mode 100644 generated/stripe_billing/.rustfmt.toml create mode 100644 generated/stripe_checkout/.rustfmt.toml delete mode 100644 generated/stripe_checkout/src/checkout_swish_payment_method_options.rs delete mode 100644 generated/stripe_checkout/src/payment_pages_checkout_session_payment_method_reuse_agreement.rs create mode 100644 generated/stripe_connect/.rustfmt.toml delete mode 100644 generated/stripe_connect/src/connect_embedded_base_features.rs delete mode 100644 generated/stripe_connect/src/connect_embedded_payments_config.rs delete mode 100644 generated/stripe_connect/src/connect_embedded_payments_features.rs delete mode 100644 generated/stripe_connect/src/connect_embedded_payouts_config.rs delete mode 100644 generated/stripe_connect/src/connect_embedded_payouts_features.rs create mode 100644 generated/stripe_core/.rustfmt.toml delete mode 100644 generated/stripe_core/src/customer_session/mod.rs delete mode 100644 generated/stripe_core/src/customer_session/requests.rs delete mode 100644 generated/stripe_core/src/customer_session/types.rs delete mode 100644 generated/stripe_core/src/customer_session_resource_components.rs delete mode 100644 generated/stripe_core/src/customer_session_resource_components_resource_buy_button.rs delete mode 100644 generated/stripe_core/src/customer_session_resource_components_resource_pricing_table.rs create mode 100644 generated/stripe_fraud/.rustfmt.toml create mode 100644 generated/stripe_issuing/.rustfmt.toml create mode 100644 generated/stripe_misc/.rustfmt.toml delete mode 100644 generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs delete mode 100644 generated/stripe_misc/src/bank_connections_resource_transaction_resource_status_transitions.rs delete mode 100644 generated/stripe_misc/src/climate_order/mod.rs delete mode 100644 generated/stripe_misc/src/climate_order/requests.rs delete mode 100644 generated/stripe_misc/src/climate_order/types.rs delete mode 100644 generated/stripe_misc/src/climate_product/mod.rs delete mode 100644 generated/stripe_misc/src/climate_product/requests.rs delete mode 100644 generated/stripe_misc/src/climate_product/types.rs delete mode 100644 generated/stripe_misc/src/climate_removals_beneficiary.rs delete mode 100644 generated/stripe_misc/src/climate_removals_location.rs delete mode 100644 generated/stripe_misc/src/climate_removals_order_deliveries.rs delete mode 100644 generated/stripe_misc/src/climate_removals_products_price.rs delete mode 100644 generated/stripe_misc/src/climate_supplier/mod.rs delete mode 100644 generated/stripe_misc/src/climate_supplier/requests.rs delete mode 100644 generated/stripe_misc/src/climate_supplier/types.rs delete mode 100644 generated/stripe_misc/src/financial_connections_transaction/mod.rs delete mode 100644 generated/stripe_misc/src/financial_connections_transaction/requests.rs delete mode 100644 generated/stripe_misc/src/financial_connections_transaction/types.rs create mode 100644 generated/stripe_payment/.rustfmt.toml create mode 100644 generated/stripe_product/.rustfmt.toml create mode 100644 generated/stripe_shared/.rustfmt.toml delete mode 100644 generated/stripe_shared/src/account_annual_revenue.rs delete mode 100644 generated/stripe_shared/src/account_invoices_settings.rs delete mode 100644 generated/stripe_shared/src/connect_account_reference.rs delete mode 100644 generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_transferred_to_balance.rs delete mode 100644 generated/stripe_shared/src/destination_details_unimplemented.rs delete mode 100644 generated/stripe_shared/src/payment_intent_next_action_swish_handle_redirect_or_display_qr_code.rs delete mode 100644 generated/stripe_shared/src/payment_intent_next_action_swish_qr_code.rs delete mode 100644 generated/stripe_shared/src/payment_intent_payment_method_options_swish.rs delete mode 100644 generated/stripe_shared/src/payment_links_resource_completed_sessions.rs delete mode 100644 generated/stripe_shared/src/payment_links_resource_payment_method_reuse_agreement.rs delete mode 100644 generated/stripe_shared/src/payment_links_resource_restrictions.rs delete mode 100644 generated/stripe_shared/src/payment_links_resource_subscription_data_invoice_settings.rs delete mode 100644 generated/stripe_shared/src/payment_method_details_swish.rs delete mode 100644 generated/stripe_shared/src/payment_method_options_us_bank_account_mandate_options.rs delete mode 100644 generated/stripe_shared/src/payment_method_swish.rs delete mode 100644 generated/stripe_shared/src/refund_destination_details.rs delete mode 100644 generated/stripe_shared/src/refund_destination_details_card.rs delete mode 100644 generated/stripe_shared/src/refund_destination_details_generic.rs delete mode 100644 generated/stripe_shared/src/subscriptions_resource_billing_cycle_anchor_config.rs delete mode 100644 generated/stripe_shared/src/tax_i_ds_owner.rs create mode 100644 generated/stripe_terminal/.rustfmt.toml create mode 100644 generated/stripe_treasury/.rustfmt.toml delete mode 100644 openapi/src/templates/derives.rs create mode 100644 openapi/src/templates/miniserde.rs create mode 100644 stripe_types/src/deser.rs create mode 100644 stripe_types/src/miniserde_helpers.rs diff --git a/.github/workflows/async-stripe.yml b/.github/workflows/async-stripe.yml index 01e6e1f0e..08a288c3d 100644 --- a/.github/workflows/async-stripe.yml +++ b/.github/workflows/async-stripe.yml @@ -99,6 +99,9 @@ jobs: - name: Run clippy run: cargo clippy --features "runtime-${{ matrix.runtime }} full" + - name: Run clippy with min-ser + run: cargo clippy --features "runtime-${{ matrix.runtime }} full min-ser" + test: runs-on: ubuntu-latest strategy: @@ -129,6 +132,9 @@ jobs: - uses: Swatinem/rust-cache@v2 + - name: Test with min-ser + run: cargo test --features runtime-${{ matrix.runtime }} min-ser + - uses: taiki-e/install-action@cargo-llvm-cov - name: Test and gather coverage run: cargo llvm-cov --lcov --output-path lcov.info --features runtime-${{ matrix.runtime }} diff --git a/Cargo.toml b/Cargo.toml index afa6c7ef0..5d46307f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,4 +39,5 @@ edition = "2021" serde = { version = ">=1.0.79", features = ["derive"] } # we use `serde(other)` which was introduced in 1.0.79 http-types = { version = "2.12.0", default-features = false } smol_str = { version = "0.2.0", features = ["serde"] } -serde_json = "1.0" \ No newline at end of file +serde_json = "1.0" +miniserde = "0.1.34" diff --git a/async-stripe/Cargo.toml b/async-stripe/Cargo.toml index a3b75428a..c0916aa05 100644 --- a/async-stripe/Cargo.toml +++ b/async-stripe/Cargo.toml @@ -78,9 +78,9 @@ hyper-rustls-native = ["hyper-rustls", "hyper-rustls/native-tokio"] hyper-rustls-webpki = ["hyper-rustls", "hyper-rustls/webpki-tokio"] [dependencies] -stripe_types = {path = "../stripe_types"} -stripe_shared = {path = "../generated/stripe_shared"} -async-std = {version = "1.8,<1.11", optional = true} +stripe_types = { path = "../stripe_types" } +stripe_shared = { path = "../generated/stripe_shared" } +async-std = { version = "1.8,<1.11", optional = true } thiserror = "1.0.24" hyper = { version = "0.14", default-features = false, features = ["http1", "http2", "client", "tcp"], optional = true } @@ -91,7 +91,7 @@ serde_qs = "0.12.0" serde_path_to_error = "0.1.8" surf = { version = "2.1", optional = true } tokio = { version = "1.2", optional = true } -uuid = { version = "1.6.1", optional=true, features=["v4"] } +uuid = { version = "1.6.1", optional = true, features = ["v4"] } serde.workspace = true http-types.workspace = true @@ -103,4 +103,5 @@ futures-util = { version = "0.3.21", optional = true } [dev-dependencies] httpmock = "0.6.7" async-std = { version = "1.10.0", features = ["attributes"] } -tokio = { version = "1.24.1", features = ["rt", "macros"] } \ No newline at end of file +tokio = { version = "1.24.1", features = ["rt", "macros"] } +miniserde.workspace = true \ No newline at end of file diff --git a/async-stripe/src/client/base/async_std.rs b/async-stripe/src/client/base/async_std.rs index b13c56da8..b6e3e3e18 100644 --- a/async-stripe/src/client/base/async_std.rs +++ b/async-stripe/src/client/base/async_std.rs @@ -3,7 +3,7 @@ use std::pin::Pin; use async_std::task::sleep; use http_types::{Request, StatusCode}; -use serde::de::DeserializeOwned; +use stripe_types::StripeDeserialize; use crate::client::request_strategy::{Outcome, RequestStrategy}; use crate::error::StripeError; @@ -26,7 +26,7 @@ impl AsyncStdClient { Self { client: surf::Client::new() } } - pub fn execute<T: DeserializeOwned + Send + 'static>( + pub fn execute<T: StripeDeserialize + Send + 'static>( &self, request: Request, strategy: &RequestStrategy, @@ -38,8 +38,9 @@ impl AsyncStdClient { Box::pin(async move { let bytes = send_inner(&client, request, &strategy).await?; - let json_deserializer = &mut serde_json::Deserializer::from_slice(&bytes); - serde_path_to_error::deserialize(json_deserializer).map_err(StripeError::from) + let str = std::str::from_utf8(bytes.as_ref()) + .map_err(|_| StripeError::JSONDeserialize("Response was not valid UTF-8".into()))?; + T::deserialize(str).map_err(StripeError::JSONDeserialize) }) } } @@ -100,10 +101,16 @@ async fn send_inner( if !status.is_success() { tries += 1; - let json_deserializer = &mut serde_json::Deserializer::from_slice(&bytes); - last_error = serde_path_to_error::deserialize(json_deserializer) + let str = std::str::from_utf8(bytes.as_ref()).map_err(|_| { + StripeError::JSONDeserialize("Response was not valid UTF-8".into()) + })?; + last_error = stripe_shared::Error::deserialize(str) .map(|e: stripe_shared::Error| StripeError::Stripe(*e.error, status.into())) - .unwrap_or_else(StripeError::from); + .unwrap_or_else(|_| { + StripeError::JSONDeserialize( + "Could not deserialize Stripe error".into(), + ) + }); last_status = Some(status); last_retry_header = retry; diff --git a/async-stripe/src/client/base/tokio.rs b/async-stripe/src/client/base/tokio.rs index c0b8e0d66..7526c8b06 100644 --- a/async-stripe/src/client/base/tokio.rs +++ b/async-stripe/src/client/base/tokio.rs @@ -4,7 +4,7 @@ use std::pin::Pin; use http_types::{Request, StatusCode}; use hyper::http; use hyper::{client::HttpConnector, Body}; -use serde::de::DeserializeOwned; +use stripe_types::StripeDeserialize; use tokio::time::sleep; use crate::client::request_strategy::{Outcome, RequestStrategy}; @@ -77,7 +77,7 @@ impl TokioClient { } } - pub fn execute<T: DeserializeOwned + Send + 'static>( + pub fn execute<T: StripeDeserialize + Send + 'static>( &self, request: Request, strategy: &RequestStrategy, @@ -89,8 +89,9 @@ impl TokioClient { Box::pin(async move { let bytes = send_inner(&client, request, &strategy).await?; - let json_deserializer = &mut serde_json::Deserializer::from_slice(&bytes); - serde_path_to_error::deserialize(json_deserializer).map_err(StripeError::from) + let str = std::str::from_utf8(bytes.as_ref()) + .map_err(|_| StripeError::JSONDeserialize("Response was not valid UTF-8".into()))?; + T::deserialize(str).map_err(StripeError::JSONDeserialize) }) } } @@ -153,12 +154,18 @@ async fn send_inner( if !status.is_success() { tries += 1; - let json_deserializer = &mut serde_json::Deserializer::from_slice(&bytes); - last_error = serde_path_to_error::deserialize(json_deserializer) + let str = std::str::from_utf8(bytes.as_ref()).map_err(|_| { + StripeError::JSONDeserialize("Response was not valid UTF-8".into()) + })?; + last_error = stripe_shared::Error::deserialize(str) .map(|e: stripe_shared::Error| { StripeError::Stripe(*e.error, status.as_u16()) }) - .unwrap_or_else(StripeError::from); + .unwrap_or_else(|_| { + StripeError::JSONDeserialize( + "Could not deserialize Stripe error".into(), + ) + }); last_status = Some( // NOTE: StatusCode::from can panic here, so fall back to InternalServerError // see https://github.com/http-rs/http-types/blob/ac5d645ce5294554b86ebd49233d3ec01665d1d7/src/hyperium_http.rs#L20-L24 @@ -302,7 +309,7 @@ mod tests { async fn nice_serde_error() { use serde::Deserialize; - #[derive(Debug, Deserialize)] + #[derive(Debug, Deserialize, miniserde::Deserialize)] struct DataType { // Allowing dead code since used for deserialization #[allow(dead_code)] @@ -333,9 +340,8 @@ mod tests { mock.assert_hits_async(1).await; match res { - Err(StripeError::JSONSerialize(err)) => { - println!("Error: {:?} Path: {:?}", err.inner(), err.path().to_string()) - } + Err(StripeError::JSONSerialize(_)) => {} + Err(StripeError::JSONDeserialize(_)) => {} _ => panic!("Expected stripe error {:?}", res), } } diff --git a/async-stripe/src/client/base/tokio_blocking.rs b/async-stripe/src/client/base/tokio_blocking.rs index e29be6c22..42ff22e09 100644 --- a/async-stripe/src/client/base/tokio_blocking.rs +++ b/async-stripe/src/client/base/tokio_blocking.rs @@ -2,7 +2,7 @@ use std::{sync::Arc, time::Duration}; use http_types::Request; -use serde::de::DeserializeOwned; +use stripe_types::StripeDeserialize; use crate::client::base::tokio::TokioClient; use crate::client::request_strategy::RequestStrategy; @@ -39,7 +39,7 @@ impl TokioBlockingClient { TokioBlockingClient { inner, runtime: Arc::new(runtime) } } - pub fn execute<T: DeserializeOwned + Send + 'static>( + pub fn execute<T: StripeDeserialize + Send + 'static>( &self, request: Request, strategy: &RequestStrategy, diff --git a/async-stripe/src/client/stripe.rs b/async-stripe/src/client/stripe.rs index bf720b048..d819ff538 100644 --- a/async-stripe/src/client/stripe.rs +++ b/async-stripe/src/client/stripe.rs @@ -1,9 +1,9 @@ // Necessary under tokio-blocking since `Response` is a type alias to a `Result` #![allow(clippy::missing_errors_doc)] use http_types::{Body, Method, Request, Url}; -use serde::de::DeserializeOwned; use serde::Serialize; use stripe_shared::version::VERSION; +use stripe_types::StripeDeserialize; use crate::client::headers::{AppInfo, Headers}; use crate::{ @@ -86,12 +86,12 @@ impl Client { } /// Make a `GET` http request with just a path - pub fn get<T: DeserializeOwned + Send + 'static>(&self, path: &str) -> Response<T> { + pub fn get<T: StripeDeserialize + Send + 'static>(&self, path: &str) -> Response<T> { self.send(path, Method::Get) } /// Make a `GET` http request with url query parameters - pub fn get_query<T: DeserializeOwned + Send + 'static, P: Serialize>( + pub fn get_query<T: StripeDeserialize + Send + 'static, P: Serialize>( &self, path: &str, params: P, @@ -103,7 +103,7 @@ impl Client { self.client.execute::<T>(self.create_request(Method::Get, url), &self.strategy) } - pub fn send<T: DeserializeOwned + Send + 'static>( + pub fn send<T: StripeDeserialize + Send + 'static>( &self, path: &str, method: Method, @@ -113,17 +113,17 @@ impl Client { } /// Make a `DELETE` http request with just a path - pub fn delete<T: DeserializeOwned + Send + 'static>(&self, path: &str) -> Response<T> { + pub fn delete<T: StripeDeserialize + Send + 'static>(&self, path: &str) -> Response<T> { self.send(path, Method::Delete) } /// Make a `POST` http request with just a path - pub fn post<T: DeserializeOwned + Send + 'static>(&self, path: &str) -> Response<T> { + pub fn post<T: StripeDeserialize + Send + 'static>(&self, path: &str) -> Response<T> { self.send(path, Method::Post) } /// Make a `POST` http request with urlencoded body - pub fn post_form<T: DeserializeOwned + Send + 'static, F: Serialize>( + pub fn post_form<T: StripeDeserialize + Send + 'static, F: Serialize>( &self, path: &str, form: F, @@ -132,7 +132,7 @@ impl Client { } /// Make a `DELETE` http request with urlencoded body - pub fn delete_form<T: DeserializeOwned + Send + 'static, F: Serialize>( + pub fn delete_form<T: StripeDeserialize + Send + 'static, F: Serialize>( &self, path: &str, form: F, @@ -141,7 +141,7 @@ impl Client { } /// Make an http request with urlencoded body - pub fn send_form<T: DeserializeOwned + Send + 'static, F: Serialize>( + pub fn send_form<T: StripeDeserialize + Send + 'static, F: Serialize>( &self, path: &str, form: F, diff --git a/async-stripe/src/error.rs b/async-stripe/src/error.rs index 51b440e28..a33208569 100644 --- a/async-stripe/src/error.rs +++ b/async-stripe/src/error.rs @@ -10,6 +10,8 @@ pub enum StripeError { QueryStringSerialize(#[from] serde_path_to_error::Error<serde_qs::Error>), #[error("error serializing or deserializing a request")] JSONSerialize(#[from] serde_path_to_error::Error<serde_json::Error>), + #[error("error serializing a request")] + JSONDeserialize(String), #[error("attempted to access an unsupported version of the api")] UnsupportedVersion, #[error("error communicating with stripe: {0}")] diff --git a/crate_info.md b/crate_info.md index 8cfffff4c..e0a539faa 100644 --- a/crate_info.md +++ b/crate_info.md @@ -31,7 +31,6 @@ | [Topup](https://stripe.com/docs/api/topups/object) | stripe_connect | topup | | [TransferReversal](https://stripe.com/docs/api/transfer_reversals/object) | stripe_connect | transfer_reversal | | [Transfer](https://stripe.com/docs/api/transfers/object) | stripe_connect | transfer | -| CustomerSession | stripe_core | customer_session | | PaymentSource | stripe_core | payment_source | | [BalanceTransaction](https://stripe.com/docs/api/balance_transactions/object) | stripe_core | balance_transaction | | [Balance](https://stripe.com/docs/api/balance/balance_object) | stripe_core | balance | @@ -62,12 +61,8 @@ | [IssuingToken](https://stripe.com/docs/api/issuing/tokens/object) | stripe_issuing | issuing_token | | [IssuingTransaction](https://stripe.com/docs/api/issuing/transactions/object) | stripe_issuing | issuing_transaction | | ApplePayDomain | stripe_misc | apple_pay_domain | -| ClimateOrder | stripe_misc | climate_order | -| ClimateProduct | stripe_misc | climate_product | -| ClimateSupplier | stripe_misc | climate_supplier | | EphemeralKey | stripe_misc | ephemeral_key | | ExchangeRate | stripe_misc | exchange_rate | -| FinancialConnectionsTransaction | stripe_misc | financial_connections_transaction | | TaxRegistration | stripe_misc | tax_registration | | [FinancialConnectionsAccount](https://stripe.com/docs/api/financial_connections/accounts/object) | stripe_misc | financial_connections_account | | [FinancialConnectionsSession](https://stripe.com/docs/api/financial_connections/sessions/object) | stripe_misc | financial_connections_session | diff --git a/examples/checkout.rs b/examples/checkout.rs deleted file mode 100644 index e929575c6..000000000 --- a/examples/checkout.rs +++ /dev/null @@ -1,104 +0,0 @@ -//! Checkout -//! ======== -//! -//! Reference: <https://stripe.com/docs/api/checkout/sessions> -//! -//! This example shows how to build a checkout session for -//! a particular product and price. Creating a checkout -//! session generates a URL that the user can use to pay. -//! Notice you have to define the customer ahead of time. -//! If you'd rather avoid this, you can use a [stripe::PaymentLink]. - -use stripe::{ - CheckoutSession, CheckoutSessionMode, Client, CreateCheckoutSession, - CreateCheckoutSessionLineItems, CreateCustomer, CreatePrice, CreateProduct, Currency, Customer, - Expandable, IdOrCreate, Price, Product, -}; - -#[tokio::main] -async fn main() { - let secret_key = std::env::var("STRIPE_SECRET_KEY").expect("Missing STRIPE_SECRET_KEY in env"); - let client = Client::new(secret_key); - - let customer = Customer::create( - &client, - CreateCustomer { - name: Some("Alexander Lyon"), - email: Some("test@async-stripe.com"), - description: Some( - "A fake customer that is used to illustrate the examples in async-stripe.", - ), - metadata: Some(std::collections::HashMap::from([( - String::from("async-stripe"), - String::from("true"), - )])), - - ..Default::default() - }, - ) - .await - .unwrap(); - - println!("created a customer at https://dashboard.stripe.com/test/customers/{}", customer.id); - - // create a new example project - let product = { - let mut create_product = CreateProduct::new("T-Shirt"); - create_product.metadata = Some(std::collections::HashMap::from([( - String::from("async-stripe"), - String::from("true"), - )])); - Product::create(&client, create_product).await.unwrap() - }; - - // and add a price for it in USD - let price = { - let mut create_price = CreatePrice::new(Currency::USD); - create_price.product = Some(IdOrCreate::Id(&product.id)); - create_price.metadata = Some(std::collections::HashMap::from([( - String::from("async-stripe"), - String::from("true"), - )])); - create_price.unit_amount = Some(1000); - create_price.expand = &["product"]; - Price::create(&client, create_price).await.unwrap() - }; - - println!( - "created a product {:?} at price {} {}", - product.name.unwrap(), - price.unit_amount.unwrap() / 100, - price.currency.unwrap() - ); - - // finally, create a checkout session for this product / price - let checkout_session = { - let mut params = CreateCheckoutSession::new(); - params.cancel_url = Some("http://test.com/cancel"); - params.customer = Some(customer.id); - params.mode = Some(CheckoutSessionMode::Payment); - params.line_items = Some(vec![CreateCheckoutSessionLineItems { - quantity: Some(3), - price: Some(price.id.to_string()), - ..Default::default() - }]); - params.expand = &["line_items", "line_items.data.price.product"]; - - CheckoutSession::create(&client, params).await.unwrap() - }; - - let line_items = checkout_session.line_items.unwrap(); - - println!( - "created a {} checkout session for {} {:?} for {} {} at {}", - checkout_session.payment_status, - line_items.data[0].quantity.unwrap(), - match line_items.data[0].price.as_ref().unwrap().product.as_ref().unwrap() { - Expandable::Object(p) => p.name.as_ref().unwrap(), - _ => panic!("product not found"), - }, - checkout_session.amount_subtotal.unwrap() / 100, - line_items.data[0].price.as_ref().unwrap().currency.unwrap(), - checkout_session.url.unwrap() - ); -} diff --git a/examples/connect.rs b/examples/connect.rs deleted file mode 100644 index f16289753..000000000 --- a/examples/connect.rs +++ /dev/null @@ -1,58 +0,0 @@ -//! Stripe Connect -//! ============== -//! -//! Reference: <https://stripe.com/docs/api/account_links> -//! -//! This example shows how to manange a Stripe connect account, -//! initiating an account link which can be used to onboard a -//! new user to your application. -//! -//! Node: To get started, you'll need to make sure you have signed up to -//! use stripe connect and configure branding settings with an icon and a -//! brand color. See more: <https://dashboard.stripe.com/connect/accounts/overview> - -use stripe::{ - Account, AccountLink, AccountLinkType, AccountType, Client, CreateAccount, - CreateAccountCapabilities, CreateAccountCapabilitiesCardPayments, - CreateAccountCapabilitiesTransfers, CreateAccountLink, -}; - -#[tokio::main] -async fn main() { - let secret_key = std::env::var("STRIPE_SECRET_KEY").expect("Missing STRIPE_SECRET_KEY in env"); - let client = Client::new(secret_key); - - let account = Account::create( - &client, - CreateAccount { - type_: Some(AccountType::Express), - capabilities: Some(CreateAccountCapabilities { - card_payments: Some(CreateAccountCapabilitiesCardPayments { - requested: Some(true), - }), - transfers: Some(CreateAccountCapabilitiesTransfers { requested: Some(true) }), - ..Default::default() - }), - ..Default::default() - }, - ) - .await - .unwrap(); - - let link = AccountLink::create( - &client, - CreateAccountLink { - account: account.id.clone(), - type_: AccountLinkType::AccountOnboarding, - collect: None, - expand: &[], - refresh_url: Some("https://test.com/refresh"), - return_url: Some("https://test.com/return"), - collection_options: None, - }, - ) - .await - .unwrap(); - - println!("created a stripe connect link at {}", link.url); -} diff --git a/examples/endpoints/Cargo.toml b/examples/endpoints/Cargo.toml index 94f8903cc..294fb045c 100644 --- a/examples/endpoints/Cargo.toml +++ b/examples/endpoints/Cargo.toml @@ -8,19 +8,20 @@ publish = false [dependencies] futures-util = "0.3.28" tokio = { version = "1.24.1", features = ["rt-multi-thread", "macros"] } -async-stripe = {path = "../../async-stripe"} -stripe_types = {path = "../../stripe_types"} -stripe_billing = {path = "../../generated/stripe_billing", features = ["subscription"]} -stripe_core = {path = "../../generated/stripe_core", features = ["customer", "payment_intent"]} -stripe_product = {path = "../../generated/stripe_product", features = ["product", "price"]} -stripe_payment = {path = "../../generated/stripe_payment", features = ["payment_method", "payment_link"]} -stripe_checkout = {path = "../../generated/stripe_checkout", features = ["checkout_session"]} -stripe_connect = {path = "../../generated/stripe_connect", features = ["account", "account_link"]} +async-stripe = { path = "../../async-stripe" } +stripe_types = { path = "../../stripe_types" } +stripe_billing = { path = "../../generated/stripe_billing", features = ["subscription"] } +stripe_core = { path = "../../generated/stripe_core", features = ["customer", "payment_intent"] } +stripe_product = { path = "../../generated/stripe_product", features = ["product", "price"] } +stripe_payment = { path = "../../generated/stripe_payment", features = ["payment_method", "payment_link"] } +stripe_checkout = { path = "../../generated/stripe_checkout", features = ["checkout_session"] } +stripe_connect = { path = "../../generated/stripe_connect", features = ["account", "account_link"] } [features] async = [] +min-ser = ["stripe_types/min-ser", "stripe_checkout/min-ser", "stripe_core/min-ser", "stripe_checkout/min-ser", "stripe_billing/min-ser", "stripe_connect/min-ser", "stripe_payment/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper", "async"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls", "async"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki", "async"] -runtime-async-std-surf = ["async-stripe/runtime-async-std-surf", "async"] \ No newline at end of file +runtime-async-std-surf = ["async-stripe/runtime-async-std-surf", "async"] diff --git a/examples/endpoints/src/connect.rs b/examples/endpoints/src/connect.rs index 9169ed0ee..f97e1730c 100644 --- a/examples/endpoints/src/connect.rs +++ b/examples/endpoints/src/connect.rs @@ -36,7 +36,6 @@ pub async fn run_connect_example(client: &stripe::Client) -> Result<(), StripeEr return_url: Some("https://test.com/return"), expand: None, collect: None, - collection_options: None, } .send(client) .await?; diff --git a/generated/stripe_billing/.rustfmt.toml b/generated/stripe_billing/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_billing/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_billing/Cargo.toml b/generated/stripe_billing/Cargo.toml index 7d6c2572c..9011c2d8c 100644 --- a/generated/stripe_billing/Cargo.toml +++ b/generated/stripe_billing/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_billing/src/billing_portal_configuration/requests.rs b/generated/stripe_billing/src/billing_portal_configuration/requests.rs index 36d17f455..bd6f01166 100644 --- a/generated/stripe_billing/src/billing_portal_configuration/requests.rs +++ b/generated/stripe_billing/src/billing_portal_configuration/requests.rs @@ -31,39 +31,13 @@ impl<'a> ListBillingPortalConfiguration<'a> { } impl<'a> ListBillingPortalConfiguration<'a> { /// Returns a list of configurations that describe the functionality of the customer portal. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_billing::BillingPortalConfiguration>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_billing::BillingPortalConfiguration>> { client.get_query("/billing_portal/configurations", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_billing::BillingPortalConfiguration>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_billing::BillingPortalConfiguration>> { stripe::ListPaginator::from_list_params("/billing_portal/configurations", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveBillingPortalConfiguration<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveBillingPortalConfiguration<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveBillingPortalConfiguration<'a> { - /// Retrieves a configuration that describes the functionality of the customer portal. - pub fn send( - &self, - client: &stripe::Client, - configuration: &stripe_billing::BillingPortalConfigurationId, - ) -> stripe::Response<stripe_billing::BillingPortalConfiguration> { - client.get_query(&format!("/billing_portal/configurations/{configuration}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateBillingPortalConfiguration<'a> { /// The business information shown to customers in the portal. @@ -89,18 +63,8 @@ pub struct CreateBillingPortalConfiguration<'a> { pub metadata: Option<&'a std::collections::HashMap<String, String>>, } impl<'a> CreateBillingPortalConfiguration<'a> { - pub fn new( - business_profile: CreateBillingPortalConfigurationBusinessProfile<'a>, - features: CreateBillingPortalConfigurationFeatures<'a>, - ) -> Self { - Self { - business_profile, - default_return_url: None, - expand: None, - features, - login_page: None, - metadata: None, - } + pub fn new(business_profile: CreateBillingPortalConfigurationBusinessProfile<'a>, features: CreateBillingPortalConfigurationFeatures<'a>) -> Self { + Self { business_profile, default_return_url: None, expand: None, features, login_page: None, metadata: None } } } /// The business information shown to customers in the portal. @@ -153,8 +117,7 @@ impl<'a> CreateBillingPortalConfigurationFeatures<'a> { pub struct CreateBillingPortalConfigurationFeaturesCustomerUpdate<'a> { /// The types of customer updates that are supported. When empty, customers are not updateable. #[serde(skip_serializing_if = "Option::is_none")] - pub allowed_updates: - Option<&'a [CreateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates]>, + pub allowed_updates: Option<&'a [CreateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates]>, /// Whether the feature is enabled. pub enabled: bool, } @@ -248,8 +211,7 @@ impl CreateBillingPortalConfigurationFeaturesPaymentMethodUpdate { pub struct CreateBillingPortalConfigurationFeaturesSubscriptionCancel<'a> { /// Whether the cancellation reasons will be collected in the portal and which options are exposed to the customer. #[serde(skip_serializing_if = "Option::is_none")] - pub cancellation_reason: - Option<CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason<'a>>, + pub cancellation_reason: Option<CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason<'a>>, /// Whether the feature is enabled. pub enabled: bool, /// Whether to cancel subscriptions immediately or at the end of the billing period. @@ -259,8 +221,7 @@ pub struct CreateBillingPortalConfigurationFeaturesSubscriptionCancel<'a> { /// Possible values are `none` and `create_prorations`, which is only compatible with `mode=immediately`. /// No prorations are generated when canceling a subscription at the end of its natural billing period. #[serde(skip_serializing_if = "Option::is_none")] - pub proration_behavior: - Option<CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior>, + pub proration_behavior: Option<CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior>, } impl<'a> CreateBillingPortalConfigurationFeaturesSubscriptionCancel<'a> { pub fn new(enabled: bool) -> Self { @@ -273,14 +234,10 @@ pub struct CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellatio /// Whether the feature is enabled. pub enabled: bool, /// Which cancellation reasons will be given as options to the customer. - pub options: - &'a [CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions], + pub options: &'a [CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions], } impl<'a> CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason<'a> { - pub fn new( - enabled: bool, - options: &'a [CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions], - ) -> Self { + pub fn new(enabled: bool, options: &'a [CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions]) -> Self { Self { enabled, options } } } @@ -312,9 +269,7 @@ impl CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReaso } } -impl std::str::FromStr - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl std::str::FromStr for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions::*; @@ -331,24 +286,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl std::fmt::Display for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl std::fmt::Debug for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl serde::Serialize for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -422,9 +371,7 @@ impl CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior } } -impl std::str::FromStr - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl std::str::FromStr for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior::*; @@ -436,24 +383,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl std::fmt::Display for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl std::fmt::Debug for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl serde::Serialize for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -465,8 +406,7 @@ impl serde::Serialize #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { /// The types of subscription updates that are supported. When empty, subscriptions are not updateable. - pub default_allowed_updates: - &'a [CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates], + pub default_allowed_updates: &'a [CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates], /// Whether the feature is enabled. pub enabled: bool, /// The list of up to 10 products that support subscription updates. @@ -474,8 +414,7 @@ pub struct CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { /// Determines how to handle prorations resulting from subscription updates. /// Valid values are `none`, `create_prorations`, and `always_invoice`. #[serde(skip_serializing_if = "Option::is_none")] - pub proration_behavior: - Option<CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior>, + pub proration_behavior: Option<CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior>, } impl<'a> CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { pub fn new( @@ -504,9 +443,7 @@ impl CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpd } } -impl std::str::FromStr - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl std::str::FromStr for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates::*; @@ -518,24 +455,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl std::fmt::Display for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl std::fmt::Debug for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl serde::Serialize for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -562,9 +493,7 @@ impl CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior } } -impl std::str::FromStr - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl std::str::FromStr for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior::*; @@ -576,24 +505,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl std::fmt::Display for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl std::fmt::Debug for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl serde::Serialize for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -615,10 +538,7 @@ impl CreateBillingPortalConfigurationLoginPage { } impl<'a> CreateBillingPortalConfiguration<'a> { /// Creates a configuration that describes the functionality and behavior of a PortalSession - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_billing::BillingPortalConfiguration> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_billing::BillingPortalConfiguration> { client.send_form("/billing_portal/configurations", self, http_types::Method::Post) } } @@ -706,8 +626,7 @@ impl<'a> UpdateBillingPortalConfigurationFeatures<'a> { pub struct UpdateBillingPortalConfigurationFeaturesCustomerUpdate<'a> { /// The types of customer updates that are supported. When empty, customers are not updateable. #[serde(skip_serializing_if = "Option::is_none")] - pub allowed_updates: - Option<&'a [UpdateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates]>, + pub allowed_updates: Option<&'a [UpdateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates]>, /// Whether the feature is enabled. #[serde(skip_serializing_if = "Option::is_none")] pub enabled: Option<bool>, @@ -802,8 +721,7 @@ impl UpdateBillingPortalConfigurationFeaturesPaymentMethodUpdate { pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionCancel<'a> { /// Whether the cancellation reasons will be collected in the portal and which options are exposed to the customer. #[serde(skip_serializing_if = "Option::is_none")] - pub cancellation_reason: - Option<UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason<'a>>, + pub cancellation_reason: Option<UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason<'a>>, /// Whether the feature is enabled. #[serde(skip_serializing_if = "Option::is_none")] pub enabled: Option<bool>, @@ -814,8 +732,7 @@ pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionCancel<'a> { /// Possible values are `none` and `create_prorations`, which is only compatible with `mode=immediately`. /// No prorations are generated when canceling a subscription at the end of its natural billing period. #[serde(skip_serializing_if = "Option::is_none")] - pub proration_behavior: - Option<UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior>, + pub proration_behavior: Option<UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior>, } impl<'a> UpdateBillingPortalConfigurationFeaturesSubscriptionCancel<'a> { pub fn new() -> Self { @@ -829,9 +746,7 @@ pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellatio pub enabled: bool, /// Which cancellation reasons will be given as options to the customer. #[serde(skip_serializing_if = "Option::is_none")] - pub options: Option< - &'a [UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions], - >, + pub options: Option<&'a [UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions]>, } impl<'a> UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReason<'a> { pub fn new(enabled: bool) -> Self { @@ -866,9 +781,7 @@ impl UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReaso } } -impl std::str::FromStr - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl std::str::FromStr for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions::*; @@ -885,24 +798,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl std::fmt::Display for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl std::fmt::Debug for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions -{ +impl serde::Serialize for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -976,9 +883,7 @@ impl UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior } } -impl std::str::FromStr - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl std::str::FromStr for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior::*; @@ -990,24 +895,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl std::fmt::Display for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl std::fmt::Debug for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior -{ +impl serde::Serialize for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1020,9 +919,7 @@ impl serde::Serialize pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { /// The types of subscription updates that are supported. When empty, subscriptions are not updateable. #[serde(skip_serializing_if = "Option::is_none")] - pub default_allowed_updates: Option< - &'a [UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates], - >, + pub default_allowed_updates: Option<&'a [UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates]>, /// Whether the feature is enabled. #[serde(skip_serializing_if = "Option::is_none")] pub enabled: Option<bool>, @@ -1032,8 +929,7 @@ pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { /// Determines how to handle prorations resulting from subscription updates. /// Valid values are `none`, `create_prorations`, and `always_invoice`. #[serde(skip_serializing_if = "Option::is_none")] - pub proration_behavior: - Option<UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior>, + pub proration_behavior: Option<UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior>, } impl<'a> UpdateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { pub fn new() -> Self { @@ -1058,9 +954,7 @@ impl UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpd } } -impl std::str::FromStr - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl std::str::FromStr for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates::*; @@ -1072,24 +966,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl std::fmt::Display for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl std::fmt::Debug for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates -{ +impl serde::Serialize for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1116,9 +1004,7 @@ impl UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior } } -impl std::str::FromStr - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl std::str::FromStr for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior::*; @@ -1130,24 +1016,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl std::fmt::Display for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl std::fmt::Debug for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior -{ +impl serde::Serialize for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1171,16 +1051,25 @@ impl UpdateBillingPortalConfigurationLoginPage { } impl<'a> UpdateBillingPortalConfiguration<'a> { /// Updates a configuration that describes the functionality of the customer portal. - pub fn send( - &self, - client: &stripe::Client, - configuration: &stripe_billing::BillingPortalConfigurationId, - ) -> stripe::Response<stripe_billing::BillingPortalConfiguration> { - client.send_form( - &format!("/billing_portal/configurations/{configuration}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, configuration: &stripe_billing::BillingPortalConfigurationId) -> stripe::Response<stripe_billing::BillingPortalConfiguration> { + client.send_form(&format!("/billing_portal/configurations/{configuration}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveBillingPortalConfiguration<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveBillingPortalConfiguration<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveBillingPortalConfiguration<'a> { + /// Retrieves a configuration that describes the functionality of the customer portal. + pub fn send(&self, client: &stripe::Client, configuration: &stripe_billing::BillingPortalConfigurationId) -> stripe::Response<stripe_billing::BillingPortalConfiguration> { + client.get_query(&format!("/billing_portal/configurations/{configuration}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_billing/src/billing_portal_configuration/types.rs b/generated/stripe_billing/src/billing_portal_configuration/types.rs index 8bca7d765..2207fc480 100644 --- a/generated/stripe_billing/src/billing_portal_configuration/types.rs +++ b/generated/stripe_billing/src/billing_portal_configuration/types.rs @@ -1,5 +1,7 @@ /// A portal configuration describes the functionality and behavior of a portal session. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BillingPortalConfiguration { /// Whether the configuration is active and can be used to create portal sessions. pub active: bool, @@ -26,6 +28,149 @@ pub struct BillingPortalConfiguration { /// Time at which the object was last updated. Measured in seconds since the Unix epoch. pub updated: stripe_types::Timestamp, } +#[cfg(feature = "min-ser")] +pub struct BillingPortalConfigurationBuilder { + active: Option<bool>, + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + business_profile: Option<stripe_billing::PortalBusinessProfile>, + created: Option<stripe_types::Timestamp>, + default_return_url: Option<Option<String>>, + features: Option<stripe_billing::PortalFeatures>, + id: Option<stripe_billing::BillingPortalConfigurationId>, + is_default: Option<bool>, + livemode: Option<bool>, + login_page: Option<stripe_billing::PortalLoginPage>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + updated: Option<stripe_types::Timestamp>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BillingPortalConfiguration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BillingPortalConfiguration>, + builder: BillingPortalConfigurationBuilder, + } + + impl Visitor for Place<BillingPortalConfiguration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BillingPortalConfigurationBuilder::deser_default() })) + } + } + + impl MapBuilder for BillingPortalConfigurationBuilder { + type Out = BillingPortalConfiguration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "application" => Deserialize::begin(&mut self.application), + "business_profile" => Deserialize::begin(&mut self.business_profile), + "created" => Deserialize::begin(&mut self.created), + "default_return_url" => Deserialize::begin(&mut self.default_return_url), + "features" => Deserialize::begin(&mut self.features), + "id" => Deserialize::begin(&mut self.id), + "is_default" => Deserialize::begin(&mut self.is_default), + "livemode" => Deserialize::begin(&mut self.livemode), + "login_page" => Deserialize::begin(&mut self.login_page), + "metadata" => Deserialize::begin(&mut self.metadata), + "updated" => Deserialize::begin(&mut self.updated), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + application: Deserialize::default(), + business_profile: Deserialize::default(), + created: Deserialize::default(), + default_return_url: Deserialize::default(), + features: Deserialize::default(), + id: Deserialize::default(), + is_default: Deserialize::default(), + livemode: Deserialize::default(), + login_page: Deserialize::default(), + metadata: Deserialize::default(), + updated: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let application = self.application.take()?; + let business_profile = self.business_profile.take()?; + let created = self.created.take()?; + let default_return_url = self.default_return_url.take()?; + let features = self.features.take()?; + let id = self.id.take()?; + let is_default = self.is_default.take()?; + let livemode = self.livemode.take()?; + let login_page = self.login_page.take()?; + let metadata = self.metadata.take()?; + let updated = self.updated.take()?; + + Some(Self::Out { active, application, business_profile, created, default_return_url, features, id, is_default, livemode, login_page, metadata, updated }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BillingPortalConfiguration { + type Builder = BillingPortalConfigurationBuilder; + } + + impl FromValueOpt for BillingPortalConfiguration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BillingPortalConfigurationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "business_profile" => b.business_profile = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "default_return_url" => b.default_return_url = Some(FromValueOpt::from_value(v)?), + "features" => b.features = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "is_default" => b.is_default = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "login_page" => b.login_page = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "updated" => b.updated = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for BillingPortalConfiguration { type Id = stripe_billing::BillingPortalConfigurationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_billing/src/billing_portal_session/requests.rs b/generated/stripe_billing/src/billing_portal_session/requests.rs index 85fcfaa43..29b3c6848 100644 --- a/generated/stripe_billing/src/billing_portal_session/requests.rs +++ b/generated/stripe_billing/src/billing_portal_session/requests.rs @@ -29,15 +29,7 @@ pub struct CreateBillingPortalSession<'a> { } impl<'a> CreateBillingPortalSession<'a> { pub fn new(customer: &'a str) -> Self { - Self { - configuration: None, - customer, - expand: None, - flow_data: None, - locale: None, - on_behalf_of: None, - return_url: None, - } + Self { configuration: None, customer, expand: None, flow_data: None, locale: None, on_behalf_of: None, return_url: None } } } /// Information about a specific flow for the customer to go through. @@ -55,21 +47,14 @@ pub struct CreateBillingPortalSessionFlowData<'a> { pub subscription_update: Option<CreateBillingPortalSessionFlowDataSubscriptionUpdate<'a>>, /// Configuration when `flow_data.type=subscription_update_confirm`. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_update_confirm: - Option<CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirm<'a>>, + pub subscription_update_confirm: Option<CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirm<'a>>, /// Type of flow that the customer will go through. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateBillingPortalSessionFlowDataType, } impl<'a> CreateBillingPortalSessionFlowData<'a> { pub fn new(type_: CreateBillingPortalSessionFlowDataType) -> Self { - Self { - after_completion: None, - subscription_cancel: None, - subscription_update: None, - subscription_update_confirm: None, - type_, - } + Self { after_completion: None, subscription_cancel: None, subscription_update: None, subscription_update_confirm: None, type_ } } } /// Behavior after the flow is completed. @@ -77,13 +62,12 @@ impl<'a> CreateBillingPortalSessionFlowData<'a> { pub struct CreateBillingPortalSessionFlowDataAfterCompletion<'a> { /// Configuration when `after_completion.type=hosted_confirmation`. #[serde(skip_serializing_if = "Option::is_none")] - pub hosted_confirmation: - Option<CreateBillingPortalSessionFlowDataAfterCompletionHostedConfirmation<'a>>, + pub hosted_confirmation: Option<CreateBillingPortalSessionFlowDataAfterCompletionHostedConfirmation<'a>>, /// Configuration when `after_completion.type=redirect`. #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option<CreateBillingPortalSessionFlowDataAfterCompletionRedirect<'a>>, /// The specified behavior after the flow is completed. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateBillingPortalSessionFlowDataAfterCompletionType, } impl<'a> CreateBillingPortalSessionFlowDataAfterCompletion<'a> { @@ -183,14 +167,11 @@ pub struct CreateBillingPortalSessionFlowDataSubscriptionCancelRetention<'a> { /// Configuration when `retention.type=coupon_offer`. pub coupon_offer: CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionCouponOffer<'a>, /// Type of retention strategy to use with the customer. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionType, } impl<'a> CreateBillingPortalSessionFlowDataSubscriptionCancelRetention<'a> { - pub fn new( - coupon_offer: CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionCouponOffer<'a>, - type_: CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionType, - ) -> Self { + pub fn new(coupon_offer: CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionCouponOffer<'a>, type_: CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionType) -> Self { Self { coupon_offer, type_ } } } @@ -265,8 +246,7 @@ pub struct CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirm<'a> { /// The coupon or promotion code to apply to this subscription update. /// Currently, only up to one may be specified. #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: - Option<&'a [CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirmDiscounts<'a>]>, + pub discounts: Option<&'a [CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirmDiscounts<'a>]>, /// The [subscription item](https://stripe.com/docs/api/subscription_items) to be updated through this flow. /// Currently, only up to one may be specified and subscriptions with multiple items are not updatable. pub items: &'a [CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirmItems<'a>], @@ -274,10 +254,7 @@ pub struct CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirm<'a> { pub subscription: &'a str, } impl<'a> CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirm<'a> { - pub fn new( - items: &'a [CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirmItems<'a>], - subscription: &'a str, - ) -> Self { + pub fn new(items: &'a [CreateBillingPortalSessionFlowDataSubscriptionUpdateConfirmItems<'a>], subscription: &'a str) -> Self { Self { discounts: None, items, subscription } } } @@ -370,10 +347,7 @@ impl serde::Serialize for CreateBillingPortalSessionFlowDataType { } impl<'a> CreateBillingPortalSession<'a> { /// Creates a session of the customer portal. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_billing::BillingPortalSession> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_billing::BillingPortalSession> { client.send_form("/billing_portal/sessions", self, http_types::Method::Post) } } diff --git a/generated/stripe_billing/src/billing_portal_session/types.rs b/generated/stripe_billing/src/billing_portal_session/types.rs index 04d6bd964..bf9463cd3 100644 --- a/generated/stripe_billing/src/billing_portal_session/types.rs +++ b/generated/stripe_billing/src/billing_portal_session/types.rs @@ -12,7 +12,9 @@ /// and billing details. /// /// Learn more in the [integration guide](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal). -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BillingPortalSession { /// The configuration used by this session, describing the features available. pub configuration: stripe_types::Expandable<stripe_billing::BillingPortalConfiguration>, @@ -40,6 +42,139 @@ pub struct BillingPortalSession { /// The short-lived URL of the session that gives customers access to the customer portal. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct BillingPortalSessionBuilder { + configuration: Option<stripe_types::Expandable<stripe_billing::BillingPortalConfiguration>>, + created: Option<stripe_types::Timestamp>, + customer: Option<String>, + flow: Option<Option<stripe_billing::PortalFlowsFlow>>, + id: Option<stripe_billing::BillingPortalSessionId>, + livemode: Option<bool>, + locale: Option<Option<stripe_billing::BillingPortalSessionLocale>>, + on_behalf_of: Option<Option<String>>, + return_url: Option<Option<String>>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BillingPortalSession { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BillingPortalSession>, + builder: BillingPortalSessionBuilder, + } + + impl Visitor for Place<BillingPortalSession> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BillingPortalSessionBuilder::deser_default() })) + } + } + + impl MapBuilder for BillingPortalSessionBuilder { + type Out = BillingPortalSession; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "configuration" => Deserialize::begin(&mut self.configuration), + "created" => Deserialize::begin(&mut self.created), + "customer" => Deserialize::begin(&mut self.customer), + "flow" => Deserialize::begin(&mut self.flow), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "locale" => Deserialize::begin(&mut self.locale), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "return_url" => Deserialize::begin(&mut self.return_url), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + configuration: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + flow: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + locale: Deserialize::default(), + on_behalf_of: Deserialize::default(), + return_url: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let configuration = self.configuration.take()?; + let created = self.created.take()?; + let customer = self.customer.take()?; + let flow = self.flow.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let locale = self.locale.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let return_url = self.return_url.take()?; + let url = self.url.take()?; + + Some(Self::Out { configuration, created, customer, flow, id, livemode, locale, on_behalf_of, return_url, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BillingPortalSession { + type Builder = BillingPortalSessionBuilder; + } + + impl FromValueOpt for BillingPortalSession { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BillingPortalSessionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "configuration" => b.configuration = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "flow" => b.flow = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "locale" => b.locale = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for BillingPortalSession { type Id = stripe_billing::BillingPortalSessionId; fn id(&self) -> &Self::Id { @@ -235,6 +370,24 @@ impl<'de> serde::Deserialize<'de> for BillingPortalSessionLocale { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(BillingPortalSessionLocale::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for BillingPortalSessionLocale { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<BillingPortalSessionLocale> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BillingPortalSessionLocale::from_str(s).unwrap_or(BillingPortalSessionLocale::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(BillingPortalSessionLocale); diff --git a/generated/stripe_billing/src/credit_note/requests.rs b/generated/stripe_billing/src/credit_note/requests.rs index 7fa35022d..be2d01dfb 100644 --- a/generated/stripe_billing/src/credit_note/requests.rs +++ b/generated/stripe_billing/src/credit_note/requests.rs @@ -1,69 +1,5 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListCreditNote<'a> { - /// Only return credit notes for the customer specified by this customer ID. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Only return credit notes for the invoice specified by this invoice ID. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice: Option<&'a str>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListCreditNote<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListCreditNote<'a> { - /// Returns a list of credit notes. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::CreditNote>> { - client.get_query("/credit_notes", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CreditNote>> { - stripe::ListPaginator::from_list_params("/credit_notes", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveCreditNote<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveCreditNote<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveCreditNote<'a> { - /// Retrieves the credit note object with the given identifier. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::CreditNoteId, - ) -> stripe::Response<stripe_shared::CreditNote> { - client.get_query(&format!("/credit_notes/{id}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct PreviewCreditNote<'a> { +pub struct CreateCreditNote<'a> { /// The integer amount in cents (or local equivalent) representing the total amount of the credit note. #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, @@ -82,7 +18,7 @@ pub struct PreviewCreditNote<'a> { pub invoice: &'a str, /// Line items that make up the credit note. #[serde(skip_serializing_if = "Option::is_none")] - pub lines: Option<&'a [PreviewCreditNoteLines<'a>]>, + pub lines: Option<&'a [CreateCreditNoteLines<'a>]>, /// The credit note's memo appears on the credit note PDF. #[serde(skip_serializing_if = "Option::is_none")] pub memo: Option<&'a str>, @@ -109,7 +45,7 @@ pub struct PreviewCreditNote<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub shipping_cost: Option<CreditNoteShippingCost<'a>>, } -impl<'a> PreviewCreditNote<'a> { +impl<'a> CreateCreditNote<'a> { pub fn new(invoice: &'a str) -> Self { Self { amount: None, @@ -130,7 +66,7 @@ impl<'a> PreviewCreditNote<'a> { } /// Line items that make up the credit note. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct PreviewCreditNoteLines<'a> { +pub struct CreateCreditNoteLines<'a> { /// The line item amount to credit. Only valid when `type` is `invoice_line_item`. #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, @@ -151,8 +87,8 @@ pub struct PreviewCreditNoteLines<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option<&'a [&'a str]>, /// Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` - #[serde(rename = "type")] - pub type_: PreviewCreditNoteLinesType, + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: CreateCreditNoteLinesType, /// The integer unit amount in cents (or local equivalent) of the credit note line item. /// This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. /// Only valid when `type` is `custom_line_item`. @@ -163,30 +99,20 @@ pub struct PreviewCreditNoteLines<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> PreviewCreditNoteLines<'a> { - pub fn new(type_: PreviewCreditNoteLinesType) -> Self { - Self { - amount: None, - description: None, - invoice_line_item: None, - quantity: None, - tax_amounts: None, - tax_rates: None, - type_, - unit_amount: None, - unit_amount_decimal: None, - } +impl<'a> CreateCreditNoteLines<'a> { + pub fn new(type_: CreateCreditNoteLinesType) -> Self { + Self { amount: None, description: None, invoice_line_item: None, quantity: None, tax_amounts: None, tax_rates: None, type_, unit_amount: None, unit_amount_decimal: None } } } /// Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` #[derive(Copy, Clone, Eq, PartialEq)] -pub enum PreviewCreditNoteLinesType { +pub enum CreateCreditNoteLinesType { CustomLineItem, InvoiceLineItem, } -impl PreviewCreditNoteLinesType { +impl CreateCreditNoteLinesType { pub fn as_str(self) -> &'static str { - use PreviewCreditNoteLinesType::*; + use CreateCreditNoteLinesType::*; match self { CustomLineItem => "custom_line_item", InvoiceLineItem => "invoice_line_item", @@ -194,10 +120,10 @@ impl PreviewCreditNoteLinesType { } } -impl std::str::FromStr for PreviewCreditNoteLinesType { +impl std::str::FromStr for CreateCreditNoteLinesType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use PreviewCreditNoteLinesType::*; + use CreateCreditNoteLinesType::*; match s { "custom_line_item" => Ok(CustomLineItem), "invoice_line_item" => Ok(InvoiceLineItem), @@ -205,18 +131,18 @@ impl std::str::FromStr for PreviewCreditNoteLinesType { } } } -impl std::fmt::Display for PreviewCreditNoteLinesType { +impl std::fmt::Display for CreateCreditNoteLinesType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for PreviewCreditNoteLinesType { +impl std::fmt::Debug for CreateCreditNoteLinesType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for PreviewCreditNoteLinesType { +impl serde::Serialize for CreateCreditNoteLinesType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -224,14 +150,31 @@ impl serde::Serialize for PreviewCreditNoteLinesType { serializer.serialize_str(self.as_str()) } } -impl<'a> PreviewCreditNote<'a> { - /// Get a preview of a credit note without creating it. +impl<'a> CreateCreditNote<'a> { + /// Issue a credit note to adjust the amount of a finalized invoice. + /// For a `status=open` invoice, a credit note reduces. + /// its `amount_due`. + /// For a `status=paid` invoice, a credit note does not affect its `amount_due`. + /// Instead, it can result. + /// in any combination of the following: + /// + /// <ul> + /// <li>Refund: create a new refund (using `refund_amount`) or link an existing refund (using `refund`).</li>. + /// <li>Customer balance credit: credit the customer’s balance (using `credit_amount`) which will be automatically applied to their next invoice when it’s finalized.</li>. + /// <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using `out_of_band_amount`).</li>. + /// </ul> + /// + /// For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. + /// + /// You may issue multiple credit notes for an invoice. + /// Each credit note will increment the invoice’s `pre_payment_credit_notes_amount`. + /// or `post_payment_credit_notes_amount` depending on its `status` at the time of credit note creation. pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::CreditNote> { - client.get_query("/credit_notes/preview", self) + client.send_form("/credit_notes", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct PreviewLinesCreditNote<'a> { +pub struct PreviewCreditNote<'a> { /// The integer amount in cents (or local equivalent) representing the total amount of the credit note. #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, @@ -243,23 +186,14 @@ pub struct PreviewLinesCreditNote<'a> { /// When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF. #[serde(skip_serializing_if = "Option::is_none")] pub effective_at: Option<stripe_types::Timestamp>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, /// ID of the invoice. pub invoice: &'a str, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, /// Line items that make up the credit note. #[serde(skip_serializing_if = "Option::is_none")] - pub lines: Option<&'a [PreviewLinesCreditNoteLines<'a>]>, + pub lines: Option<&'a [PreviewCreditNoteLines<'a>]>, /// The credit note's memo appears on the credit note PDF. #[serde(skip_serializing_if = "Option::is_none")] pub memo: Option<&'a str>, @@ -285,22 +219,15 @@ pub struct PreviewLinesCreditNote<'a> { /// When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. #[serde(skip_serializing_if = "Option::is_none")] pub shipping_cost: Option<CreditNoteShippingCost<'a>>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, } -impl<'a> PreviewLinesCreditNote<'a> { +impl<'a> PreviewCreditNote<'a> { pub fn new(invoice: &'a str) -> Self { Self { amount: None, credit_amount: None, effective_at: None, - ending_before: None, expand: None, invoice, - limit: None, lines: None, memo: None, metadata: None, @@ -309,13 +236,12 @@ impl<'a> PreviewLinesCreditNote<'a> { refund: None, refund_amount: None, shipping_cost: None, - starting_after: None, } } } /// Line items that make up the credit note. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct PreviewLinesCreditNoteLines<'a> { +pub struct PreviewCreditNoteLines<'a> { /// The line item amount to credit. Only valid when `type` is `invoice_line_item`. #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, @@ -336,8 +262,8 @@ pub struct PreviewLinesCreditNoteLines<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option<&'a [&'a str]>, /// Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` - #[serde(rename = "type")] - pub type_: PreviewLinesCreditNoteLinesType, + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: PreviewCreditNoteLinesType, /// The integer unit amount in cents (or local equivalent) of the credit note line item. /// This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. /// Only valid when `type` is `custom_line_item`. @@ -348,30 +274,20 @@ pub struct PreviewLinesCreditNoteLines<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> PreviewLinesCreditNoteLines<'a> { - pub fn new(type_: PreviewLinesCreditNoteLinesType) -> Self { - Self { - amount: None, - description: None, - invoice_line_item: None, - quantity: None, - tax_amounts: None, - tax_rates: None, - type_, - unit_amount: None, - unit_amount_decimal: None, - } +impl<'a> PreviewCreditNoteLines<'a> { + pub fn new(type_: PreviewCreditNoteLinesType) -> Self { + Self { amount: None, description: None, invoice_line_item: None, quantity: None, tax_amounts: None, tax_rates: None, type_, unit_amount: None, unit_amount_decimal: None } } } /// Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` #[derive(Copy, Clone, Eq, PartialEq)] -pub enum PreviewLinesCreditNoteLinesType { +pub enum PreviewCreditNoteLinesType { CustomLineItem, InvoiceLineItem, } -impl PreviewLinesCreditNoteLinesType { +impl PreviewCreditNoteLinesType { pub fn as_str(self) -> &'static str { - use PreviewLinesCreditNoteLinesType::*; + use PreviewCreditNoteLinesType::*; match self { CustomLineItem => "custom_line_item", InvoiceLineItem => "invoice_line_item", @@ -379,10 +295,10 @@ impl PreviewLinesCreditNoteLinesType { } } -impl std::str::FromStr for PreviewLinesCreditNoteLinesType { +impl std::str::FromStr for PreviewCreditNoteLinesType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use PreviewLinesCreditNoteLinesType::*; + use PreviewCreditNoteLinesType::*; match s { "custom_line_item" => Ok(CustomLineItem), "invoice_line_item" => Ok(InvoiceLineItem), @@ -390,18 +306,18 @@ impl std::str::FromStr for PreviewLinesCreditNoteLinesType { } } } -impl std::fmt::Display for PreviewLinesCreditNoteLinesType { +impl std::fmt::Display for PreviewCreditNoteLinesType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for PreviewLinesCreditNoteLinesType { +impl std::fmt::Debug for PreviewCreditNoteLinesType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for PreviewLinesCreditNoteLinesType { +impl serde::Serialize for PreviewCreditNoteLinesType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -409,23 +325,115 @@ impl serde::Serialize for PreviewLinesCreditNoteLinesType { serializer.serialize_str(self.as_str()) } } -impl<'a> PreviewLinesCreditNote<'a> { - /// When retrieving a credit note preview, you’ll get a **lines** property containing the first handful of those items. - /// This URL you can retrieve the full (paginated) list of line items. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::CreditNoteLineItem>> { - client.get_query("/credit_notes/preview/lines", self) +impl<'a> PreviewCreditNote<'a> { + /// Get a preview of a credit note without creating it. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::CreditNote> { + client.get_query("/credit_notes/preview", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CreditNoteLineItem>> { - stripe::ListPaginator::from_list_params("/credit_notes/preview/lines", self) +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveCreditNote<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveCreditNote<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveCreditNote<'a> { + /// Retrieves the credit note object with the given identifier. + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::CreditNoteId) -> stripe::Response<stripe_shared::CreditNote> { + client.get_query(&format!("/credit_notes/{id}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListCreditNote<'a> { + /// Only return credit notes for the customer specified by this customer ID. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Only return credit notes for the invoice specified by this invoice ID. + #[serde(skip_serializing_if = "Option::is_none")] + pub invoice: Option<&'a str>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListCreditNote<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListCreditNote<'a> { + /// Returns a list of credit notes. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::CreditNote>> { + client.get_query("/credit_notes", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CreditNote>> { + stripe::ListPaginator::from_list_params("/credit_notes", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateCreditNote<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Credit note memo. + #[serde(skip_serializing_if = "Option::is_none")] + pub memo: Option<&'a str>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, +} +impl<'a> UpdateCreditNote<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> UpdateCreditNote<'a> { + /// Updates an existing credit note. + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::CreditNoteId) -> stripe::Response<stripe_shared::CreditNote> { + client.send_form(&format!("/credit_notes/{id}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct VoidCreditNoteCreditNote<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> VoidCreditNoteCreditNote<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> VoidCreditNoteCreditNote<'a> { + /// Marks a credit note as void. + /// Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::CreditNoteId) -> stripe::Response<stripe_shared::CreditNote> { + client.send_form(&format!("/credit_notes/{id}/void"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCreditNote<'a> { +pub struct PreviewLinesCreditNote<'a> { /// The integer amount in cents (or local equivalent) representing the total amount of the credit note. #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, @@ -437,14 +445,23 @@ pub struct CreateCreditNote<'a> { /// When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF. #[serde(skip_serializing_if = "Option::is_none")] pub effective_at: Option<stripe_types::Timestamp>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, /// ID of the invoice. pub invoice: &'a str, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, /// Line items that make up the credit note. #[serde(skip_serializing_if = "Option::is_none")] - pub lines: Option<&'a [CreateCreditNoteLines<'a>]>, + pub lines: Option<&'a [PreviewLinesCreditNoteLines<'a>]>, /// The credit note's memo appears on the credit note PDF. #[serde(skip_serializing_if = "Option::is_none")] pub memo: Option<&'a str>, @@ -470,15 +487,22 @@ pub struct CreateCreditNote<'a> { /// When shipping_cost contains the shipping_rate from the invoice, the shipping_cost is included in the credit note. #[serde(skip_serializing_if = "Option::is_none")] pub shipping_cost: Option<CreditNoteShippingCost<'a>>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, } -impl<'a> CreateCreditNote<'a> { +impl<'a> PreviewLinesCreditNote<'a> { pub fn new(invoice: &'a str) -> Self { Self { amount: None, credit_amount: None, effective_at: None, + ending_before: None, expand: None, invoice, + limit: None, lines: None, memo: None, metadata: None, @@ -487,12 +511,13 @@ impl<'a> CreateCreditNote<'a> { refund: None, refund_amount: None, shipping_cost: None, + starting_after: None, } } } /// Line items that make up the credit note. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCreditNoteLines<'a> { +pub struct PreviewLinesCreditNoteLines<'a> { /// The line item amount to credit. Only valid when `type` is `invoice_line_item`. #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, @@ -513,8 +538,8 @@ pub struct CreateCreditNoteLines<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option<&'a [&'a str]>, /// Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` - #[serde(rename = "type")] - pub type_: CreateCreditNoteLinesType, + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: PreviewLinesCreditNoteLinesType, /// The integer unit amount in cents (or local equivalent) of the credit note line item. /// This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. /// Only valid when `type` is `custom_line_item`. @@ -525,30 +550,20 @@ pub struct CreateCreditNoteLines<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> CreateCreditNoteLines<'a> { - pub fn new(type_: CreateCreditNoteLinesType) -> Self { - Self { - amount: None, - description: None, - invoice_line_item: None, - quantity: None, - tax_amounts: None, - tax_rates: None, - type_, - unit_amount: None, - unit_amount_decimal: None, - } +impl<'a> PreviewLinesCreditNoteLines<'a> { + pub fn new(type_: PreviewLinesCreditNoteLinesType) -> Self { + Self { amount: None, description: None, invoice_line_item: None, quantity: None, tax_amounts: None, tax_rates: None, type_, unit_amount: None, unit_amount_decimal: None } } } /// Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateCreditNoteLinesType { +pub enum PreviewLinesCreditNoteLinesType { CustomLineItem, InvoiceLineItem, } -impl CreateCreditNoteLinesType { +impl PreviewLinesCreditNoteLinesType { pub fn as_str(self) -> &'static str { - use CreateCreditNoteLinesType::*; + use PreviewLinesCreditNoteLinesType::*; match self { CustomLineItem => "custom_line_item", InvoiceLineItem => "invoice_line_item", @@ -556,10 +571,10 @@ impl CreateCreditNoteLinesType { } } -impl std::str::FromStr for CreateCreditNoteLinesType { +impl std::str::FromStr for PreviewLinesCreditNoteLinesType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateCreditNoteLinesType::*; + use PreviewLinesCreditNoteLinesType::*; match s { "custom_line_item" => Ok(CustomLineItem), "invoice_line_item" => Ok(InvoiceLineItem), @@ -567,18 +582,18 @@ impl std::str::FromStr for CreateCreditNoteLinesType { } } } -impl std::fmt::Display for CreateCreditNoteLinesType { +impl std::fmt::Display for PreviewLinesCreditNoteLinesType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateCreditNoteLinesType { +impl std::fmt::Debug for PreviewLinesCreditNoteLinesType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateCreditNoteLinesType { +impl serde::Serialize for PreviewLinesCreditNoteLinesType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -586,79 +601,14 @@ impl serde::Serialize for CreateCreditNoteLinesType { serializer.serialize_str(self.as_str()) } } -impl<'a> CreateCreditNote<'a> { - /// Issue a credit note to adjust the amount of a finalized invoice. - /// For a `status=open` invoice, a credit note reduces. - /// its `amount_due`. - /// For a `status=paid` invoice, a credit note does not affect its `amount_due`. - /// Instead, it can result. - /// in any combination of the following: - /// - /// <ul> - /// <li>Refund: create a new refund (using `refund_amount`) or link an existing refund (using `refund`).</li>. - /// <li>Customer balance credit: credit the customer’s balance (using `credit_amount`) which will be automatically applied to their next invoice when it’s finalized.</li>. - /// <li>Outside of Stripe credit: record the amount that is or will be credited outside of Stripe (using `out_of_band_amount`).</li>. - /// </ul> - /// - /// For post-payment credit notes the sum of the refund, credit and outside of Stripe amounts must equal the credit note total. - /// - /// You may issue multiple credit notes for an invoice. - /// Each credit note will increment the invoice’s `pre_payment_credit_notes_amount`. - /// or `post_payment_credit_notes_amount` depending on its `status` at the time of credit note creation. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::CreditNote> { - client.send_form("/credit_notes", self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCreditNote<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Credit note memo. - #[serde(skip_serializing_if = "Option::is_none")] - pub memo: Option<&'a str>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, -} -impl<'a> UpdateCreditNote<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> UpdateCreditNote<'a> { - /// Updates an existing credit note. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::CreditNoteId, - ) -> stripe::Response<stripe_shared::CreditNote> { - client.send_form(&format!("/credit_notes/{id}"), self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct VoidCreditNoteCreditNote<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> VoidCreditNoteCreditNote<'a> { - pub fn new() -> Self { - Self::default() +impl<'a> PreviewLinesCreditNote<'a> { + /// When retrieving a credit note preview, you’ll get a **lines** property containing the first handful of those items. + /// This URL you can retrieve the full (paginated) list of line items. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::CreditNoteLineItem>> { + client.get_query("/credit_notes/preview/lines", self) } -} -impl<'a> VoidCreditNoteCreditNote<'a> { - /// Marks a credit note as void. - /// Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::CreditNoteId, - ) -> stripe::Response<stripe_shared::CreditNote> { - client.send_form(&format!("/credit_notes/{id}/void"), self, http_types::Method::Post) + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CreditNoteLineItem>> { + stripe::ListPaginator::from_list_params("/credit_notes/preview/lines", self) } } #[derive(Copy, Clone, Debug, serde::Serialize)] diff --git a/generated/stripe_billing/src/credit_note_line_item/requests.rs b/generated/stripe_billing/src/credit_note_line_item/requests.rs index bc841a139..d32725953 100644 --- a/generated/stripe_billing/src/credit_note_line_item/requests.rs +++ b/generated/stripe_billing/src/credit_note_line_item/requests.rs @@ -26,17 +26,10 @@ impl<'a> ListCreditNoteCreditNoteLineItem<'a> { impl<'a> ListCreditNoteCreditNoteLineItem<'a> { /// When retrieving a credit note, you’ll get a **lines** property containing the the first handful of those items. /// There is also a URL where you can retrieve the full (paginated) list of line items. - pub fn send( - &self, - client: &stripe::Client, - credit_note: &stripe_shared::CreditNoteId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CreditNoteLineItem>> { + pub fn send(&self, client: &stripe::Client, credit_note: &stripe_shared::CreditNoteId) -> stripe::Response<stripe_types::List<stripe_shared::CreditNoteLineItem>> { client.get_query(&format!("/credit_notes/{credit_note}/lines"), self) } - pub fn paginate( - self, - credit_note: &stripe_shared::CreditNoteId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CreditNoteLineItem>> { + pub fn paginate(self, credit_note: &stripe_shared::CreditNoteId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CreditNoteLineItem>> { stripe::ListPaginator::from_list_params(&format!("/credit_notes/{credit_note}/lines"), self) } } diff --git a/generated/stripe_billing/src/invoice/requests.rs b/generated/stripe_billing/src/invoice/requests.rs index ae4506f97..8f89de99a 100644 --- a/generated/stripe_billing/src/invoice/requests.rs +++ b/generated/stripe_billing/src/invoice/requests.rs @@ -1,98 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteInvoice {} -impl DeleteInvoice { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteInvoice { - /// Permanently deletes a one-off invoice draft. - /// This cannot be undone. - /// Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::DeletedInvoice> { - client.send_form(&format!("/invoices/{invoice}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListInvoice<'a> { - /// The collection method of the invoice to retrieve. Either `charge_automatically` or `send_invoice`. - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: Option<stripe_shared::InvoiceCollectionMethod>, - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// Only return invoices for the customer specified by this customer ID. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - #[serde(skip_serializing_if = "Option::is_none")] - pub due_date: Option<stripe_types::RangeQueryTs>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// The status of the invoice, one of `draft`, `open`, `paid`, `uncollectible`, or `void`. - /// [Learn more](https://stripe.com/docs/billing/invoices/workflow#workflow-overview). - #[serde(skip_serializing_if = "Option::is_none")] - pub status: Option<stripe_shared::InvoiceStatus>, - /// Only return invoices for the subscription specified by this subscription ID. - #[serde(skip_serializing_if = "Option::is_none")] - pub subscription: Option<&'a str>, -} -impl<'a> ListInvoice<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListInvoice<'a> { - /// You can list all invoices, or list the invoices for a specific customer. - /// The invoices are returned sorted by creation date, with the most recently created invoices appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Invoice>> { - client.get_query("/invoices", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Invoice>> { - stripe::ListPaginator::from_list_params("/invoices", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveInvoice<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveInvoice<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveInvoice<'a> { - /// Retrieves the invoice with the given ID. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::Invoice> { - client.get_query(&format!("/invoices/{invoice}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct SearchInvoice<'a> { /// Specifies which fields in the response should be expanded. @@ -123,15 +28,10 @@ impl<'a> SearchInvoice<'a> { /// conditions, data is searchable in less than a minute. /// Occasionally, propagation of new or updated data can be up. /// to an hour behind during outages. Search functionality is not available to merchants in India. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::SearchList<stripe_shared::Invoice>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::SearchList<stripe_shared::Invoice>> { client.get_query("/invoices/search", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Invoice>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Invoice>> { stripe::ListPaginator::from_search_params("/invoices/search", self) } } @@ -139,7 +39,7 @@ impl<'a> SearchInvoice<'a> { pub struct UpcomingInvoice<'a> { /// Settings for automatic tax lookup for this invoice preview. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpcomingInvoiceAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxParam>, /// The code of the coupon to apply. /// If `subscription` or `subscription_items` is provided, the invoice returned will preview updating or creating a subscription with that coupon. /// Otherwise, it will preview applying that coupon to the customer for the next upcoming invoice from among the customer's subscriptions. @@ -171,15 +71,6 @@ pub struct UpcomingInvoice<'a> { /// List of invoice items to add or update in the upcoming invoice preview. #[serde(skip_serializing_if = "Option::is_none")] pub invoice_items: Option<&'a [UpcomingInvoiceInvoiceItems<'a>]>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpcomingInvoiceIssuer<'a>>, - /// The account (if any) for which the funds of the invoice payment are intended. - /// If set, the invoice will be presented with the branding and support information of the specified account. - /// See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details. - #[serde(skip_serializing_if = "Option::is_none")] - pub on_behalf_of: Option<&'a str>, /// The identifier of the schedule whose upcoming invoice you'd like to retrieve. /// Cannot be used with subscription or subscription fields. #[serde(skip_serializing_if = "Option::is_none")] @@ -194,9 +85,8 @@ pub struct UpcomingInvoice<'a> { /// For existing subscriptions, the value can only be set to `now` or `unchanged`. #[serde(skip_serializing_if = "Option::is_none")] pub subscription_billing_cycle_anchor: Option<UpcomingInvoiceSubscriptionBillingCycleAnchor>, - /// A timestamp at which the subscription should cancel. - /// If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. - /// If set during a future period, this will always cause a proration for that period. + /// Timestamp indicating when the subscription should be scheduled to cancel. + /// Will prorate if within the current period and prorations have been enabled using `proration_behavior`. #[serde(skip_serializing_if = "Option::is_none")] pub subscription_cancel_at: Option<stripe_types::Timestamp>, /// Boolean indicating whether this subscription should cancel at the end of the current period. @@ -225,7 +115,7 @@ pub struct UpcomingInvoice<'a> { /// For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed. #[serde(skip_serializing_if = "Option::is_none")] pub subscription_resume_at: Option<UpcomingInvoiceSubscriptionResumeAt>, - /// Date a subscription is intended to start (can be future or past). + /// Date a subscription is intended to start (can be future or past) #[serde(skip_serializing_if = "Option::is_none")] pub subscription_start_date: Option<stripe_types::Timestamp>, /// If provided, the invoice returned will preview updating or creating a subscription with that trial end. @@ -244,86 +134,6 @@ impl<'a> UpcomingInvoice<'a> { Self::default() } } -/// Settings for automatic tax lookup for this invoice preview. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingInvoiceAutomaticTax<'a> { - /// Whether Stripe automatically computes tax on this invoice. - /// Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpcomingInvoiceAutomaticTaxLiability<'a>>, -} -impl<'a> UpcomingInvoiceAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingInvoiceAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpcomingInvoiceAutomaticTaxLiabilityType, -} -impl<'a> UpcomingInvoiceAutomaticTaxLiability<'a> { - pub fn new(type_: UpcomingInvoiceAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingInvoiceAutomaticTaxLiabilityType { - Account, - Self_, -} -impl UpcomingInvoiceAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use UpcomingInvoiceAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpcomingInvoiceAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingInvoiceAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingInvoiceAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingInvoiceAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingInvoiceAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Details about the customer you want to invoice or overrides for an existing customer. /// If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -402,7 +212,7 @@ impl serde::Serialize for UpcomingInvoiceCustomerDetailsTaxExempt { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpcomingInvoiceCustomerDetailsTaxIds<'a> { /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: UpcomingInvoiceCustomerDetailsTaxIdsType, /// Value of the tax ID. pub value: &'a str, @@ -859,68 +669,6 @@ impl serde::Serialize for UpcomingInvoiceInvoiceItemsTaxBehavior { serializer.serialize_str(self.as_str()) } } -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingInvoiceIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpcomingInvoiceIssuerType, -} -impl<'a> UpcomingInvoiceIssuer<'a> { - pub fn new(type_: UpcomingInvoiceIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingInvoiceIssuerType { - Account, - Self_, -} -impl UpcomingInvoiceIssuerType { - pub fn as_str(self) -> &'static str { - use UpcomingInvoiceIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpcomingInvoiceIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingInvoiceIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingInvoiceIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingInvoiceIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingInvoiceIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). /// This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. /// For existing subscriptions, the value can only be set to `now` or `unchanged`. @@ -1003,19 +751,8 @@ pub struct UpcomingInvoiceSubscriptionItemsPriceData<'a> { pub unit_amount_decimal: Option<&'a str>, } impl<'a> UpcomingInvoiceSubscriptionItemsPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: UpcomingInvoiceSubscriptionItemsPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: UpcomingInvoiceSubscriptionItemsPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -1025,7 +762,7 @@ pub struct UpcomingInvoiceSubscriptionItemsPriceDataRecurring { pub interval: UpcomingInvoiceSubscriptionItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -1257,202 +994,232 @@ impl<'a> UpcomingInvoice<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpcomingLinesInvoice<'a> { - /// Settings for automatic tax lookup for this invoice preview. +pub struct UpdateInvoice<'a> { + /// The account tax IDs associated with the invoice. Only editable when the invoice is a draft. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpcomingLinesInvoiceAutomaticTax<'a>>, - /// The code of the coupon to apply. - /// If `subscription` or `subscription_items` is provided, the invoice returned will preview updating or creating a subscription with that coupon. - /// Otherwise, it will preview applying that coupon to the customer for the next upcoming invoice from among the customer's subscriptions. - /// The invoice can be previewed without a coupon by passing this value as an empty string. + pub account_tax_ids: Option<&'a [&'a str]>, + /// A fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner's Stripe account. + /// The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. + /// For more information, see the application fees [documentation](https://stripe.com/docs/billing/invoices/connect#collecting-fees). #[serde(skip_serializing_if = "Option::is_none")] - pub coupon: Option<&'a str>, - /// The currency to preview this invoice in. Defaults to that of `customer` if not specified. + pub application_fee_amount: Option<i64>, + /// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. #[serde(skip_serializing_if = "Option::is_none")] - pub currency: Option<stripe_types::Currency>, - /// The identifier of the customer whose upcoming invoice you'd like to retrieve. - /// If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set. + pub auto_advance: Option<bool>, + /// Settings for automatic tax lookup for this invoice. #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// Details about the customer you want to invoice or overrides for an existing customer. - /// If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set. + pub automatic_tax: Option<AutomaticTaxParam>, + /// Either `charge_automatically` or `send_invoice`. + /// This field can be updated only on `draft` invoices. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_details: Option<UpcomingLinesInvoiceCustomerDetails<'a>>, - /// The coupons to redeem into discounts for the invoice preview. - /// If not specified, inherits the discount from the customer or subscription. - /// This only works for coupons directly applied to the invoice. - /// To apply a coupon to a subscription, you must use the `coupon` parameter instead. - /// Pass an empty string to avoid inheriting any discounts. - /// To preview the upcoming invoice for a subscription that hasn't been created, use `coupon` instead. + pub collection_method: Option<stripe_shared::InvoiceCollectionMethod>, + /// A list of up to 4 custom fields to be displayed on the invoice. + /// If a value for `custom_fields` is specified, the list specified will replace the existing custom field list on this invoice. + /// Pass an empty string to remove previously-defined fields. #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: Option<&'a [DiscountsDataParam<'a>]>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + pub custom_fields: Option<&'a [CustomFieldParams<'a>]>, + /// The number of days from which the invoice is created until it is due. + /// Only valid for invoices where `collection_method=send_invoice`. + /// This field can only be updated on `draft` invoices. #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. + pub days_until_due: Option<u32>, + /// ID of the default payment method for the invoice. + /// It must belong to the customer associated with the invoice. + /// If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings. #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// List of invoice items to add or update in the upcoming invoice preview. + pub default_payment_method: Option<&'a str>, + /// ID of the default payment source for the invoice. + /// It must belong to the customer associated with the invoice and be in a chargeable state. + /// If not set, defaults to the subscription's default source, if any, or to the customer's default source. #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_items: Option<&'a [UpcomingLinesInvoiceInvoiceItems<'a>]>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. + pub default_source: Option<&'a str>, + /// The tax rates that will apply to any line item that does not have `tax_rates` set. + /// Pass an empty string to remove previously-defined tax rates. #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpcomingLinesInvoiceIssuer<'a>>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. + pub default_tax_rates: Option<&'a [&'a str]>, + /// An arbitrary string attached to the object. + /// Often useful for displaying to users. + /// Referenced as 'memo' in the Dashboard. #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// The account (if any) for which the funds of the invoice payment are intended. - /// If set, the invoice will be presented with the branding and support information of the specified account. - /// See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details. + pub description: Option<&'a str>, + /// The discounts that will apply to the invoice. + /// Pass an empty string to remove previously-defined discounts. #[serde(skip_serializing_if = "Option::is_none")] - pub on_behalf_of: Option<&'a str>, - /// The identifier of the schedule whose upcoming invoice you'd like to retrieve. - /// Cannot be used with subscription or subscription fields. + pub discounts: Option<&'a [DiscountsDataParam<'a>]>, + /// The date on which payment for this invoice is due. + /// Only valid for invoices where `collection_method=send_invoice`. + /// This field can only be updated on `draft` invoices. #[serde(skip_serializing_if = "Option::is_none")] - pub schedule: Option<&'a str>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + pub due_date: Option<stripe_types::Timestamp>, + /// The date when this invoice is in effect. + /// Same as `finalized_at` unless overwritten. + /// When defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF and receipt. #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// The identifier of the subscription for which you'd like to retrieve the upcoming invoice. - /// If not provided, but a `subscription_items` is provided, you will preview creating a subscription with those items. - /// If neither `subscription` nor `subscription_items` is provided, you will retrieve the next upcoming invoice from among the customer's subscriptions. + pub effective_at: Option<stripe_types::Timestamp>, + /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription: Option<&'a str>, - /// For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). - /// This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. - /// For existing subscriptions, the value can only be set to `now` or `unchanged`. + pub expand: Option<&'a [&'a str]>, + /// Footer to be displayed on the invoice. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_billing_cycle_anchor: - Option<UpcomingLinesInvoiceSubscriptionBillingCycleAnchor>, - /// A timestamp at which the subscription should cancel. - /// If set to a date before the current period ends, this will cause a proration if prorations have been enabled using `proration_behavior`. - /// If set during a future period, this will always cause a proration for that period. + pub footer: Option<&'a str>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_cancel_at: Option<stripe_types::Timestamp>, - /// Boolean indicating whether this subscription should cancel at the end of the current period. + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// The account (if any) for which the funds of the invoice payment are intended. + /// If set, the invoice will be presented with the branding and support information of the specified account. + /// See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_cancel_at_period_end: Option<bool>, - /// This simulates the subscription being canceled or expired immediately. + pub on_behalf_of: Option<&'a str>, + /// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_cancel_now: Option<bool>, - /// If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. - /// The default tax rates will apply to any line item that does not have `tax_rates` set. + pub payment_settings: Option<UpdateInvoicePaymentSettings<'a>>, + /// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_default_tax_rates: Option<&'a [&'a str]>, - /// A list of up to 20 subscription items, each with an attached price. + pub rendering: Option<UpdateInvoiceRendering>, + /// This is a legacy field that will be removed soon. + /// For details about `rendering_options`, refer to `rendering` instead. + /// Options for invoice PDF rendering. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_items: Option<&'a [UpcomingLinesInvoiceSubscriptionItems<'a>]>, - /// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. - /// The default value is `create_prorations`. + pub rendering_options: Option<UpdateInvoiceRenderingOptions>, + /// Settings for the cost of shipping for this invoice. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_proration_behavior: Option<UpcomingLinesInvoiceSubscriptionProrationBehavior>, - /// If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. - /// The time given must be within the current subscription period and within the current phase of the schedule backing this subscription, if the schedule exists. - /// If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. - /// Also, `subscription_proration_behavior` cannot be set to 'none'. + pub shipping_cost: Option<UpdateInvoiceShippingCost<'a>>, + /// Shipping details for the invoice. + /// The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_proration_date: Option<stripe_types::Timestamp>, - /// For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed. + pub shipping_details: Option<RecipientShippingWithOptionalFieldsAddress<'a>>, + /// Extra information about a charge for the customer's credit card statement. + /// It must contain at least one letter. + /// If not specified and this invoice is part of a subscription, the default `statement_descriptor` will be set to the first subscription item's product's `statement_descriptor`. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_resume_at: Option<UpcomingLinesInvoiceSubscriptionResumeAt>, - /// Date a subscription is intended to start (can be future or past). + pub statement_descriptor: Option<&'a str>, + /// If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge. + /// This will be unset if you POST an empty value. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_start_date: Option<stripe_types::Timestamp>, - /// If provided, the invoice returned will preview updating or creating a subscription with that trial end. - /// If set, one of `subscription_items` or `subscription` is required. + pub transfer_data: Option<TransferDataSpecs<'a>>, +} +impl<'a> UpdateInvoice<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoicePaymentSettings<'a> { + /// ID of the mandate to be used for this invoice. + /// It must correspond to the payment method used to pay the invoice, including the invoice's default_payment_method or default_source, if set. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_trial_end: Option<UpcomingLinesInvoiceSubscriptionTrialEnd>, - /// Indicates if a plan's `trial_period_days` should be applied to the subscription. - /// Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. - /// Setting this flag to `true` together with `subscription_trial_end` is not allowed. - /// See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more. + pub default_mandate: Option<&'a str>, + /// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub subscription_trial_from_plan: Option<bool>, + pub payment_method_options: Option<UpdateInvoicePaymentSettingsPaymentMethodOptions<'a>>, + /// The list of payment method types (e.g. + /// card) to provide to the invoice’s PaymentIntent. + /// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method_types: Option<&'a [UpdateInvoicePaymentSettingsPaymentMethodTypes]>, } -impl<'a> UpcomingLinesInvoice<'a> { +impl<'a> UpdateInvoicePaymentSettings<'a> { pub fn new() -> Self { Self::default() } } -/// Settings for automatic tax lookup for this invoice preview. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingLinesInvoiceAutomaticTax<'a> { - /// Whether Stripe automatically computes tax on this invoice. - /// Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. +/// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptions<'a> { + /// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub acss_debit: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit>, + /// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub bancontact: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontact>, + /// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub card: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCard>, + /// If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice’s PaymentIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer_balance: Option<InvoicePaymentMethodOptionsParam<'a>>, + /// If paying by `konbini`, this sub-hash contains details about the Konbini payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpcomingLinesInvoiceAutomaticTaxLiability<'a>>, + pub konbini: Option<&'a serde_json::Value>, + /// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub us_bank_account: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, } -impl<'a> UpcomingLinesInvoiceAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } +impl<'a> UpdateInvoicePaymentSettingsPaymentMethodOptions<'a> { + pub fn new() -> Self { + Self::default() } } -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingLinesInvoiceAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. +/// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { + /// Additional fields for Mandate creation + #[serde(skip_serializing_if = "Option::is_none")] + pub mandate_options: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, + /// Verification method for the intent + #[serde(skip_serializing_if = "Option::is_none")] + pub verification_method: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, +} +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { + pub fn new() -> Self { + Self::default() + } +} +/// Additional fields for Mandate creation +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { + /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpcomingLinesInvoiceAutomaticTaxLiabilityType, + pub transaction_type: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } -impl<'a> UpcomingLinesInvoiceAutomaticTaxLiability<'a> { - pub fn new(type_: UpcomingLinesInvoiceAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { + pub fn new() -> Self { + Self::default() } } -/// Type of the account referenced in the request. +/// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceAutomaticTaxLiabilityType { - Account, - Self_, +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { + Business, + Personal, } -impl UpcomingLinesInvoiceAutomaticTaxLiabilityType { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceAutomaticTaxLiabilityType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; match self { - Account => "account", - Self_ => "self", + Business => "business", + Personal => "personal", } } } -impl std::str::FromStr for UpcomingLinesInvoiceAutomaticTaxLiabilityType { +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceAutomaticTaxLiabilityType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; match s { - "account" => Ok(Account), - "self" => Ok(Self_), + "business" => Ok(Business), + "personal" => Ok(Personal), _ => Err(()), } } } -impl std::fmt::Display for UpcomingLinesInvoiceAutomaticTaxLiabilityType { +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpcomingLinesInvoiceAutomaticTaxLiabilityType { +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpcomingLinesInvoiceAutomaticTaxLiabilityType { +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1460,73 +1227,48 @@ impl serde::Serialize for UpcomingLinesInvoiceAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } -/// Details about the customer you want to invoice or overrides for an existing customer. -/// If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpcomingLinesInvoiceCustomerDetails<'a> { - /// The customer's address. - #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option<OptionalFieldsAddress<'a>>, - /// The customer's shipping information. Appears on invoices emailed to this customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub shipping: Option<CustomerShipping<'a>>, - /// Tax details about the customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax: Option<TaxParam<'a>>, - /// The customer's tax exemption. One of `none`, `exempt`, or `reverse`. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_exempt: Option<UpcomingLinesInvoiceCustomerDetailsTaxExempt>, - /// The customer's tax IDs. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_ids: Option<&'a [UpcomingLinesInvoiceCustomerDetailsTaxIds<'a>]>, -} -impl<'a> UpcomingLinesInvoiceCustomerDetails<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The customer's tax exemption. One of `none`, `exempt`, or `reverse`. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceCustomerDetailsTaxExempt { - Exempt, - None, - Reverse, +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { + Automatic, + Instant, + Microdeposits, } -impl UpcomingLinesInvoiceCustomerDetailsTaxExempt { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceCustomerDetailsTaxExempt::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; match self { - Exempt => "exempt", - None => "none", - Reverse => "reverse", + Automatic => "automatic", + Instant => "instant", + Microdeposits => "microdeposits", } } } -impl std::str::FromStr for UpcomingLinesInvoiceCustomerDetailsTaxExempt { +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceCustomerDetailsTaxExempt::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; match s { - "exempt" => Ok(Exempt), - "none" => Ok(None), - "reverse" => Ok(Reverse), + "automatic" => Ok(Automatic), + "instant" => Ok(Instant), + "microdeposits" => Ok(Microdeposits), _ => Err(()), } } } -impl std::fmt::Display for UpcomingLinesInvoiceCustomerDetailsTaxExempt { +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpcomingLinesInvoiceCustomerDetailsTaxExempt { +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpcomingLinesInvoiceCustomerDetailsTaxExempt { +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1534,1073 +1276,165 @@ impl serde::Serialize for UpcomingLinesInvoiceCustomerDetailsTaxExempt { serializer.serialize_str(self.as_str()) } } -/// The customer's tax IDs. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingLinesInvoiceCustomerDetailsTaxIds<'a> { - /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. - #[serde(rename = "type")] - pub type_: UpcomingLinesInvoiceCustomerDetailsTaxIdsType, - /// Value of the tax ID. - pub value: &'a str, +/// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontact { + /// Preferred language of the Bancontact authorization page that the customer is redirected to. + #[serde(skip_serializing_if = "Option::is_none")] + pub preferred_language: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, } -impl<'a> UpcomingLinesInvoiceCustomerDetailsTaxIds<'a> { - pub fn new(type_: UpcomingLinesInvoiceCustomerDetailsTaxIdsType, value: &'a str) -> Self { - Self { type_, value } +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontact { + pub fn new() -> Self { + Self::default() } } -/// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. +/// Preferred language of the Bancontact authorization page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] -#[non_exhaustive] -pub enum UpcomingLinesInvoiceCustomerDetailsTaxIdsType { - AdNrt, - AeTrn, - ArCuit, - AuAbn, - AuArn, - BgUic, - BoTin, - BrCnpj, - BrCpf, - CaBn, - CaGstHst, - CaPstBc, - CaPstMb, - CaPstSk, - CaQst, - ChVat, - ClTin, - CnTin, - CoNit, - CrTin, - DoRcn, - EcRuc, - EgTin, - EsCif, - EuOssVat, - EuVat, - GbVat, - GeVat, - HkBr, - HuTin, - IdNpwp, - IlVat, - InGst, - IsVat, - JpCn, - JpRn, - JpTrn, - KePin, - KrBrn, - LiUid, - MxRfc, - MyFrp, - MyItn, - MySst, - NoVat, - NzGst, - PeRuc, - PhTin, - RoTin, - RsPib, - RuInn, - RuKpp, - SaVat, - SgGst, - SgUen, - SiTin, - SvNit, - ThVat, - TrTin, - TwVat, - UaVat, - UsEin, - UyRuc, - VeRif, - VnTin, - ZaVat, - /// An unrecognized value from Stripe. Should not be used as a request parameter. - Unknown, -} -impl UpcomingLinesInvoiceCustomerDetailsTaxIdsType { - pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceCustomerDetailsTaxIdsType::*; - match self { - AdNrt => "ad_nrt", - AeTrn => "ae_trn", - ArCuit => "ar_cuit", - AuAbn => "au_abn", - AuArn => "au_arn", - BgUic => "bg_uic", - BoTin => "bo_tin", - BrCnpj => "br_cnpj", - BrCpf => "br_cpf", - CaBn => "ca_bn", - CaGstHst => "ca_gst_hst", - CaPstBc => "ca_pst_bc", - CaPstMb => "ca_pst_mb", - CaPstSk => "ca_pst_sk", - CaQst => "ca_qst", - ChVat => "ch_vat", - ClTin => "cl_tin", - CnTin => "cn_tin", - CoNit => "co_nit", - CrTin => "cr_tin", - DoRcn => "do_rcn", - EcRuc => "ec_ruc", - EgTin => "eg_tin", - EsCif => "es_cif", - EuOssVat => "eu_oss_vat", - EuVat => "eu_vat", - GbVat => "gb_vat", - GeVat => "ge_vat", - HkBr => "hk_br", - HuTin => "hu_tin", - IdNpwp => "id_npwp", - IlVat => "il_vat", - InGst => "in_gst", - IsVat => "is_vat", - JpCn => "jp_cn", - JpRn => "jp_rn", - JpTrn => "jp_trn", - KePin => "ke_pin", - KrBrn => "kr_brn", - LiUid => "li_uid", - MxRfc => "mx_rfc", - MyFrp => "my_frp", - MyItn => "my_itn", - MySst => "my_sst", - NoVat => "no_vat", - NzGst => "nz_gst", - PeRuc => "pe_ruc", - PhTin => "ph_tin", - RoTin => "ro_tin", - RsPib => "rs_pib", - RuInn => "ru_inn", - RuKpp => "ru_kpp", - SaVat => "sa_vat", - SgGst => "sg_gst", - SgUen => "sg_uen", - SiTin => "si_tin", - SvNit => "sv_nit", - ThVat => "th_vat", - TrTin => "tr_tin", - TwVat => "tw_vat", - UaVat => "ua_vat", - UsEin => "us_ein", - UyRuc => "uy_ruc", - VeRif => "ve_rif", - VnTin => "vn_tin", - ZaVat => "za_vat", - Unknown => "unknown", - } - } -} - -impl std::str::FromStr for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceCustomerDetailsTaxIdsType::*; - match s { - "ad_nrt" => Ok(AdNrt), - "ae_trn" => Ok(AeTrn), - "ar_cuit" => Ok(ArCuit), - "au_abn" => Ok(AuAbn), - "au_arn" => Ok(AuArn), - "bg_uic" => Ok(BgUic), - "bo_tin" => Ok(BoTin), - "br_cnpj" => Ok(BrCnpj), - "br_cpf" => Ok(BrCpf), - "ca_bn" => Ok(CaBn), - "ca_gst_hst" => Ok(CaGstHst), - "ca_pst_bc" => Ok(CaPstBc), - "ca_pst_mb" => Ok(CaPstMb), - "ca_pst_sk" => Ok(CaPstSk), - "ca_qst" => Ok(CaQst), - "ch_vat" => Ok(ChVat), - "cl_tin" => Ok(ClTin), - "cn_tin" => Ok(CnTin), - "co_nit" => Ok(CoNit), - "cr_tin" => Ok(CrTin), - "do_rcn" => Ok(DoRcn), - "ec_ruc" => Ok(EcRuc), - "eg_tin" => Ok(EgTin), - "es_cif" => Ok(EsCif), - "eu_oss_vat" => Ok(EuOssVat), - "eu_vat" => Ok(EuVat), - "gb_vat" => Ok(GbVat), - "ge_vat" => Ok(GeVat), - "hk_br" => Ok(HkBr), - "hu_tin" => Ok(HuTin), - "id_npwp" => Ok(IdNpwp), - "il_vat" => Ok(IlVat), - "in_gst" => Ok(InGst), - "is_vat" => Ok(IsVat), - "jp_cn" => Ok(JpCn), - "jp_rn" => Ok(JpRn), - "jp_trn" => Ok(JpTrn), - "ke_pin" => Ok(KePin), - "kr_brn" => Ok(KrBrn), - "li_uid" => Ok(LiUid), - "mx_rfc" => Ok(MxRfc), - "my_frp" => Ok(MyFrp), - "my_itn" => Ok(MyItn), - "my_sst" => Ok(MySst), - "no_vat" => Ok(NoVat), - "nz_gst" => Ok(NzGst), - "pe_ruc" => Ok(PeRuc), - "ph_tin" => Ok(PhTin), - "ro_tin" => Ok(RoTin), - "rs_pib" => Ok(RsPib), - "ru_inn" => Ok(RuInn), - "ru_kpp" => Ok(RuKpp), - "sa_vat" => Ok(SaVat), - "sg_gst" => Ok(SgGst), - "sg_uen" => Ok(SgUen), - "si_tin" => Ok(SiTin), - "sv_nit" => Ok(SvNit), - "th_vat" => Ok(ThVat), - "tr_tin" => Ok(TrTin), - "tw_vat" => Ok(TwVat), - "ua_vat" => Ok(UaVat), - "us_ein" => Ok(UsEin), - "uy_ruc" => Ok(UyRuc), - "ve_rif" => Ok(VeRif), - "vn_tin" => Ok(VnTin), - "za_vat" => Ok(ZaVat), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// List of invoice items to add or update in the upcoming invoice preview. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpcomingLinesInvoiceInvoiceItems<'a> { - /// The integer amount in cents (or local equivalent) of previewed invoice item. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option<i64>, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - /// Only applicable to new invoice items. - #[serde(skip_serializing_if = "Option::is_none")] - pub currency: Option<stripe_types::Currency>, - /// An arbitrary string which you can attach to the invoice item. - /// The description is displayed in the invoice for easy tracking. - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option<&'a str>, - /// Explicitly controls whether discounts apply to this invoice item. - /// Defaults to true, except for negative invoice items. - #[serde(skip_serializing_if = "Option::is_none")] - pub discountable: Option<bool>, - /// The coupons to redeem into discounts for the invoice item in the preview. - #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: Option<&'a [DiscountsDataParam<'a>]>, - /// The ID of the invoice item to update in preview. - /// If not specified, a new invoice item will be added to the preview of the upcoming invoice. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoiceitem: Option<&'a str>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// The period associated with this invoice item. - /// When set to different values, the period will be rendered on the invoice. - /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. - /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. - #[serde(skip_serializing_if = "Option::is_none")] - pub period: Option<Period>, - /// The ID of the price object. - #[serde(skip_serializing_if = "Option::is_none")] - pub price: Option<&'a str>, - /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. - #[serde(skip_serializing_if = "Option::is_none")] - pub price_data: Option<UpcomingLinesInvoiceInvoiceItemsPriceData<'a>>, - /// Non-negative integer. The quantity of units for the invoice item. - #[serde(skip_serializing_if = "Option::is_none")] - pub quantity: Option<u64>, - /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. - /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. - /// One of `inclusive`, `exclusive`, or `unspecified`. - /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option<UpcomingLinesInvoiceInvoiceItemsTaxBehavior>, - /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_code: Option<&'a str>, - /// The tax rates that apply to the item. When set, any `default_tax_rates` do not apply to this item. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_rates: Option<&'a [&'a str]>, - /// The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. - /// This unit_amount will be multiplied by the quantity to get the full amount. - /// If you want to apply a credit to the customer's account, pass a negative unit_amount. - #[serde(skip_serializing_if = "Option::is_none")] - pub unit_amount: Option<i64>, - /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. - /// Only one of `unit_amount` and `unit_amount_decimal` can be set. - #[serde(skip_serializing_if = "Option::is_none")] - pub unit_amount_decimal: Option<&'a str>, -} -impl<'a> UpcomingLinesInvoiceInvoiceItems<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingLinesInvoiceInvoiceItemsPriceData<'a> { - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// The ID of the product that this price will belong to. - pub product: &'a str, - /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. - /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. - /// One of `inclusive`, `exclusive`, or `unspecified`. - /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option<UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior>, - /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. - #[serde(skip_serializing_if = "Option::is_none")] - pub unit_amount: Option<i64>, - /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. - /// Only one of `unit_amount` and `unit_amount_decimal` can be set. - #[serde(skip_serializing_if = "Option::is_none")] - pub unit_amount_decimal: Option<&'a str>, -} -impl<'a> UpcomingLinesInvoiceInvoiceItemsPriceData<'a> { - pub fn new(currency: stripe_types::Currency, product: &'a str) -> Self { - Self { currency, product, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } - } -} -/// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. -/// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. -/// One of `inclusive`, `exclusive`, or `unspecified`. -/// Once specified as either `inclusive` or `exclusive`, it cannot be changed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { - Exclusive, - Inclusive, - Unspecified, -} -impl UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { - pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior::*; - match self { - Exclusive => "exclusive", - Inclusive => "inclusive", - Unspecified => "unspecified", - } - } -} - -impl std::str::FromStr for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior::*; - match s { - "exclusive" => Ok(Exclusive), - "inclusive" => Ok(Inclusive), - "unspecified" => Ok(Unspecified), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. -/// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. -/// One of `inclusive`, `exclusive`, or `unspecified`. -/// Once specified as either `inclusive` or `exclusive`, it cannot be changed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceInvoiceItemsTaxBehavior { - Exclusive, - Inclusive, - Unspecified, -} -impl UpcomingLinesInvoiceInvoiceItemsTaxBehavior { - pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceInvoiceItemsTaxBehavior::*; - match self { - Exclusive => "exclusive", - Inclusive => "inclusive", - Unspecified => "unspecified", - } - } -} - -impl std::str::FromStr for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceInvoiceItemsTaxBehavior::*; - match s { - "exclusive" => Ok(Exclusive), - "inclusive" => Ok(Inclusive), - "unspecified" => Ok(Unspecified), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingLinesInvoiceIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpcomingLinesInvoiceIssuerType, -} -impl<'a> UpcomingLinesInvoiceIssuer<'a> { - pub fn new(type_: UpcomingLinesInvoiceIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceIssuerType { - Account, - Self_, -} -impl UpcomingLinesInvoiceIssuerType { - pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpcomingLinesInvoiceIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingLinesInvoiceIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingLinesInvoiceIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). -/// This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. -/// For existing subscriptions, the value can only be set to `now` or `unchanged`. -#[derive(Copy, Clone, Debug, serde::Serialize)] -#[serde(untagged)] -pub enum UpcomingLinesInvoiceSubscriptionBillingCycleAnchor { - Now, - Unchanged, - Timestamp(stripe_types::Timestamp), -} -/// A list of up to 20 subscription items, each with an attached price. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpcomingLinesInvoiceSubscriptionItems<'a> { - /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. - /// When updating, pass an empty string to remove previously-defined thresholds. - #[serde(skip_serializing_if = "Option::is_none")] - pub billing_thresholds: Option<ItemBillingThresholdsParam>, - /// Delete all usage for a given subscription item. - /// Allowed only when `deleted` is set to `true` and the current plan's `usage_type` is `metered`. - #[serde(skip_serializing_if = "Option::is_none")] - pub clear_usage: Option<bool>, - /// A flag that, if set to `true`, will delete the specified item. - #[serde(skip_serializing_if = "Option::is_none")] - pub deleted: Option<bool>, - /// Subscription item to update. - #[serde(skip_serializing_if = "Option::is_none")] - pub id: Option<&'a str>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Plan ID for this item, as a string. - #[serde(skip_serializing_if = "Option::is_none")] - pub plan: Option<&'a str>, - /// The ID of the price object. - /// When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided. - #[serde(skip_serializing_if = "Option::is_none")] - pub price: Option<&'a str>, - /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. - #[serde(skip_serializing_if = "Option::is_none")] - pub price_data: Option<UpcomingLinesInvoiceSubscriptionItemsPriceData<'a>>, - /// Quantity for this item. - #[serde(skip_serializing_if = "Option::is_none")] - pub quantity: Option<u64>, - /// A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. - /// These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. - /// When updating, pass an empty string to remove previously-defined tax rates. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_rates: Option<&'a [&'a str]>, -} -impl<'a> UpcomingLinesInvoiceSubscriptionItems<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingLinesInvoiceSubscriptionItemsPriceData<'a> { - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// The ID of the product that this price will belong to. - pub product: &'a str, - /// The recurring components of a price such as `interval` and `interval_count`. - pub recurring: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring, - /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. - /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. - /// One of `inclusive`, `exclusive`, or `unspecified`. - /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option<UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior>, - /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. - #[serde(skip_serializing_if = "Option::is_none")] - pub unit_amount: Option<i64>, - /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. - /// Only one of `unit_amount` and `unit_amount_decimal` can be set. - #[serde(skip_serializing_if = "Option::is_none")] - pub unit_amount_decimal: Option<&'a str>, -} -impl<'a> UpcomingLinesInvoiceSubscriptionItemsPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } - } -} -/// The recurring components of a price such as `interval` and `interval_count`. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring { - /// Specifies billing frequency. Either `day`, `week`, `month` or `year`. - pub interval: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval, - /// The number of intervals between subscription billings. - /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). - #[serde(skip_serializing_if = "Option::is_none")] - pub interval_count: Option<u64>, -} -impl UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring { - pub fn new(interval: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval) -> Self { - Self { interval, interval_count: None } - } -} -/// Specifies billing frequency. Either `day`, `week`, `month` or `year`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { - Day, - Month, - Week, - Year, -} -impl UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { - pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval::*; - match self { - Day => "day", - Month => "month", - Week => "week", - Year => "year", - } - } -} - -impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval::*; - match s { - "day" => Ok(Day), - "month" => Ok(Month), - "week" => Ok(Week), - "year" => Ok(Year), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. -/// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. -/// One of `inclusive`, `exclusive`, or `unspecified`. -/// Once specified as either `inclusive` or `exclusive`, it cannot be changed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { - Exclusive, - Inclusive, - Unspecified, -} -impl UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { - pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior::*; - match self { - Exclusive => "exclusive", - Inclusive => "inclusive", - Unspecified => "unspecified", - } - } -} - -impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior::*; - match s { - "exclusive" => Ok(Exclusive), - "inclusive" => Ok(Inclusive), - "unspecified" => Ok(Unspecified), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. -/// The default value is `create_prorations`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceSubscriptionProrationBehavior { - AlwaysInvoice, - CreateProrations, - None, -} -impl UpcomingLinesInvoiceSubscriptionProrationBehavior { - pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceSubscriptionProrationBehavior::*; - match self { - AlwaysInvoice => "always_invoice", - CreateProrations => "create_prorations", - None => "none", - } - } -} - -impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionProrationBehavior { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceSubscriptionProrationBehavior::*; - match s { - "always_invoice" => Ok(AlwaysInvoice), - "create_prorations" => Ok(CreateProrations), - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionProrationBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionProrationBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpcomingLinesInvoiceSubscriptionProrationBehavior { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpcomingLinesInvoiceSubscriptionResumeAt { - Now, +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { + De, + En, + Fr, + Nl, } -impl UpcomingLinesInvoiceSubscriptionResumeAt { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { pub fn as_str(self) -> &'static str { - use UpcomingLinesInvoiceSubscriptionResumeAt::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; match self { - Now => "now", + De => "de", + En => "en", + Fr => "fr", + Nl => "nl", } } } -impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionResumeAt { +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpcomingLinesInvoiceSubscriptionResumeAt::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; match s { - "now" => Ok(Now), + "de" => Ok(De), + "en" => Ok(En), + "fr" => Ok(Fr), + "nl" => Ok(Nl), _ => Err(()), } } } -impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionResumeAt { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionResumeAt { +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpcomingLinesInvoiceSubscriptionResumeAt { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// If provided, the invoice returned will preview updating or creating a subscription with that trial end. -/// If set, one of `subscription_items` or `subscription` is required. -#[derive(Copy, Clone, Debug, serde::Serialize)] -#[serde(untagged)] -pub enum UpcomingLinesInvoiceSubscriptionTrialEnd { - Now, - Timestamp(stripe_types::Timestamp), -} -impl<'a> UpcomingLinesInvoice<'a> { - /// When retrieving an upcoming invoice, you’ll get a **lines** property containing the total count of line items and the first handful of those items. - /// There is also a URL where you can retrieve the full (paginated) list of line items. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::InvoiceLineItem>> { - client.get_query("/invoices/upcoming/lines", self) + +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::InvoiceLineItem>> { - stripe::ListPaginator::from_list_params("/invoices/upcoming/lines", self) +} +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) } } +/// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoice<'a> { - /// The account tax IDs associated with the invoice. Only editable when the invoice is a draft. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<&'a [&'a str]>, - /// A fee in cents (or local equivalent) that will be applied to the invoice and transferred to the application owner's Stripe account. - /// The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. - /// For more information, see the application fees [documentation](https://stripe.com/docs/billing/invoices/connect#collecting-fees). - #[serde(skip_serializing_if = "Option::is_none")] - pub application_fee_amount: Option<i64>, - /// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. - /// If `false`, the invoice's state doesn't automatically advance without an explicit action. - #[serde(skip_serializing_if = "Option::is_none")] - pub auto_advance: Option<bool>, - /// Settings for automatic tax lookup for this invoice. - #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<CreateInvoiceAutomaticTax<'a>>, - /// Either `charge_automatically`, or `send_invoice`. - /// When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. - /// When sending an invoice, Stripe will email this invoice to the customer with payment instructions. - /// Defaults to `charge_automatically`. - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: Option<stripe_shared::InvoiceCollectionMethod>, - /// The currency to create this invoice in. Defaults to that of `customer` if not specified. - #[serde(skip_serializing_if = "Option::is_none")] - pub currency: Option<stripe_types::Currency>, - /// A list of up to 4 custom fields to be displayed on the invoice. - #[serde(skip_serializing_if = "Option::is_none")] - pub custom_fields: Option<&'a [CustomFieldParams<'a>]>, - /// The ID of the customer who will be billed. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// The number of days from when the invoice is created until it is due. - /// Valid only for invoices where `collection_method=send_invoice`. - #[serde(skip_serializing_if = "Option::is_none")] - pub days_until_due: Option<u32>, - /// ID of the default payment method for the invoice. - /// It must belong to the customer associated with the invoice. - /// If not set, defaults to the subscription's default payment method, if any, or to the default payment method in the customer's invoice settings. - #[serde(skip_serializing_if = "Option::is_none")] - pub default_payment_method: Option<&'a str>, - /// ID of the default payment source for the invoice. - /// It must belong to the customer associated with the invoice and be in a chargeable state. - /// If not set, defaults to the subscription's default source, if any, or to the customer's default source. - #[serde(skip_serializing_if = "Option::is_none")] - pub default_source: Option<&'a str>, - /// The tax rates that will apply to any line item that does not have `tax_rates` set. - #[serde(skip_serializing_if = "Option::is_none")] - pub default_tax_rates: Option<&'a [&'a str]>, - /// An arbitrary string attached to the object. - /// Often useful for displaying to users. - /// Referenced as 'memo' in the Dashboard. - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option<&'a str>, - /// The coupons to redeem into discounts for the invoice. - /// If not specified, inherits the discount from the invoice's customer. - /// Pass an empty string to avoid inheriting any discounts. - #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: Option<&'a [CreateInvoiceDiscounts<'a>]>, - /// The date on which payment for this invoice is due. - /// Valid only for invoices where `collection_method=send_invoice`. - #[serde(skip_serializing_if = "Option::is_none")] - pub due_date: Option<stripe_types::Timestamp>, - /// The date when this invoice is in effect. - /// Same as `finalized_at` unless overwritten. - /// When defined, this value replaces the system-generated 'Date of issue' printed on the invoice PDF and receipt. - #[serde(skip_serializing_if = "Option::is_none")] - pub effective_at: Option<stripe_types::Timestamp>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Footer to be displayed on the invoice. - #[serde(skip_serializing_if = "Option::is_none")] - pub footer: Option<&'a str>, - /// Revise an existing invoice. - /// The new invoice will be created in `status=draft`. - /// See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details. - #[serde(skip_serializing_if = "Option::is_none")] - pub from_invoice: Option<CreateInvoiceFromInvoice<'a>>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreateInvoiceIssuer<'a>>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// The account (if any) for which the funds of the invoice payment are intended. - /// If set, the invoice will be presented with the branding and support information of the specified account. - /// See the [Invoices with Connect](https://stripe.com/docs/billing/invoices/connect) documentation for details. - #[serde(skip_serializing_if = "Option::is_none")] - pub on_behalf_of: Option<&'a str>, - /// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_settings: Option<CreateInvoicePaymentSettings<'a>>, - /// How to handle pending invoice items on invoice creation. - /// One of `include` or `exclude`. - /// `include` will include any pending invoice items, and will create an empty draft invoice if no pending invoice items exist. - /// `exclude` will always create an empty invoice draft regardless if there are pending invoice items or not. - /// Defaults to `exclude` if the parameter is omitted. - #[serde(skip_serializing_if = "Option::is_none")] - pub pending_invoice_items_behavior: Option<CreateInvoicePendingInvoiceItemsBehavior>, - /// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page. - #[serde(skip_serializing_if = "Option::is_none")] - pub rendering: Option<CreateInvoiceRendering>, - /// This is a legacy field that will be removed soon. - /// For details about `rendering_options`, refer to `rendering` instead. - /// Options for invoice PDF rendering. - #[serde(skip_serializing_if = "Option::is_none")] - pub rendering_options: Option<CreateInvoiceRenderingOptions>, - /// Settings for the cost of shipping for this invoice. - #[serde(skip_serializing_if = "Option::is_none")] - pub shipping_cost: Option<CreateInvoiceShippingCost<'a>>, - /// Shipping details for the invoice. - /// The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub shipping_details: Option<RecipientShippingWithOptionalFieldsAddress<'a>>, - /// Extra information about a charge for the customer's credit card statement. - /// It must contain at least one letter. - /// If not specified and this invoice is part of a subscription, the default `statement_descriptor` will be set to the first subscription item's product's `statement_descriptor`. - #[serde(skip_serializing_if = "Option::is_none")] - pub statement_descriptor: Option<&'a str>, - /// The ID of the subscription to invoice, if any. - /// If set, the created invoice will only include pending invoice items for that subscription. - /// The subscription's billing cycle and regular subscription events won't be affected. +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsCard { + /// Installment configuration for payments attempted on this invoice (Mexico Only). + /// + /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). #[serde(skip_serializing_if = "Option::is_none")] - pub subscription: Option<&'a str>, - /// If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge. + pub installments: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments>, + /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). + /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. + /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub transfer_data: Option<TransferDataSpecs<'a>>, + pub request_three_d_secure: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, } -impl<'a> CreateInvoice<'a> { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCard { pub fn new() -> Self { Self::default() } } -/// Settings for automatic tax lookup for this invoice. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceAutomaticTax<'a> { - /// Whether Stripe automatically computes tax on this invoice. - /// Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. +/// Installment configuration for payments attempted on this invoice (Mexico Only). +/// +/// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { + /// Setting to true enables installments for this invoice. + /// Setting to false will prevent any selected plan from applying to a payment. #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<CreateInvoiceAutomaticTaxLiability<'a>>, + pub enabled: Option<bool>, + /// The selected installment plan to use for this invoice. + #[serde(skip_serializing_if = "Option::is_none")] + pub plan: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan>, } -impl<'a> CreateInvoiceAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { + pub fn new() -> Self { + Self::default() } } -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. +/// The selected installment plan to use for this invoice. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateInvoiceAutomaticTaxLiabilityType, +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { + /// For `fixed_count` installment plans, this is the number of installment payments your customer will make to their credit card. + pub count: u64, + /// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card. + /// One of `month`. + pub interval: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, + /// Type of installment plan, one of `fixed_count`. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, } -impl<'a> CreateInvoiceAutomaticTaxLiability<'a> { - pub fn new(type_: CreateInvoiceAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { + pub fn new( + count: u64, + interval: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, + type_: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, + ) -> Self { + Self { count, interval, type_ } } } -/// Type of the account referenced in the request. +/// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card. +/// One of `month`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceAutomaticTaxLiabilityType { - Account, - Self_, +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { + Month, } -impl CreateInvoiceAutomaticTaxLiabilityType { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { pub fn as_str(self) -> &'static str { - use CreateInvoiceAutomaticTaxLiabilityType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; match self { - Account => "account", - Self_ => "self", + Month => "month", } } } -impl std::str::FromStr for CreateInvoiceAutomaticTaxLiabilityType { +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceAutomaticTaxLiabilityType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; match s { - "account" => Ok(Account), - "self" => Ok(Self_), + "month" => Ok(Month), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceAutomaticTaxLiabilityType { +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceAutomaticTaxLiabilityType { +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceAutomaticTaxLiabilityType { +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2608,76 +1442,42 @@ impl serde::Serialize for CreateInvoiceAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } -/// The coupons to redeem into discounts for the invoice. -/// If not specified, inherits the discount from the invoice's customer. -/// Pass an empty string to avoid inheriting any discounts. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoiceDiscounts<'a> { - /// ID of the coupon to create a new discount for. - #[serde(skip_serializing_if = "Option::is_none")] - pub coupon: Option<&'a str>, - /// ID of an existing discount on the object (or one of its ancestors) to reuse. - #[serde(skip_serializing_if = "Option::is_none")] - pub discount: Option<&'a str>, -} -impl<'a> CreateInvoiceDiscounts<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Revise an existing invoice. -/// The new invoice will be created in `status=draft`. -/// See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceFromInvoice<'a> { - /// The relation between the new invoice and the original invoice. - /// Currently, only 'revision' is permitted. - pub action: CreateInvoiceFromInvoiceAction, - /// The `id` of the invoice that will be cloned. - pub invoice: &'a str, -} -impl<'a> CreateInvoiceFromInvoice<'a> { - pub fn new(action: CreateInvoiceFromInvoiceAction, invoice: &'a str) -> Self { - Self { action, invoice } - } -} -/// The relation between the new invoice and the original invoice. -/// Currently, only 'revision' is permitted. +/// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceFromInvoiceAction { - Revision, +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { + FixedCount, } -impl CreateInvoiceFromInvoiceAction { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { pub fn as_str(self) -> &'static str { - use CreateInvoiceFromInvoiceAction::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; match self { - Revision => "revision", + FixedCount => "fixed_count", } } } -impl std::str::FromStr for CreateInvoiceFromInvoiceAction { +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceFromInvoiceAction::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; match s { - "revision" => Ok(Revision), + "fixed_count" => Ok(FixedCount), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceFromInvoiceAction { +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceFromInvoiceAction { +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceFromInvoiceAction { +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2685,61 +1485,47 @@ impl serde::Serialize for CreateInvoiceFromInvoiceAction { serializer.serialize_str(self.as_str()) } } -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateInvoiceIssuerType, -} -impl<'a> CreateInvoiceIssuer<'a> { - pub fn new(type_: CreateInvoiceIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. +/// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). +/// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. +/// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceIssuerType { - Account, - Self_, +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { + Any, + Automatic, } -impl CreateInvoiceIssuerType { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { - use CreateInvoiceIssuerType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; match self { - Account => "account", - Self_ => "self", + Any => "any", + Automatic => "automatic", } } } -impl std::str::FromStr for CreateInvoiceIssuerType { +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceIssuerType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; match s { - "account" => Ok(Account), - "self" => Ok(Self_), + "any" => Ok(Any), + "automatic" => Ok(Automatic), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceIssuerType { +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceIssuerType { +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceIssuerType { +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2747,132 +1533,128 @@ impl serde::Serialize for CreateInvoiceIssuerType { serializer.serialize_str(self.as_str()) } } -/// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. +/// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettings<'a> { - /// ID of the mandate to be used for this invoice. - /// It must correspond to the payment method used to pay the invoice, including the invoice's default_payment_method or default_source, if set. - #[serde(skip_serializing_if = "Option::is_none")] - pub default_mandate: Option<&'a str>, - /// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { + /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method_options: Option<CreateInvoicePaymentSettingsPaymentMethodOptions<'a>>, - /// The list of payment method types (e.g. - /// card) to provide to the invoice’s PaymentIntent. - /// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). + pub financial_connections: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method_types: Option<&'a [CreateInvoicePaymentSettingsPaymentMethodTypes]>, + pub verification_method: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod>, } -impl<'a> CreateInvoicePaymentSettings<'a> { +impl<'a> UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { Self::default() } } -/// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. +/// Additional fields for Financial Connections Session creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptions<'a> { - /// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub acss_debit: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit>, - /// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsBancontact>, - /// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub card: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCard>, - /// If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice’s PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<InvoicePaymentMethodOptionsParam<'a>>, - /// If paying by `konbini`, this sub-hash contains details about the Konbini payment method options to pass to the invoice’s PaymentIntent. +pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { + /// The list of permissions to request. + /// If this parameter is passed, the `payment_method` permission must be included. + /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, - /// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. + pub permissions: Option<&'a [UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, + /// List of data features that you would like to retrieve upon account creation. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, + pub prefetch: Option<&'a [UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, } -impl<'a> CreateInvoicePaymentSettingsPaymentMethodOptions<'a> { +impl<'a> UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { pub fn new() -> Self { Self::default() } } -/// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { - /// Additional fields for Mandate creation - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, - /// Verification method for the intent - #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, +/// The list of permissions to request. +/// If this parameter is passed, the `payment_method` permission must be included. +/// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + Balances, + Ownership, + PaymentMethod, + Transactions, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { - pub fn new() -> Self { - Self::default() +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + pub fn as_str(self) -> &'static str { + use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; + match self { + Balances => "balances", + Ownership => "ownership", + PaymentMethod => "payment_method", + Transactions => "transactions", + } } } -/// Additional fields for Mandate creation -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { - /// Transaction type of the mandate. - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: Option< - CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType, - >, + +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; + match s { + "balances" => Ok(Balances), + "ownership" => Ok(Ownership), + "payment_method" => Ok(PaymentMethod), + "transactions" => Ok(Transactions), + _ => Err(()), + } + } } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { - pub fn new() -> Self { - Self::default() +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) } } -/// Transaction type of the mandate. + +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +/// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { - Business, - Personal, +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { + Balances, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { - Business => "business", - Personal => "personal", + Balances => "balances", } } } -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { - "business" => Ok(Business), - "personal" => Ok(Personal), + "balances" => Ok(Balances), _ => Err(()), } } } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2882,14 +1664,14 @@ impl serde::Serialize } /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { +pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, Instant, Microdeposits, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { +impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; match self { Automatic => "automatic", Instant => "instant", @@ -2898,12 +1680,10 @@ impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod } } -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; + use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; match s { "automatic" => Ok(Automatic), "instant" => Ok(Instant), @@ -2912,24 +1692,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2937,72 +1711,117 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsBancontact { - /// Preferred language of the Bancontact authorization page that the customer is redirected to. - #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_language: - Option<CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, -} -impl CreateInvoicePaymentSettingsPaymentMethodOptionsBancontact { - pub fn new() -> Self { - Self::default() - } -} -/// Preferred language of the Bancontact authorization page that the customer is redirected to. +/// The list of payment method types (e.g. +/// card) to provide to the invoice’s PaymentIntent. +/// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { - De, - En, - Fr, - Nl, +#[non_exhaustive] +pub enum UpdateInvoicePaymentSettingsPaymentMethodTypes { + AchCreditTransfer, + AchDebit, + AcssDebit, + AuBecsDebit, + BacsDebit, + Bancontact, + Boleto, + Card, + Cashapp, + CustomerBalance, + Fpx, + Giropay, + Grabpay, + Ideal, + Konbini, + Link, + Paynow, + Paypal, + Promptpay, + SepaCreditTransfer, + SepaDebit, + Sofort, + UsBankAccount, + WechatPay, + /// An unrecognized value from Stripe. Should not be used as a request parameter. + Unknown, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { +impl UpdateInvoicePaymentSettingsPaymentMethodTypes { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; + use UpdateInvoicePaymentSettingsPaymentMethodTypes::*; match self { - De => "de", - En => "en", - Fr => "fr", - Nl => "nl", + AchCreditTransfer => "ach_credit_transfer", + AchDebit => "ach_debit", + AcssDebit => "acss_debit", + AuBecsDebit => "au_becs_debit", + BacsDebit => "bacs_debit", + Bancontact => "bancontact", + Boleto => "boleto", + Card => "card", + Cashapp => "cashapp", + CustomerBalance => "customer_balance", + Fpx => "fpx", + Giropay => "giropay", + Grabpay => "grabpay", + Ideal => "ideal", + Konbini => "konbini", + Link => "link", + Paynow => "paynow", + Paypal => "paypal", + Promptpay => "promptpay", + SepaCreditTransfer => "sepa_credit_transfer", + SepaDebit => "sepa_debit", + Sofort => "sofort", + UsBankAccount => "us_bank_account", + WechatPay => "wechat_pay", + Unknown => "unknown", } } } -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; + use UpdateInvoicePaymentSettingsPaymentMethodTypes::*; match s { - "de" => Ok(De), - "en" => Ok(En), - "fr" => Ok(Fr), - "nl" => Ok(Nl), + "ach_credit_transfer" => Ok(AchCreditTransfer), + "ach_debit" => Ok(AchDebit), + "acss_debit" => Ok(AcssDebit), + "au_becs_debit" => Ok(AuBecsDebit), + "bacs_debit" => Ok(BacsDebit), + "bancontact" => Ok(Bancontact), + "boleto" => Ok(Boleto), + "card" => Ok(Card), + "cashapp" => Ok(Cashapp), + "customer_balance" => Ok(CustomerBalance), + "fpx" => Ok(Fpx), + "giropay" => Ok(Giropay), + "grabpay" => Ok(Grabpay), + "ideal" => Ok(Ideal), + "konbini" => Ok(Konbini), + "link" => Ok(Link), + "paynow" => Ok(Paynow), + "paypal" => Ok(Paypal), + "promptpay" => Ok(Promptpay), + "sepa_credit_transfer" => Ok(SepaCreditTransfer), + "sepa_debit" => Ok(SepaDebit), + "sofort" => Ok(Sofort), + "us_bank_account" => Ok(UsBankAccount), + "wechat_pay" => Ok(WechatPay), _ => Err(()), } } } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodTypes { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3010,110 +1829,66 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsCard { - /// Installment configuration for payments attempted on this invoice (Mexico Only). - /// - /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). - #[serde(skip_serializing_if = "Option::is_none")] - pub installments: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments>, - /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). - /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. - #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, -} -impl CreateInvoicePaymentSettingsPaymentMethodOptionsCard { - pub fn new() -> Self { - Self::default() - } -} -/// Installment configuration for payments attempted on this invoice (Mexico Only). -/// -/// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). +/// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { - /// Setting to true enables installments for this invoice. - /// Setting to false will prevent any selected plan from applying to a payment. +pub struct UpdateInvoiceRendering { + /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. + /// One of `exclude_tax` or `include_inclusive_tax`. + /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. + /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[serde(skip_serializing_if = "Option::is_none")] - pub enabled: Option<bool>, - /// The selected installment plan to use for this invoice. + pub amount_tax_display: Option<UpdateInvoiceRenderingAmountTaxDisplay>, + /// Invoice pdf rendering options #[serde(skip_serializing_if = "Option::is_none")] - pub plan: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan>, + pub pdf: Option<UpdateInvoiceRenderingPdf>, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { +impl UpdateInvoiceRendering { pub fn new() -> Self { Self::default() } } -/// The selected installment plan to use for this invoice. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { - /// For `fixed_count` installment plans, this is the number of installment payments your customer will make to their credit card. - pub count: u64, - /// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card. - /// One of `month`. - pub interval: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, - /// Type of installment plan, one of `fixed_count`. - #[serde(rename = "type")] - pub type_: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, -} -impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { - pub fn new( - count: u64, - interval: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, - type_: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, - ) -> Self { - Self { count, interval, type_ } - } -} -/// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card. -/// One of `month`. +/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. +/// One of `exclude_tax` or `include_inclusive_tax`. +/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. +/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { - Month, +pub enum UpdateInvoiceRenderingAmountTaxDisplay { + ExcludeTax, + IncludeInclusiveTax, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { +impl UpdateInvoiceRenderingAmountTaxDisplay { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; + use UpdateInvoiceRenderingAmountTaxDisplay::*; match self { - Month => "month", + ExcludeTax => "exclude_tax", + IncludeInclusiveTax => "include_inclusive_tax", } } } -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl std::str::FromStr for UpdateInvoiceRenderingAmountTaxDisplay { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; + use UpdateInvoiceRenderingAmountTaxDisplay::*; match s { - "month" => Ok(Month), + "exclude_tax" => Ok(ExcludeTax), + "include_inclusive_tax" => Ok(IncludeInclusiveTax), _ => Err(()), } } } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl std::fmt::Display for UpdateInvoiceRenderingAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl std::fmt::Debug for UpdateInvoiceRenderingAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl serde::Serialize for UpdateInvoiceRenderingAmountTaxDisplay { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3121,46 +1896,64 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Type of installment plan, one of `fixed_count`. +/// Invoice pdf rendering options +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoiceRenderingPdf { + /// Page size for invoice PDF. Can be set to `a4`, `letter`, or `auto`. + /// If set to `auto`, invoice PDF page size defaults to `a4` for customers with + /// Japanese locale and `letter` for customers with other locales. + #[serde(skip_serializing_if = "Option::is_none")] + pub page_size: Option<UpdateInvoiceRenderingPdfPageSize>, +} +impl UpdateInvoiceRenderingPdf { + pub fn new() -> Self { + Self::default() + } +} +/// Page size for invoice PDF. Can be set to `a4`, `letter`, or `auto`. +/// If set to `auto`, invoice PDF page size defaults to `a4` for customers with +/// Japanese locale and `letter` for customers with other locales. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { - FixedCount, +pub enum UpdateInvoiceRenderingPdfPageSize { + A4, + Auto, + Letter, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { +impl UpdateInvoiceRenderingPdfPageSize { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; + use UpdateInvoiceRenderingPdfPageSize::*; match self { - FixedCount => "fixed_count", + A4 => "a4", + Auto => "auto", + Letter => "letter", } } } -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType -{ +impl std::str::FromStr for UpdateInvoiceRenderingPdfPageSize { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; + use UpdateInvoiceRenderingPdfPageSize::*; match s { - "fixed_count" => Ok(FixedCount), + "a4" => Ok(A4), + "auto" => Ok(Auto), + "letter" => Ok(Letter), _ => Err(()), } } } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType -{ +impl std::fmt::Display for UpdateInvoiceRenderingPdfPageSize { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { +impl std::fmt::Debug for UpdateInvoiceRenderingPdfPageSize { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { +impl serde::Serialize for UpdateInvoiceRenderingPdfPageSize { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3168,50 +1961,65 @@ impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardIn serializer.serialize_str(self.as_str()) } } -/// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). -/// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. +/// This is a legacy field that will be removed soon. +/// For details about `rendering_options`, refer to `rendering` instead. +/// Options for invoice PDF rendering. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateInvoiceRenderingOptions { + /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. + /// One of `exclude_tax` or `include_inclusive_tax`. + /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. + /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. + #[serde(skip_serializing_if = "Option::is_none")] + pub amount_tax_display: Option<UpdateInvoiceRenderingOptionsAmountTaxDisplay>, +} +impl UpdateInvoiceRenderingOptions { + pub fn new() -> Self { + Self::default() + } +} +/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. +/// One of `exclude_tax` or `include_inclusive_tax`. +/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. +/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { - Any, - Automatic, - Challenge, +pub enum UpdateInvoiceRenderingOptionsAmountTaxDisplay { + ExcludeTax, + IncludeInclusiveTax, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl UpdateInvoiceRenderingOptionsAmountTaxDisplay { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; + use UpdateInvoiceRenderingOptionsAmountTaxDisplay::*; match self { - Any => "any", - Automatic => "automatic", - Challenge => "challenge", + ExcludeTax => "exclude_tax", + IncludeInclusiveTax => "include_inclusive_tax", } } } -impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl std::str::FromStr for UpdateInvoiceRenderingOptionsAmountTaxDisplay { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; + use UpdateInvoiceRenderingOptionsAmountTaxDisplay::*; match s { - "any" => Ok(Any), - "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), + "exclude_tax" => Ok(ExcludeTax), + "include_inclusive_tax" => Ok(IncludeInclusiveTax), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl std::fmt::Display for UpdateInvoiceRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl std::fmt::Debug for UpdateInvoiceRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl serde::Serialize for UpdateInvoiceRenderingOptionsAmountTaxDisplay { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3219,98 +2027,135 @@ impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRe serializer.serialize_str(self.as_str()) } } -/// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. +/// Settings for the cost of shipping for this invoice. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { - /// Additional fields for Financial Connections Session creation +pub struct UpdateInvoiceShippingCost<'a> { + /// The ID of the shipping rate to use for this order. #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: Option< - CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>, - >, - /// Verification method for the intent + pub shipping_rate: Option<&'a str>, + /// Parameters to create a new ad-hoc shipping rate for this order. #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub shipping_rate_data: Option<UpdateInvoiceShippingCostShippingRateData<'a>>, } -impl<'a> CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { +impl<'a> UpdateInvoiceShippingCost<'a> { pub fn new() -> Self { Self::default() } } -/// Additional fields for Financial Connections Session creation +/// Parameters to create a new ad-hoc shipping rate for this order. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpdateInvoiceShippingCostShippingRateData<'a> { + /// The estimated range for how long shipping will take, meant to be displayable to the customer. + /// This will appear on CheckoutSessions. + #[serde(skip_serializing_if = "Option::is_none")] + pub delivery_estimate: Option<UpdateInvoiceShippingCostShippingRateDataDeliveryEstimate>, + /// The name of the shipping rate, meant to be displayable to the customer. + /// This will appear on CheckoutSessions. + pub display_name: &'a str, + /// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. + #[serde(skip_serializing_if = "Option::is_none")] + pub fixed_amount: Option<UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a>>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. + /// One of `inclusive`, `exclusive`, or `unspecified`. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_behavior: Option<UpdateInvoiceShippingCostShippingRateDataTaxBehavior>, + /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. + /// The Shipping tax code is `txcd_92010001`. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_code: Option<&'a str>, + /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + #[serde(skip_serializing_if = "Option::is_none")] + pub type_: Option<UpdateInvoiceShippingCostShippingRateDataType>, +} +impl<'a> UpdateInvoiceShippingCostShippingRateData<'a> { + pub fn new(display_name: &'a str) -> Self { + Self { delivery_estimate: None, display_name, fixed_amount: None, metadata: None, tax_behavior: None, tax_code: None, type_: None } + } +} +/// The estimated range for how long shipping will take, meant to be displayable to the customer. +/// This will appear on CheckoutSessions. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { - /// The list of permissions to request. - /// If this parameter is passed, the `payment_method` permission must be included. - /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. -#[serde(skip_serializing_if = "Option::is_none")] -pub permissions: Option<&'a [CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, - /// List of data features that you would like to retrieve upon account creation. -#[serde(skip_serializing_if = "Option::is_none")] -pub prefetch: Option<&'a [CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, - +pub struct UpdateInvoiceShippingCostShippingRateDataDeliveryEstimate { + /// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. + #[serde(skip_serializing_if = "Option::is_none")] + pub maximum: Option<UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum>, + /// The lower bound of the estimated range. If empty, represents no lower bound. + #[serde(skip_serializing_if = "Option::is_none")] + pub minimum: Option<UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum>, } -impl<'a> CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { +impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimate { pub fn new() -> Self { Self::default() } } -/// The list of permissions to request. -/// If this parameter is passed, the `payment_method` permission must be included. -/// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. +/// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { + /// A unit of time. + pub unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, + /// Must be greater than 0. + pub value: i64, +} +impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { + pub fn new(unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, value: i64) -> Self { + Self { unit, value } + } +} +/// A unit of time. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ - Balances, - Ownership, - PaymentMethod, - Transactions, +pub enum UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { + BusinessDay, + Day, + Hour, + Month, + Week, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { +impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; + use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; match self { - Balances => "balances", - Ownership => "ownership", - PaymentMethod => "payment_method", - Transactions => "transactions", + BusinessDay => "business_day", + Day => "day", + Hour => "hour", + Month => "month", + Week => "week", } } } -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; + use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; match s { - "balances" => Ok(Balances), - "ownership" => Ok(Ownership), - "payment_method" => Ok(PaymentMethod), - "transactions" => Ok(Transactions), + "business_day" => Ok(BusinessDay), + "day" => Ok(Day), + "hour" => Ok(Hour), + "month" => Ok(Month), + "week" => Ok(Week), _ => Err(()), } } } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3318,53 +2163,67 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// List of data features that you would like to retrieve upon account creation. +/// The lower bound of the estimated range. If empty, represents no lower bound. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { + /// A unit of time. + pub unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, + /// Must be greater than 0. + pub value: i64, +} +impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { + pub fn new(unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, value: i64) -> Self { + Self { unit, value } + } +} +/// A unit of time. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { - Balances, - Transactions, +pub enum UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { + BusinessDay, + Day, + Hour, + Month, + Week, } -impl CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { +impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; + use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; match self { - Balances => "balances", - Transactions => "transactions", + BusinessDay => "business_day", + Day => "day", + Hour => "hour", + Month => "month", + Week => "week", } } } -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; + use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; match s { - "balances" => Ok(Balances), - "transactions" => Ok(Transactions), + "business_day" => Ok(BusinessDay), + "day" => Ok(Day), + "hour" => Ok(Hour), + "month" => Ok(Month), + "week" => Ok(Week), _ => Err(()), } } } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3372,180 +2231,83 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Verification method for the intent -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { - Automatic, - Instant, - Microdeposits, -} -impl CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { - pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; - match self { - Automatic => "automatic", - Instant => "instant", - Microdeposits => "microdeposits", - } - } -} - -impl std::str::FromStr - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; - match s { - "automatic" => Ok(Automatic), - "instant" => Ok(Instant), - "microdeposits" => Ok(Microdeposits), - _ => Err(()), - } - } +/// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a> { + /// A non-negative integer in cents representing how much to charge. + pub amount: i64, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + pub currency: stripe_types::Currency, + /// Shipping rates defined in each available currency option. + /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). + #[serde(skip_serializing_if = "Option::is_none")] + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions>>, } -impl std::fmt::Display - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) +impl<'a> UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a> { + pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { + Self { amount, currency, currency_options: None } } } - -impl std::fmt::Debug - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } +/// Shipping rates defined in each available currency option. +/// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { + /// A non-negative integer in cents representing how much to charge. + pub amount: i64, + /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. + /// One of `inclusive`, `exclusive`, or `unspecified`. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_behavior: Option<UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior>, } -impl serde::Serialize - for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { + pub fn new(amount: i64) -> Self { + Self { amount, tax_behavior: None } } } -/// The list of payment method types (e.g. -/// card) to provide to the invoice’s PaymentIntent. -/// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). +/// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. +/// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] -#[non_exhaustive] -pub enum CreateInvoicePaymentSettingsPaymentMethodTypes { - AchCreditTransfer, - AchDebit, - AcssDebit, - AuBecsDebit, - BacsDebit, - Bancontact, - Boleto, - Card, - Cashapp, - CustomerBalance, - Eps, - Fpx, - Giropay, - Grabpay, - Ideal, - Konbini, - Link, - P24, - Paynow, - Paypal, - Promptpay, - SepaCreditTransfer, - SepaDebit, - Sofort, - UsBankAccount, - WechatPay, - /// An unrecognized value from Stripe. Should not be used as a request parameter. - Unknown, +pub enum UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { + Exclusive, + Inclusive, + Unspecified, } -impl CreateInvoicePaymentSettingsPaymentMethodTypes { +impl UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { pub fn as_str(self) -> &'static str { - use CreateInvoicePaymentSettingsPaymentMethodTypes::*; - match self { - AchCreditTransfer => "ach_credit_transfer", - AchDebit => "ach_debit", - AcssDebit => "acss_debit", - AuBecsDebit => "au_becs_debit", - BacsDebit => "bacs_debit", - Bancontact => "bancontact", - Boleto => "boleto", - Card => "card", - Cashapp => "cashapp", - CustomerBalance => "customer_balance", - Eps => "eps", - Fpx => "fpx", - Giropay => "giropay", - Grabpay => "grabpay", - Ideal => "ideal", - Konbini => "konbini", - Link => "link", - P24 => "p24", - Paynow => "paynow", - Paypal => "paypal", - Promptpay => "promptpay", - SepaCreditTransfer => "sepa_credit_transfer", - SepaDebit => "sepa_debit", - Sofort => "sofort", - UsBankAccount => "us_bank_account", - WechatPay => "wechat_pay", - Unknown => "unknown", - } - } -} - -impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodTypes { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePaymentSettingsPaymentMethodTypes::*; - match s { - "ach_credit_transfer" => Ok(AchCreditTransfer), - "ach_debit" => Ok(AchDebit), - "acss_debit" => Ok(AcssDebit), - "au_becs_debit" => Ok(AuBecsDebit), - "bacs_debit" => Ok(BacsDebit), - "bancontact" => Ok(Bancontact), - "boleto" => Ok(Boleto), - "card" => Ok(Card), - "cashapp" => Ok(Cashapp), - "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), - "fpx" => Ok(Fpx), - "giropay" => Ok(Giropay), - "grabpay" => Ok(Grabpay), - "ideal" => Ok(Ideal), - "konbini" => Ok(Konbini), - "link" => Ok(Link), - "p24" => Ok(P24), - "paynow" => Ok(Paynow), - "paypal" => Ok(Paypal), - "promptpay" => Ok(Promptpay), - "sepa_credit_transfer" => Ok(SepaCreditTransfer), - "sepa_debit" => Ok(SepaDebit), - "sofort" => Ok(Sofort), - "us_bank_account" => Ok(UsBankAccount), - "wechat_pay" => Ok(WechatPay), + use UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; + match self { + Exclusive => "exclusive", + Inclusive => "inclusive", + Unspecified => "unspecified", + } + } +} + +impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; + match s { + "exclusive" => Ok(Exclusive), + "inclusive" => Ok(Inclusive), + "unspecified" => Ok(Unspecified), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodTypes { +impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodTypes { +impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodTypes { +impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3553,52 +2315,49 @@ impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } -/// How to handle pending invoice items on invoice creation. -/// One of `include` or `exclude`. -/// `include` will include any pending invoice items, and will create an empty draft invoice if no pending invoice items exist. -/// `exclude` will always create an empty invoice draft regardless if there are pending invoice items or not. -/// Defaults to `exclude` if the parameter is omitted. +/// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. +/// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoicePendingInvoiceItemsBehavior { - Exclude, - Include, - IncludeAndRequire, +pub enum UpdateInvoiceShippingCostShippingRateDataTaxBehavior { + Exclusive, + Inclusive, + Unspecified, } -impl CreateInvoicePendingInvoiceItemsBehavior { +impl UpdateInvoiceShippingCostShippingRateDataTaxBehavior { pub fn as_str(self) -> &'static str { - use CreateInvoicePendingInvoiceItemsBehavior::*; + use UpdateInvoiceShippingCostShippingRateDataTaxBehavior::*; match self { - Exclude => "exclude", - Include => "include", - IncludeAndRequire => "include_and_require", + Exclusive => "exclusive", + Inclusive => "inclusive", + Unspecified => "unspecified", } } } -impl std::str::FromStr for CreateInvoicePendingInvoiceItemsBehavior { +impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoicePendingInvoiceItemsBehavior::*; + use UpdateInvoiceShippingCostShippingRateDataTaxBehavior::*; match s { - "exclude" => Ok(Exclude), - "include" => Ok(Include), - "include_and_require" => Ok(IncludeAndRequire), + "exclusive" => Ok(Exclusive), + "inclusive" => Ok(Inclusive), + "unspecified" => Ok(Unspecified), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoicePendingInvoiceItemsBehavior { +impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoicePendingInvoiceItemsBehavior { +impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoicePendingInvoiceItemsBehavior { +impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3606,131 +2365,289 @@ impl serde::Serialize for CreateInvoicePendingInvoiceItemsBehavior { serializer.serialize_str(self.as_str()) } } -/// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoiceRendering { - /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. - /// One of `exclude_tax` or `include_inclusive_tax`. - /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. - /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: Option<CreateInvoiceRenderingAmountTaxDisplay>, - /// Invoice pdf rendering options - #[serde(skip_serializing_if = "Option::is_none")] - pub pdf: Option<CreateInvoiceRenderingPdf>, -} -impl CreateInvoiceRendering { - pub fn new() -> Self { - Self::default() - } -} -/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. -/// One of `exclude_tax` or `include_inclusive_tax`. -/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. -/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. +/// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceRenderingAmountTaxDisplay { - ExcludeTax, - IncludeInclusiveTax, +pub enum UpdateInvoiceShippingCostShippingRateDataType { + FixedAmount, } -impl CreateInvoiceRenderingAmountTaxDisplay { +impl UpdateInvoiceShippingCostShippingRateDataType { pub fn as_str(self) -> &'static str { - use CreateInvoiceRenderingAmountTaxDisplay::*; + use UpdateInvoiceShippingCostShippingRateDataType::*; match self { - ExcludeTax => "exclude_tax", - IncludeInclusiveTax => "include_inclusive_tax", + FixedAmount => "fixed_amount", } } } -impl std::str::FromStr for CreateInvoiceRenderingAmountTaxDisplay { +impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceRenderingAmountTaxDisplay::*; + use UpdateInvoiceShippingCostShippingRateDataType::*; match s { - "exclude_tax" => Ok(ExcludeTax), - "include_inclusive_tax" => Ok(IncludeInclusiveTax), + "fixed_amount" => Ok(FixedAmount), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceRenderingAmountTaxDisplay { +impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceRenderingAmountTaxDisplay { +impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceRenderingAmountTaxDisplay { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataType { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> UpdateInvoice<'a> { + /// Draft invoices are fully editable. + /// Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized),. + /// monetary values, as well as `collection_method`, become uneditable. + /// + /// If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on,. + /// sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass. + /// `auto_advance=false`. + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::Invoice> { + client.send_form(&format!("/invoices/{invoice}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct PayInvoice<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// In cases where the source used to pay the invoice has insufficient funds, passing `forgive=true` controls whether a charge should be attempted for the full amount available on the source, up to the amount to fully pay the invoice. + /// This effectively forgives the difference between the amount available on the source and the amount due. + /// + /// + /// Passing `forgive=false` will fail the charge if the source hasn't been pre-funded with the right amount. + /// An example for this case is with ACH Credit Transfers and wires: if the amount wired is less than the amount due by a small amount, you might want to forgive the difference. + /// Defaults to `false`. + #[serde(skip_serializing_if = "Option::is_none")] + pub forgive: Option<bool>, + /// ID of the mandate to be used for this invoice. + /// It must correspond to the payment method used to pay the invoice, including the payment_method param or the invoice's default_payment_method or default_source, if set. + #[serde(skip_serializing_if = "Option::is_none")] + pub mandate: Option<&'a str>, + /// Indicates if a customer is on or off-session while an invoice payment is attempted. + /// Defaults to `true` (off-session). + #[serde(skip_serializing_if = "Option::is_none")] + pub off_session: Option<bool>, + /// Boolean representing whether an invoice is paid outside of Stripe. + /// This will result in no charge being made. + /// Defaults to `false`. + #[serde(skip_serializing_if = "Option::is_none")] + pub paid_out_of_band: Option<bool>, + /// A PaymentMethod to be charged. + /// The PaymentMethod must be the ID of a PaymentMethod belonging to the customer associated with the invoice being paid. + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method: Option<&'a str>, + /// A payment source to be charged. + /// The source must be the ID of a source belonging to the customer associated with the invoice being paid. + #[serde(skip_serializing_if = "Option::is_none")] + pub source: Option<&'a str>, +} +impl<'a> PayInvoice<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> PayInvoice<'a> { + /// Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). + /// However, if you’d like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::Invoice> { + client.send_form(&format!("/invoices/{invoice}/pay"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpcomingLinesInvoice<'a> { + /// Settings for automatic tax lookup for this invoice preview. + #[serde(skip_serializing_if = "Option::is_none")] + pub automatic_tax: Option<AutomaticTaxParam>, + /// The code of the coupon to apply. + /// If `subscription` or `subscription_items` is provided, the invoice returned will preview updating or creating a subscription with that coupon. + /// Otherwise, it will preview applying that coupon to the customer for the next upcoming invoice from among the customer's subscriptions. + /// The invoice can be previewed without a coupon by passing this value as an empty string. + #[serde(skip_serializing_if = "Option::is_none")] + pub coupon: Option<&'a str>, + /// The currency to preview this invoice in. Defaults to that of `customer` if not specified. + #[serde(skip_serializing_if = "Option::is_none")] + pub currency: Option<stripe_types::Currency>, + /// The identifier of the customer whose upcoming invoice you'd like to retrieve. + /// If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// Details about the customer you want to invoice or overrides for an existing customer. + /// If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer_details: Option<UpcomingLinesInvoiceCustomerDetails<'a>>, + /// The coupons to redeem into discounts for the invoice preview. + /// If not specified, inherits the discount from the customer or subscription. + /// This only works for coupons directly applied to the invoice. + /// To apply a coupon to a subscription, you must use the `coupon` parameter instead. + /// Pass an empty string to avoid inheriting any discounts. + /// To preview the upcoming invoice for a subscription that hasn't been created, use `coupon` instead. + #[serde(skip_serializing_if = "Option::is_none")] + pub discounts: Option<&'a [DiscountsDataParam<'a>]>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// List of invoice items to add or update in the upcoming invoice preview. + #[serde(skip_serializing_if = "Option::is_none")] + pub invoice_items: Option<&'a [UpcomingLinesInvoiceInvoiceItems<'a>]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// The identifier of the schedule whose upcoming invoice you'd like to retrieve. + /// Cannot be used with subscription or subscription fields. + #[serde(skip_serializing_if = "Option::is_none")] + pub schedule: Option<&'a str>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// The identifier of the subscription for which you'd like to retrieve the upcoming invoice. + /// If not provided, but a `subscription_items` is provided, you will preview creating a subscription with those items. + /// If neither `subscription` nor `subscription_items` is provided, you will retrieve the next upcoming invoice from among the customer's subscriptions. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription: Option<&'a str>, + /// For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). + /// This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. + /// For existing subscriptions, the value can only be set to `now` or `unchanged`. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_billing_cycle_anchor: Option<UpcomingLinesInvoiceSubscriptionBillingCycleAnchor>, + /// Timestamp indicating when the subscription should be scheduled to cancel. + /// Will prorate if within the current period and prorations have been enabled using `proration_behavior`. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_cancel_at: Option<stripe_types::Timestamp>, + /// Boolean indicating whether this subscription should cancel at the end of the current period. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_cancel_at_period_end: Option<bool>, + /// This simulates the subscription being canceled or expired immediately. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_cancel_now: Option<bool>, + /// If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. + /// The default tax rates will apply to any line item that does not have `tax_rates` set. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_default_tax_rates: Option<&'a [&'a str]>, + /// A list of up to 20 subscription items, each with an attached price. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_items: Option<&'a [UpcomingLinesInvoiceSubscriptionItems<'a>]>, + /// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. + /// The default value is `create_prorations`. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_proration_behavior: Option<UpcomingLinesInvoiceSubscriptionProrationBehavior>, + /// If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. + /// The time given must be within the current subscription period and within the current phase of the schedule backing this subscription, if the schedule exists. + /// If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. + /// Also, `subscription_proration_behavior` cannot be set to 'none'. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_proration_date: Option<stripe_types::Timestamp>, + /// For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_resume_at: Option<UpcomingLinesInvoiceSubscriptionResumeAt>, + /// Date a subscription is intended to start (can be future or past) + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_start_date: Option<stripe_types::Timestamp>, + /// If provided, the invoice returned will preview updating or creating a subscription with that trial end. + /// If set, one of `subscription_items` or `subscription` is required. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_trial_end: Option<UpcomingLinesInvoiceSubscriptionTrialEnd>, + /// Indicates if a plan's `trial_period_days` should be applied to the subscription. + /// Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. + /// Setting this flag to `true` together with `subscription_trial_end` is not allowed. + /// See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription_trial_from_plan: Option<bool>, +} +impl<'a> UpcomingLinesInvoice<'a> { + pub fn new() -> Self { + Self::default() } } -/// Invoice pdf rendering options +/// Details about the customer you want to invoice or overrides for an existing customer. +/// If `automatic_tax` is enabled then one of `customer`, `customer_details`, `subscription`, or `schedule` must be set. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoiceRenderingPdf { - /// Page size for invoice PDF. Can be set to `a4`, `letter`, or `auto`. - /// If set to `auto`, invoice PDF page size defaults to `a4` for customers with - /// Japanese locale and `letter` for customers with other locales. +pub struct UpcomingLinesInvoiceCustomerDetails<'a> { + /// The customer's address. #[serde(skip_serializing_if = "Option::is_none")] - pub page_size: Option<CreateInvoiceRenderingPdfPageSize>, + pub address: Option<OptionalFieldsAddress<'a>>, + /// The customer's shipping information. Appears on invoices emailed to this customer. + #[serde(skip_serializing_if = "Option::is_none")] + pub shipping: Option<CustomerShipping<'a>>, + /// Tax details about the customer. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax: Option<TaxParam<'a>>, + /// The customer's tax exemption. One of `none`, `exempt`, or `reverse`. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_exempt: Option<UpcomingLinesInvoiceCustomerDetailsTaxExempt>, + /// The customer's tax IDs. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_ids: Option<&'a [UpcomingLinesInvoiceCustomerDetailsTaxIds<'a>]>, } -impl CreateInvoiceRenderingPdf { +impl<'a> UpcomingLinesInvoiceCustomerDetails<'a> { pub fn new() -> Self { Self::default() } } -/// Page size for invoice PDF. Can be set to `a4`, `letter`, or `auto`. -/// If set to `auto`, invoice PDF page size defaults to `a4` for customers with -/// Japanese locale and `letter` for customers with other locales. +/// The customer's tax exemption. One of `none`, `exempt`, or `reverse`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceRenderingPdfPageSize { - A4, - Auto, - Letter, +pub enum UpcomingLinesInvoiceCustomerDetailsTaxExempt { + Exempt, + None, + Reverse, } -impl CreateInvoiceRenderingPdfPageSize { +impl UpcomingLinesInvoiceCustomerDetailsTaxExempt { pub fn as_str(self) -> &'static str { - use CreateInvoiceRenderingPdfPageSize::*; + use UpcomingLinesInvoiceCustomerDetailsTaxExempt::*; match self { - A4 => "a4", - Auto => "auto", - Letter => "letter", + Exempt => "exempt", + None => "none", + Reverse => "reverse", } } } -impl std::str::FromStr for CreateInvoiceRenderingPdfPageSize { +impl std::str::FromStr for UpcomingLinesInvoiceCustomerDetailsTaxExempt { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceRenderingPdfPageSize::*; + use UpcomingLinesInvoiceCustomerDetailsTaxExempt::*; match s { - "a4" => Ok(A4), - "auto" => Ok(Auto), - "letter" => Ok(Letter), + "exempt" => Ok(Exempt), + "none" => Ok(None), + "reverse" => Ok(Reverse), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceRenderingPdfPageSize { +impl std::fmt::Display for UpcomingLinesInvoiceCustomerDetailsTaxExempt { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceRenderingPdfPageSize { +impl std::fmt::Debug for UpcomingLinesInvoiceCustomerDetailsTaxExempt { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceRenderingPdfPageSize { +impl serde::Serialize for UpcomingLinesInvoiceCustomerDetailsTaxExempt { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3738,65 +2655,255 @@ impl serde::Serialize for CreateInvoiceRenderingPdfPageSize { serializer.serialize_str(self.as_str()) } } -/// This is a legacy field that will be removed soon. -/// For details about `rendering_options`, refer to `rendering` instead. -/// Options for invoice PDF rendering. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoiceRenderingOptions { - /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. - /// One of `exclude_tax` or `include_inclusive_tax`. - /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. - /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: Option<CreateInvoiceRenderingOptionsAmountTaxDisplay>, +/// The customer's tax IDs. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpcomingLinesInvoiceCustomerDetailsTaxIds<'a> { + /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: UpcomingLinesInvoiceCustomerDetailsTaxIdsType, + /// Value of the tax ID. + pub value: &'a str, } -impl CreateInvoiceRenderingOptions { - pub fn new() -> Self { - Self::default() +impl<'a> UpcomingLinesInvoiceCustomerDetailsTaxIds<'a> { + pub fn new(type_: UpcomingLinesInvoiceCustomerDetailsTaxIdsType, value: &'a str) -> Self { + Self { type_, value } } } -/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. -/// One of `exclude_tax` or `include_inclusive_tax`. -/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. -/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. +/// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceRenderingOptionsAmountTaxDisplay { - ExcludeTax, - IncludeInclusiveTax, +#[non_exhaustive] +pub enum UpcomingLinesInvoiceCustomerDetailsTaxIdsType { + AdNrt, + AeTrn, + ArCuit, + AuAbn, + AuArn, + BgUic, + BoTin, + BrCnpj, + BrCpf, + CaBn, + CaGstHst, + CaPstBc, + CaPstMb, + CaPstSk, + CaQst, + ChVat, + ClTin, + CnTin, + CoNit, + CrTin, + DoRcn, + EcRuc, + EgTin, + EsCif, + EuOssVat, + EuVat, + GbVat, + GeVat, + HkBr, + HuTin, + IdNpwp, + IlVat, + InGst, + IsVat, + JpCn, + JpRn, + JpTrn, + KePin, + KrBrn, + LiUid, + MxRfc, + MyFrp, + MyItn, + MySst, + NoVat, + NzGst, + PeRuc, + PhTin, + RoTin, + RsPib, + RuInn, + RuKpp, + SaVat, + SgGst, + SgUen, + SiTin, + SvNit, + ThVat, + TrTin, + TwVat, + UaVat, + UsEin, + UyRuc, + VeRif, + VnTin, + ZaVat, + /// An unrecognized value from Stripe. Should not be used as a request parameter. + Unknown, } -impl CreateInvoiceRenderingOptionsAmountTaxDisplay { +impl UpcomingLinesInvoiceCustomerDetailsTaxIdsType { pub fn as_str(self) -> &'static str { - use CreateInvoiceRenderingOptionsAmountTaxDisplay::*; + use UpcomingLinesInvoiceCustomerDetailsTaxIdsType::*; match self { - ExcludeTax => "exclude_tax", - IncludeInclusiveTax => "include_inclusive_tax", + AdNrt => "ad_nrt", + AeTrn => "ae_trn", + ArCuit => "ar_cuit", + AuAbn => "au_abn", + AuArn => "au_arn", + BgUic => "bg_uic", + BoTin => "bo_tin", + BrCnpj => "br_cnpj", + BrCpf => "br_cpf", + CaBn => "ca_bn", + CaGstHst => "ca_gst_hst", + CaPstBc => "ca_pst_bc", + CaPstMb => "ca_pst_mb", + CaPstSk => "ca_pst_sk", + CaQst => "ca_qst", + ChVat => "ch_vat", + ClTin => "cl_tin", + CnTin => "cn_tin", + CoNit => "co_nit", + CrTin => "cr_tin", + DoRcn => "do_rcn", + EcRuc => "ec_ruc", + EgTin => "eg_tin", + EsCif => "es_cif", + EuOssVat => "eu_oss_vat", + EuVat => "eu_vat", + GbVat => "gb_vat", + GeVat => "ge_vat", + HkBr => "hk_br", + HuTin => "hu_tin", + IdNpwp => "id_npwp", + IlVat => "il_vat", + InGst => "in_gst", + IsVat => "is_vat", + JpCn => "jp_cn", + JpRn => "jp_rn", + JpTrn => "jp_trn", + KePin => "ke_pin", + KrBrn => "kr_brn", + LiUid => "li_uid", + MxRfc => "mx_rfc", + MyFrp => "my_frp", + MyItn => "my_itn", + MySst => "my_sst", + NoVat => "no_vat", + NzGst => "nz_gst", + PeRuc => "pe_ruc", + PhTin => "ph_tin", + RoTin => "ro_tin", + RsPib => "rs_pib", + RuInn => "ru_inn", + RuKpp => "ru_kpp", + SaVat => "sa_vat", + SgGst => "sg_gst", + SgUen => "sg_uen", + SiTin => "si_tin", + SvNit => "sv_nit", + ThVat => "th_vat", + TrTin => "tr_tin", + TwVat => "tw_vat", + UaVat => "ua_vat", + UsEin => "us_ein", + UyRuc => "uy_ruc", + VeRif => "ve_rif", + VnTin => "vn_tin", + ZaVat => "za_vat", + Unknown => "unknown", } } } -impl std::str::FromStr for CreateInvoiceRenderingOptionsAmountTaxDisplay { +impl std::str::FromStr for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceRenderingOptionsAmountTaxDisplay::*; + use UpcomingLinesInvoiceCustomerDetailsTaxIdsType::*; match s { - "exclude_tax" => Ok(ExcludeTax), - "include_inclusive_tax" => Ok(IncludeInclusiveTax), + "ad_nrt" => Ok(AdNrt), + "ae_trn" => Ok(AeTrn), + "ar_cuit" => Ok(ArCuit), + "au_abn" => Ok(AuAbn), + "au_arn" => Ok(AuArn), + "bg_uic" => Ok(BgUic), + "bo_tin" => Ok(BoTin), + "br_cnpj" => Ok(BrCnpj), + "br_cpf" => Ok(BrCpf), + "ca_bn" => Ok(CaBn), + "ca_gst_hst" => Ok(CaGstHst), + "ca_pst_bc" => Ok(CaPstBc), + "ca_pst_mb" => Ok(CaPstMb), + "ca_pst_sk" => Ok(CaPstSk), + "ca_qst" => Ok(CaQst), + "ch_vat" => Ok(ChVat), + "cl_tin" => Ok(ClTin), + "cn_tin" => Ok(CnTin), + "co_nit" => Ok(CoNit), + "cr_tin" => Ok(CrTin), + "do_rcn" => Ok(DoRcn), + "ec_ruc" => Ok(EcRuc), + "eg_tin" => Ok(EgTin), + "es_cif" => Ok(EsCif), + "eu_oss_vat" => Ok(EuOssVat), + "eu_vat" => Ok(EuVat), + "gb_vat" => Ok(GbVat), + "ge_vat" => Ok(GeVat), + "hk_br" => Ok(HkBr), + "hu_tin" => Ok(HuTin), + "id_npwp" => Ok(IdNpwp), + "il_vat" => Ok(IlVat), + "in_gst" => Ok(InGst), + "is_vat" => Ok(IsVat), + "jp_cn" => Ok(JpCn), + "jp_rn" => Ok(JpRn), + "jp_trn" => Ok(JpTrn), + "ke_pin" => Ok(KePin), + "kr_brn" => Ok(KrBrn), + "li_uid" => Ok(LiUid), + "mx_rfc" => Ok(MxRfc), + "my_frp" => Ok(MyFrp), + "my_itn" => Ok(MyItn), + "my_sst" => Ok(MySst), + "no_vat" => Ok(NoVat), + "nz_gst" => Ok(NzGst), + "pe_ruc" => Ok(PeRuc), + "ph_tin" => Ok(PhTin), + "ro_tin" => Ok(RoTin), + "rs_pib" => Ok(RsPib), + "ru_inn" => Ok(RuInn), + "ru_kpp" => Ok(RuKpp), + "sa_vat" => Ok(SaVat), + "sg_gst" => Ok(SgGst), + "sg_uen" => Ok(SgUen), + "si_tin" => Ok(SiTin), + "sv_nit" => Ok(SvNit), + "th_vat" => Ok(ThVat), + "tr_tin" => Ok(TrTin), + "tw_vat" => Ok(TwVat), + "ua_vat" => Ok(UaVat), + "us_ein" => Ok(UsEin), + "uy_ruc" => Ok(UyRuc), + "ve_rif" => Ok(VeRif), + "vn_tin" => Ok(VnTin), + "za_vat" => Ok(ZaVat), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceRenderingOptionsAmountTaxDisplay { +impl std::fmt::Display for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceRenderingOptionsAmountTaxDisplay { +impl std::fmt::Debug for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceRenderingOptionsAmountTaxDisplay { +impl serde::Serialize for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3804,146 +2911,204 @@ impl serde::Serialize for CreateInvoiceRenderingOptionsAmountTaxDisplay { serializer.serialize_str(self.as_str()) } } -/// Settings for the cost of shipping for this invoice. +/// List of invoice items to add or update in the upcoming invoice preview. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoiceShippingCost<'a> { - /// The ID of the shipping rate to use for this order. +pub struct UpcomingLinesInvoiceInvoiceItems<'a> { + /// The integer amount in cents (or local equivalent) of previewed invoice item. #[serde(skip_serializing_if = "Option::is_none")] - pub shipping_rate: Option<&'a str>, - /// Parameters to create a new ad-hoc shipping rate for this order. + pub amount: Option<i64>, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + /// Only applicable to new invoice items. #[serde(skip_serializing_if = "Option::is_none")] - pub shipping_rate_data: Option<CreateInvoiceShippingCostShippingRateData<'a>>, -} -impl<'a> CreateInvoiceShippingCost<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Parameters to create a new ad-hoc shipping rate for this order. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceShippingCostShippingRateData<'a> { - /// The estimated range for how long shipping will take, meant to be displayable to the customer. - /// This will appear on CheckoutSessions. + pub currency: Option<stripe_types::Currency>, + /// An arbitrary string which you can attach to the invoice item. + /// The description is displayed in the invoice for easy tracking. #[serde(skip_serializing_if = "Option::is_none")] - pub delivery_estimate: Option<CreateInvoiceShippingCostShippingRateDataDeliveryEstimate>, - /// The name of the shipping rate, meant to be displayable to the customer. - /// This will appear on CheckoutSessions. - pub display_name: &'a str, - /// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. + pub description: Option<&'a str>, + /// Explicitly controls whether discounts apply to this invoice item. + /// Defaults to true, except for negative invoice items. #[serde(skip_serializing_if = "Option::is_none")] - pub fixed_amount: Option<CreateInvoiceShippingCostShippingRateDataFixedAmount<'a>>, + pub discountable: Option<bool>, + /// The coupons to redeem into discounts for the invoice item in the preview. + #[serde(skip_serializing_if = "Option::is_none")] + pub discounts: Option<&'a [DiscountsDataParam<'a>]>, + /// The ID of the invoice item to update in preview. + /// If not specified, a new invoice item will be added to the preview of the upcoming invoice. + #[serde(skip_serializing_if = "Option::is_none")] + pub invoiceitem: Option<&'a str>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. /// All keys can be unset by posting an empty value to `metadata`. #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. + /// The period associated with this invoice item. + /// When set to different values, the period will be rendered on the invoice. + /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. + /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. + #[serde(skip_serializing_if = "Option::is_none")] + pub period: Option<Period>, + /// The ID of the price object. + #[serde(skip_serializing_if = "Option::is_none")] + pub price: Option<&'a str>, + /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. + #[serde(skip_serializing_if = "Option::is_none")] + pub price_data: Option<UpcomingLinesInvoiceInvoiceItemsPriceData<'a>>, + /// Non-negative integer. The quantity of units for the invoice item. + #[serde(skip_serializing_if = "Option::is_none")] + pub quantity: Option<u64>, + /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. + /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. + /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option<CreateInvoiceShippingCostShippingRateDataTaxBehavior>, + pub tax_behavior: Option<UpcomingLinesInvoiceInvoiceItemsTaxBehavior>, /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. - /// The Shipping tax code is `txcd_92010001`. #[serde(skip_serializing_if = "Option::is_none")] pub tax_code: Option<&'a str>, - /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - #[serde(rename = "type")] + /// The tax rates that apply to the item. When set, any `default_tax_rates` do not apply to this item. #[serde(skip_serializing_if = "Option::is_none")] - pub type_: Option<CreateInvoiceShippingCostShippingRateDataType>, -} -impl<'a> CreateInvoiceShippingCostShippingRateData<'a> { - pub fn new(display_name: &'a str) -> Self { - Self { - delivery_estimate: None, - display_name, - fixed_amount: None, - metadata: None, - tax_behavior: None, - tax_code: None, - type_: None, - } - } -} -/// The estimated range for how long shipping will take, meant to be displayable to the customer. -/// This will appear on CheckoutSessions. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoiceShippingCostShippingRateDataDeliveryEstimate { - /// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. + pub tax_rates: Option<&'a [&'a str]>, + /// The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. + /// This unit_amount will be multiplied by the quantity to get the full amount. + /// If you want to apply a credit to the customer's account, pass a negative unit_amount. #[serde(skip_serializing_if = "Option::is_none")] - pub maximum: Option<CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum>, - /// The lower bound of the estimated range. If empty, represents no lower bound. + pub unit_amount: Option<i64>, + /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. + /// Only one of `unit_amount` and `unit_amount_decimal` can be set. #[serde(skip_serializing_if = "Option::is_none")] - pub minimum: Option<CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum>, + pub unit_amount_decimal: Option<&'a str>, } -impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimate { +impl<'a> UpcomingLinesInvoiceInvoiceItems<'a> { pub fn new() -> Self { Self::default() } } -/// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. +/// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { - /// A unit of time. - pub unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, - /// Must be greater than 0. - pub value: i64, +pub struct UpcomingLinesInvoiceInvoiceItemsPriceData<'a> { + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + pub currency: stripe_types::Currency, + /// The ID of the product that this price will belong to. + pub product: &'a str, + /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. + /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. + /// One of `inclusive`, `exclusive`, or `unspecified`. + /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_behavior: Option<UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior>, + /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. + #[serde(skip_serializing_if = "Option::is_none")] + pub unit_amount: Option<i64>, + /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. + /// Only one of `unit_amount` and `unit_amount_decimal` can be set. + #[serde(skip_serializing_if = "Option::is_none")] + pub unit_amount_decimal: Option<&'a str>, } -impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { - pub fn new( - unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, - value: i64, - ) -> Self { - Self { unit, value } +impl<'a> UpcomingLinesInvoiceInvoiceItemsPriceData<'a> { + pub fn new(currency: stripe_types::Currency, product: &'a str) -> Self { + Self { currency, product, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } + } +} +/// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. +/// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. +/// One of `inclusive`, `exclusive`, or `unspecified`. +/// Once specified as either `inclusive` or `exclusive`, it cannot be changed. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { + Exclusive, + Inclusive, + Unspecified, +} +impl UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { + pub fn as_str(self) -> &'static str { + use UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior::*; + match self { + Exclusive => "exclusive", + Inclusive => "inclusive", + Unspecified => "unspecified", + } + } +} + +impl std::str::FromStr for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior::*; + match s { + "exclusive" => Ok(Exclusive), + "inclusive" => Ok(Inclusive), + "unspecified" => Ok(Unspecified), + _ => Err(()), + } + } +} +impl std::fmt::Display for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) } } -/// A unit of time. +impl serde::Serialize for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +/// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. +/// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. +/// One of `inclusive`, `exclusive`, or `unspecified`. +/// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { - BusinessDay, - Day, - Hour, - Month, - Week, +pub enum UpcomingLinesInvoiceInvoiceItemsTaxBehavior { + Exclusive, + Inclusive, + Unspecified, } -impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl UpcomingLinesInvoiceInvoiceItemsTaxBehavior { pub fn as_str(self) -> &'static str { - use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; + use UpcomingLinesInvoiceInvoiceItemsTaxBehavior::*; match self { - BusinessDay => "business_day", - Day => "day", - Hour => "hour", - Month => "month", - Week => "week", + Exclusive => "exclusive", + Inclusive => "inclusive", + Unspecified => "unspecified", } } } -impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl std::str::FromStr for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; + use UpcomingLinesInvoiceInvoiceItemsTaxBehavior::*; match s { - "business_day" => Ok(BusinessDay), - "day" => Ok(Day), - "hour" => Ok(Hour), - "month" => Ok(Month), - "week" => Ok(Week), + "exclusive" => Ok(Exclusive), + "inclusive" => Ok(Inclusive), + "unspecified" => Ok(Unspecified), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl std::fmt::Display for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl std::fmt::Debug for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl serde::Serialize for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3951,70 +3116,153 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstim serializer.serialize_str(self.as_str()) } } -/// The lower bound of the estimated range. If empty, represents no lower bound. +/// For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). +/// This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. +/// For existing subscriptions, the value can only be set to `now` or `unchanged`. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { - /// A unit of time. - pub unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, - /// Must be greater than 0. - pub value: i64, +#[serde(untagged)] +pub enum UpcomingLinesInvoiceSubscriptionBillingCycleAnchor { + Now, + Unchanged, + Timestamp(stripe_types::Timestamp), } -impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { - pub fn new( - unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, - value: i64, - ) -> Self { - Self { unit, value } +/// A list of up to 20 subscription items, each with an attached price. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpcomingLinesInvoiceSubscriptionItems<'a> { + /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. + /// When updating, pass an empty string to remove previously-defined thresholds. + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_thresholds: Option<ItemBillingThresholdsParam>, + /// Delete all usage for a given subscription item. + /// Allowed only when `deleted` is set to `true` and the current plan's `usage_type` is `metered`. + #[serde(skip_serializing_if = "Option::is_none")] + pub clear_usage: Option<bool>, + /// A flag that, if set to `true`, will delete the specified item. + #[serde(skip_serializing_if = "Option::is_none")] + pub deleted: Option<bool>, + /// Subscription item to update. + #[serde(skip_serializing_if = "Option::is_none")] + pub id: Option<&'a str>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// Plan ID for this item, as a string. + #[serde(skip_serializing_if = "Option::is_none")] + pub plan: Option<&'a str>, + /// The ID of the price object. + /// When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided. + #[serde(skip_serializing_if = "Option::is_none")] + pub price: Option<&'a str>, + /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. + #[serde(skip_serializing_if = "Option::is_none")] + pub price_data: Option<UpcomingLinesInvoiceSubscriptionItemsPriceData<'a>>, + /// Quantity for this item. + #[serde(skip_serializing_if = "Option::is_none")] + pub quantity: Option<u64>, + /// A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. + /// These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. + /// When updating, pass an empty string to remove previously-defined tax rates. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_rates: Option<&'a [&'a str]>, +} +impl<'a> UpcomingLinesInvoiceSubscriptionItems<'a> { + pub fn new() -> Self { + Self::default() } } -/// A unit of time. +/// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpcomingLinesInvoiceSubscriptionItemsPriceData<'a> { + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + pub currency: stripe_types::Currency, + /// The ID of the product that this price will belong to. + pub product: &'a str, + /// The recurring components of a price such as `interval` and `interval_count`. + pub recurring: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring, + /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. + /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. + /// One of `inclusive`, `exclusive`, or `unspecified`. + /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. + #[serde(skip_serializing_if = "Option::is_none")] + pub tax_behavior: Option<UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior>, + /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. + #[serde(skip_serializing_if = "Option::is_none")] + pub unit_amount: Option<i64>, + /// Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. + /// Only one of `unit_amount` and `unit_amount_decimal` can be set. + #[serde(skip_serializing_if = "Option::is_none")] + pub unit_amount_decimal: Option<&'a str>, +} +impl<'a> UpcomingLinesInvoiceSubscriptionItemsPriceData<'a> { + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } + } +} +/// The recurring components of a price such as `interval` and `interval_count`. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring { + /// Specifies billing frequency. Either `day`, `week`, `month` or `year`. + pub interval: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval, + /// The number of intervals between subscription billings. + /// For example, `interval=month` and `interval_count=3` bills every 3 months. + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). + #[serde(skip_serializing_if = "Option::is_none")] + pub interval_count: Option<u64>, +} +impl UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurring { + pub fn new(interval: UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval) -> Self { + Self { interval, interval_count: None } + } +} +/// Specifies billing frequency. Either `day`, `week`, `month` or `year`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { - BusinessDay, +pub enum UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { Day, - Hour, Month, Week, + Year, } -impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { pub fn as_str(self) -> &'static str { - use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; + use UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval::*; match self { - BusinessDay => "business_day", Day => "day", - Hour => "hour", Month => "month", Week => "week", + Year => "year", } } } -impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; + use UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval::*; match s { - "business_day" => Ok(BusinessDay), "day" => Ok(Day), - "hour" => Ok(Hour), "month" => Ok(Month), "week" => Ok(Week), + "year" => Ok(Year), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl serde::Serialize for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4022,57 +3270,19 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstim serializer.serialize_str(self.as_str()) } } -/// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceShippingCostShippingRateDataFixedAmount<'a> { - /// A non-negative integer in cents representing how much to charge. - pub amount: i64, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// Shipping rates defined in each available currency option. - /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). - #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - &'a std::collections::HashMap< - stripe_types::Currency, - CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions, - >, - >, -} -impl<'a> CreateInvoiceShippingCostShippingRateDataFixedAmount<'a> { - pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { - Self { amount, currency, currency_options: None } - } -} -/// Shipping rates defined in each available currency option. -/// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { - /// A non-negative integer in cents representing how much to charge. - pub amount: i64, - /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. - /// One of `inclusive`, `exclusive`, or `unspecified`. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: - Option<CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior>, -} -impl CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { - pub fn new(amount: i64) -> Self { - Self { amount, tax_behavior: None } - } -} -/// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. +/// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. +/// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. +/// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { +pub enum UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { +impl UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { pub fn as_str(self) -> &'static str { - use CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; + use UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -4081,12 +3291,10 @@ impl CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehav } } -impl std::str::FromStr - for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; + use UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -4095,24 +3303,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl serde::Serialize for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4120,49 +3322,49 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. -/// One of `inclusive`, `exclusive`, or `unspecified`. +/// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. +/// The default value is `create_prorations`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceShippingCostShippingRateDataTaxBehavior { - Exclusive, - Inclusive, - Unspecified, +pub enum UpcomingLinesInvoiceSubscriptionProrationBehavior { + AlwaysInvoice, + CreateProrations, + None, } -impl CreateInvoiceShippingCostShippingRateDataTaxBehavior { +impl UpcomingLinesInvoiceSubscriptionProrationBehavior { pub fn as_str(self) -> &'static str { - use CreateInvoiceShippingCostShippingRateDataTaxBehavior::*; + use UpcomingLinesInvoiceSubscriptionProrationBehavior::*; match self { - Exclusive => "exclusive", - Inclusive => "inclusive", - Unspecified => "unspecified", + AlwaysInvoice => "always_invoice", + CreateProrations => "create_prorations", + None => "none", } } } -impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataTaxBehavior { +impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionProrationBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceShippingCostShippingRateDataTaxBehavior::*; + use UpcomingLinesInvoiceSubscriptionProrationBehavior::*; match s { - "exclusive" => Ok(Exclusive), - "inclusive" => Ok(Inclusive), - "unspecified" => Ok(Unspecified), + "always_invoice" => Ok(AlwaysInvoice), + "create_prorations" => Ok(CreateProrations), + "none" => Ok(None), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataTaxBehavior { +impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataTaxBehavior { +impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionProrationBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataTaxBehavior { +impl serde::Serialize for UpcomingLinesInvoiceSubscriptionProrationBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4170,42 +3372,42 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataTaxBehavior { serializer.serialize_str(self.as_str()) } } -/// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. +/// For paused subscriptions, setting `subscription_resume_at` to `now` will preview the invoice that will be generated if the subscription is resumed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceShippingCostShippingRateDataType { - FixedAmount, +pub enum UpcomingLinesInvoiceSubscriptionResumeAt { + Now, } -impl CreateInvoiceShippingCostShippingRateDataType { +impl UpcomingLinesInvoiceSubscriptionResumeAt { pub fn as_str(self) -> &'static str { - use CreateInvoiceShippingCostShippingRateDataType::*; + use UpcomingLinesInvoiceSubscriptionResumeAt::*; match self { - FixedAmount => "fixed_amount", + Now => "now", } } } -impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataType { +impl std::str::FromStr for UpcomingLinesInvoiceSubscriptionResumeAt { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateInvoiceShippingCostShippingRateDataType::*; + use UpcomingLinesInvoiceSubscriptionResumeAt::*; match s { - "fixed_amount" => Ok(FixedAmount), + "now" => Ok(Now), _ => Err(()), } } } -impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataType { +impl std::fmt::Display for UpcomingLinesInvoiceSubscriptionResumeAt { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataType { +impl std::fmt::Debug for UpcomingLinesInvoiceSubscriptionResumeAt { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataType { +impl serde::Serialize for UpcomingLinesInvoiceSubscriptionResumeAt { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4213,15 +3415,26 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataType { serializer.serialize_str(self.as_str()) } } -impl<'a> CreateInvoice<'a> { - /// This endpoint creates a draft invoice for a given customer. - /// The invoice remains a draft until you [finalize](https://stripe.com/docs/api#finalize_invoice) the invoice, which allows you to [pay](https://stripe.com/docs/api#pay_invoice) or [send](https://stripe.com/docs/api#send_invoice) the invoice to your customers. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Invoice> { - client.send_form("/invoices", self, http_types::Method::Post) +/// If provided, the invoice returned will preview updating or creating a subscription with that trial end. +/// If set, one of `subscription_items` or `subscription` is required. +#[derive(Copy, Clone, Debug, serde::Serialize)] +#[serde(untagged)] +pub enum UpcomingLinesInvoiceSubscriptionTrialEnd { + Now, + Timestamp(stripe_types::Timestamp), +} +impl<'a> UpcomingLinesInvoice<'a> { + /// When retrieving an upcoming invoice, you’ll get a **lines** property containing the total count of line items and the first handful of those items. + /// There is also a URL where you can retrieve the full (paginated) list of line items. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::InvoiceLineItem>> { + client.get_query("/invoices/upcoming/lines", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::InvoiceLineItem>> { + stripe::ListPaginator::from_list_params("/invoices/upcoming/lines", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoice<'a> { +pub struct CreateInvoice<'a> { /// The account tax IDs associated with the invoice. Only editable when the invoice is a draft. #[serde(skip_serializing_if = "Option::is_none")] pub account_tax_ids: Option<&'a [&'a str]>, @@ -4231,23 +3444,29 @@ pub struct UpdateInvoice<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub application_fee_amount: Option<i64>, /// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. + /// If `false`, the invoice's state doesn't automatically advance without an explicit action. #[serde(skip_serializing_if = "Option::is_none")] pub auto_advance: Option<bool>, /// Settings for automatic tax lookup for this invoice. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpdateInvoiceAutomaticTax<'a>>, - /// Either `charge_automatically` or `send_invoice`. - /// This field can be updated only on `draft` invoices. + pub automatic_tax: Option<AutomaticTaxParam>, + /// Either `charge_automatically`, or `send_invoice`. + /// When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. + /// When sending an invoice, Stripe will email this invoice to the customer with payment instructions. + /// Defaults to `charge_automatically`. #[serde(skip_serializing_if = "Option::is_none")] pub collection_method: Option<stripe_shared::InvoiceCollectionMethod>, + /// The currency to create this invoice in. Defaults to that of `customer` if not specified. + #[serde(skip_serializing_if = "Option::is_none")] + pub currency: Option<stripe_types::Currency>, /// A list of up to 4 custom fields to be displayed on the invoice. - /// If a value for `custom_fields` is specified, the list specified will replace the existing custom field list on this invoice. - /// Pass an empty string to remove previously-defined fields. #[serde(skip_serializing_if = "Option::is_none")] pub custom_fields: Option<&'a [CustomFieldParams<'a>]>, - /// The number of days from which the invoice is created until it is due. - /// Only valid for invoices where `collection_method=send_invoice`. - /// This field can only be updated on `draft` invoices. + /// The ID of the customer who will be billed. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// The number of days from when the invoice is created until it is due. + /// Valid only for invoices where `collection_method=send_invoice`. #[serde(skip_serializing_if = "Option::is_none")] pub days_until_due: Option<u32>, /// ID of the default payment method for the invoice. @@ -4261,7 +3480,6 @@ pub struct UpdateInvoice<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub default_source: Option<&'a str>, /// The tax rates that will apply to any line item that does not have `tax_rates` set. - /// Pass an empty string to remove previously-defined tax rates. #[serde(skip_serializing_if = "Option::is_none")] pub default_tax_rates: Option<&'a [&'a str]>, /// An arbitrary string attached to the object. @@ -4269,13 +3487,13 @@ pub struct UpdateInvoice<'a> { /// Referenced as 'memo' in the Dashboard. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<&'a str>, - /// The discounts that will apply to the invoice. - /// Pass an empty string to remove previously-defined discounts. + /// The coupons to redeem into discounts for the invoice. + /// If not specified, inherits the discount from the invoice's customer. + /// Pass an empty string to avoid inheriting any discounts. #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: Option<&'a [UpdateInvoiceDiscounts<'a>]>, + pub discounts: Option<&'a [DiscountsDataParam<'a>]>, /// The date on which payment for this invoice is due. - /// Only valid for invoices where `collection_method=send_invoice`. - /// This field can only be updated on `draft` invoices. + /// Valid only for invoices where `collection_method=send_invoice`. #[serde(skip_serializing_if = "Option::is_none")] pub due_date: Option<stripe_types::Timestamp>, /// The date when this invoice is in effect. @@ -4289,10 +3507,11 @@ pub struct UpdateInvoice<'a> { /// Footer to be displayed on the invoice. #[serde(skip_serializing_if = "Option::is_none")] pub footer: Option<&'a str>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. + /// Revise an existing invoice. + /// The new invoice will be created in `status=draft`. + /// See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpdateInvoiceIssuer<'a>>, + pub from_invoice: Option<CreateInvoiceFromInvoice<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -4306,18 +3525,25 @@ pub struct UpdateInvoice<'a> { pub on_behalf_of: Option<&'a str>, /// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_settings: Option<UpdateInvoicePaymentSettings<'a>>, + pub payment_settings: Option<CreateInvoicePaymentSettings<'a>>, + /// How to handle pending invoice items on invoice creation. + /// One of `include` or `exclude`. + /// `include` will include any pending invoice items, and will create an empty draft invoice if no pending invoice items exist. + /// `exclude` will always create an empty invoice draft regardless if there are pending invoice items or not. + /// Defaults to `exclude` if the parameter is omitted. + #[serde(skip_serializing_if = "Option::is_none")] + pub pending_invoice_items_behavior: Option<CreateInvoicePendingInvoiceItemsBehavior>, /// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page. #[serde(skip_serializing_if = "Option::is_none")] - pub rendering: Option<UpdateInvoiceRendering>, + pub rendering: Option<CreateInvoiceRendering>, /// This is a legacy field that will be removed soon. /// For details about `rendering_options`, refer to `rendering` instead. /// Options for invoice PDF rendering. #[serde(skip_serializing_if = "Option::is_none")] - pub rendering_options: Option<UpdateInvoiceRenderingOptions>, + pub rendering_options: Option<CreateInvoiceRenderingOptions>, /// Settings for the cost of shipping for this invoice. #[serde(skip_serializing_if = "Option::is_none")] - pub shipping_cost: Option<UpdateInvoiceShippingCost<'a>>, + pub shipping_cost: Option<CreateInvoiceShippingCost<'a>>, /// Shipping details for the invoice. /// The Invoice PDF will use the `shipping_details` value if it is set, otherwise the PDF will render the shipping address from the customer. #[serde(skip_serializing_if = "Option::is_none")] @@ -4327,167 +3553,73 @@ pub struct UpdateInvoice<'a> { /// If not specified and this invoice is part of a subscription, the default `statement_descriptor` will be set to the first subscription item's product's `statement_descriptor`. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, + /// The ID of the subscription to invoice, if any. + /// If set, the created invoice will only include pending invoice items for that subscription. + /// The subscription's billing cycle and regular subscription events won't be affected. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription: Option<&'a str>, /// If specified, the funds from the invoice will be transferred to the destination and the ID of the resulting transfer will be found on the invoice's charge. - /// This will be unset if you POST an empty value. #[serde(skip_serializing_if = "Option::is_none")] pub transfer_data: Option<TransferDataSpecs<'a>>, } -impl<'a> UpdateInvoice<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Settings for automatic tax lookup for this invoice. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceAutomaticTax<'a> { - /// Whether Stripe automatically computes tax on this invoice. - /// Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpdateInvoiceAutomaticTaxLiability<'a>>, -} -impl<'a> UpdateInvoiceAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateInvoiceAutomaticTaxLiabilityType, -} -impl<'a> UpdateInvoiceAutomaticTaxLiability<'a> { - pub fn new(type_: UpdateInvoiceAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceAutomaticTaxLiabilityType { - Account, - Self_, -} -impl UpdateInvoiceAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use UpdateInvoiceAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateInvoiceAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateInvoiceAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateInvoiceAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateInvoiceAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The discounts that will apply to the invoice. -/// Pass an empty string to remove previously-defined discounts. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceDiscounts<'a> { - /// ID of the coupon to create a new discount for. - #[serde(skip_serializing_if = "Option::is_none")] - pub coupon: Option<&'a str>, - /// ID of an existing discount on the object (or one of its ancestors) to reuse. - #[serde(skip_serializing_if = "Option::is_none")] - pub discount: Option<&'a str>, -} -impl<'a> UpdateInvoiceDiscounts<'a> { +impl<'a> CreateInvoice<'a> { pub fn new() -> Self { Self::default() } } -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. +/// Revise an existing invoice. +/// The new invoice will be created in `status=draft`. +/// See the [revision documentation](https://stripe.com/docs/invoicing/invoice-revisions) for more details. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateInvoiceIssuerType, +pub struct CreateInvoiceFromInvoice<'a> { + /// The relation between the new invoice and the original invoice. + /// Currently, only 'revision' is permitted. + pub action: CreateInvoiceFromInvoiceAction, + /// The `id` of the invoice that will be cloned. + pub invoice: &'a str, } -impl<'a> UpdateInvoiceIssuer<'a> { - pub fn new(type_: UpdateInvoiceIssuerType) -> Self { - Self { account: None, type_ } +impl<'a> CreateInvoiceFromInvoice<'a> { + pub fn new(action: CreateInvoiceFromInvoiceAction, invoice: &'a str) -> Self { + Self { action, invoice } } } -/// Type of the account referenced in the request. +/// The relation between the new invoice and the original invoice. +/// Currently, only 'revision' is permitted. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceIssuerType { - Account, - Self_, +pub enum CreateInvoiceFromInvoiceAction { + Revision, } -impl UpdateInvoiceIssuerType { +impl CreateInvoiceFromInvoiceAction { pub fn as_str(self) -> &'static str { - use UpdateInvoiceIssuerType::*; + use CreateInvoiceFromInvoiceAction::*; match self { - Account => "account", - Self_ => "self", + Revision => "revision", } } } -impl std::str::FromStr for UpdateInvoiceIssuerType { +impl std::str::FromStr for CreateInvoiceFromInvoiceAction { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceIssuerType::*; + use CreateInvoiceFromInvoiceAction::*; match s { - "account" => Ok(Account), - "self" => Ok(Self_), + "revision" => Ok(Revision), _ => Err(()), } } } -impl std::fmt::Display for UpdateInvoiceIssuerType { +impl std::fmt::Display for CreateInvoiceFromInvoiceAction { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceIssuerType { +impl std::fmt::Debug for CreateInvoiceFromInvoiceAction { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceIssuerType { +impl serde::Serialize for CreateInvoiceFromInvoiceAction { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4497,37 +3629,37 @@ impl serde::Serialize for UpdateInvoiceIssuerType { } /// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettings<'a> { +pub struct CreateInvoicePaymentSettings<'a> { /// ID of the mandate to be used for this invoice. /// It must correspond to the payment method used to pay the invoice, including the invoice's default_payment_method or default_source, if set. #[serde(skip_serializing_if = "Option::is_none")] pub default_mandate: Option<&'a str>, /// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method_options: Option<UpdateInvoicePaymentSettingsPaymentMethodOptions<'a>>, + pub payment_method_options: Option<CreateInvoicePaymentSettingsPaymentMethodOptions<'a>>, /// The list of payment method types (e.g. /// card) to provide to the invoice’s PaymentIntent. /// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method_types: Option<&'a [UpdateInvoicePaymentSettingsPaymentMethodTypes]>, + pub payment_method_types: Option<&'a [CreateInvoicePaymentSettingsPaymentMethodTypes]>, } -impl<'a> UpdateInvoicePaymentSettings<'a> { +impl<'a> CreateInvoicePaymentSettings<'a> { pub fn new() -> Self { Self::default() } } /// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptions<'a> { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptions<'a> { /// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub acss_debit: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit>, + pub acss_debit: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit>, /// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontact>, + pub bancontact: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsBancontact>, /// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub card: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCard>, + pub card: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCard>, /// If paying by `customer_balance`, this sub-hash contains details about the Bank transfer payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option<InvoicePaymentMethodOptionsParam<'a>>, @@ -4536,53 +3668,49 @@ pub struct UpdateInvoicePaymentSettingsPaymentMethodOptions<'a> { pub konbini: Option<&'a serde_json::Value>, /// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, + pub us_bank_account: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, } -impl<'a> UpdateInvoicePaymentSettingsPaymentMethodOptions<'a> { +impl<'a> CreateInvoicePaymentSettingsPaymentMethodOptions<'a> { pub fn new() -> Self { Self::default() } } /// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, + pub mandate_options: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebit { pub fn new() -> Self { Self::default() } } /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: Option< - UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType, - >, + pub transaction_type: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { pub fn new() -> Self { Self::default() } } /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { Business, Personal, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; match self { Business => "business", Personal => "personal", @@ -4590,12 +3718,10 @@ impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTran } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; match s { "business" => Ok(Business), "personal" => Ok(Personal), @@ -4603,24 +3729,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4630,14 +3750,14 @@ impl serde::Serialize } /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { Automatic, Instant, Microdeposits, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; match self { Automatic => "automatic", Instant => "instant", @@ -4646,12 +3766,10 @@ impl UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; match s { "automatic" => Ok(Automatic), "instant" => Ok(Instant), @@ -4660,24 +3778,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4687,28 +3799,27 @@ impl serde::Serialize } /// If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontact { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_language: - Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, + pub preferred_language: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontact { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsBancontact { pub fn new() -> Self { Self::default() } } /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { De, En, Fr, Nl, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; match self { De => "de", En => "en", @@ -4718,12 +3829,10 @@ impl UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; match s { "de" => Ok(De), "en" => Ok(En), @@ -4733,24 +3842,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4760,20 +3863,19 @@ impl serde::Serialize } /// If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsCard { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsCard { /// Installment configuration for payments attempted on this invoice (Mexico Only). /// /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). #[serde(skip_serializing_if = "Option::is_none")] - pub installments: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments>, + pub installments: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, + pub request_three_d_secure: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCard { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsCard { pub fn new() -> Self { Self::default() } @@ -4782,37 +3884,37 @@ impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCard { /// /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { /// Setting to true enables installments for this invoice. /// Setting to false will prevent any selected plan from applying to a payment. #[serde(skip_serializing_if = "Option::is_none")] pub enabled: Option<bool>, /// The selected installment plan to use for this invoice. #[serde(skip_serializing_if = "Option::is_none")] - pub plan: Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan>, + pub plan: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan>, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallments { pub fn new() -> Self { Self::default() } } /// The selected installment plan to use for this invoice. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { /// For `fixed_count` installment plans, this is the number of installment payments your customer will make to their credit card. pub count: u64, /// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card. /// One of `month`. - pub interval: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, + pub interval: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, /// Type of installment plan, one of `fixed_count`. - #[serde(rename = "type")] - pub type_: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { pub fn new( count: u64, - interval: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, - type_: UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, + interval: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval, + type_: CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType, ) -> Self { Self { count, interval, type_ } } @@ -4820,48 +3922,40 @@ impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlan { /// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card. /// One of `month`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { Month, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; match self { Month => "month", } } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval::*; match s { "month" => Ok(Month), _ => Err(()), } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval -{ +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4871,44 +3965,40 @@ impl serde::Serialize } /// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { FixedCount, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; match self { FixedCount => "fixed_count", } } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType::*; match s { "fixed_count" => Ok(FixedCount), _ => Err(()), } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4920,46 +4010,43 @@ impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardIn /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } -impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } } -impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4969,36 +4056,32 @@ impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRe } /// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: Option< - UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>, - >, + pub financial_connections: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod>, } -impl<'a> UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { +impl<'a> CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { Self::default() } } /// Additional fields for Financial Connections Session creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { - /// The list of permissions to request. +pub struct CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { + /// The list of permissions to request. /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. -#[serde(skip_serializing_if = "Option::is_none")] -pub permissions: Option<&'a [UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, + #[serde(skip_serializing_if = "Option::is_none")] + pub permissions: Option<&'a [CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. -#[serde(skip_serializing_if = "Option::is_none")] -pub prefetch: Option<&'a [UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, - + #[serde(skip_serializing_if = "Option::is_none")] + pub prefetch: Option<&'a [CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, } -impl<'a> UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { +impl<'a> CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { pub fn new() -> Self { Self::default() } @@ -5007,16 +4090,15 @@ impl<'a> UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialC /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { Balances, Ownership, PaymentMethod, Transactions, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; match self { Balances => "balances", Ownership => "ownership", @@ -5026,12 +4108,10 @@ impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConne } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; match s { "balances" => Ok(Balances), "ownership" => Ok(Ownership), @@ -5041,24 +4121,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5068,51 +4142,40 @@ impl serde::Serialize } /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5122,14 +4185,14 @@ impl serde::Serialize } /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { +pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, Instant, Microdeposits, } -impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { +impl CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; match self { Automatic => "automatic", Instant => "instant", @@ -5138,12 +4201,10 @@ impl UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMe } } -impl std::str::FromStr - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; + use CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; match s { "automatic" => Ok(Automatic), "instant" => Ok(Instant), @@ -5152,24 +4213,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5182,7 +4237,7 @@ impl serde::Serialize /// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] -pub enum UpdateInvoicePaymentSettingsPaymentMethodTypes { +pub enum CreateInvoicePaymentSettingsPaymentMethodTypes { AchCreditTransfer, AchDebit, AcssDebit, @@ -5193,14 +4248,12 @@ pub enum UpdateInvoicePaymentSettingsPaymentMethodTypes { Card, Cashapp, CustomerBalance, - Eps, Fpx, Giropay, Grabpay, Ideal, Konbini, Link, - P24, Paynow, Paypal, Promptpay, @@ -5212,9 +4265,9 @@ pub enum UpdateInvoicePaymentSettingsPaymentMethodTypes { /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, } -impl UpdateInvoicePaymentSettingsPaymentMethodTypes { +impl CreateInvoicePaymentSettingsPaymentMethodTypes { pub fn as_str(self) -> &'static str { - use UpdateInvoicePaymentSettingsPaymentMethodTypes::*; + use CreateInvoicePaymentSettingsPaymentMethodTypes::*; match self { AchCreditTransfer => "ach_credit_transfer", AchDebit => "ach_debit", @@ -5226,14 +4279,12 @@ impl UpdateInvoicePaymentSettingsPaymentMethodTypes { Card => "card", Cashapp => "cashapp", CustomerBalance => "customer_balance", - Eps => "eps", Fpx => "fpx", Giropay => "giropay", Grabpay => "grabpay", Ideal => "ideal", Konbini => "konbini", Link => "link", - P24 => "p24", Paynow => "paynow", Paypal => "paypal", Promptpay => "promptpay", @@ -5247,10 +4298,10 @@ impl UpdateInvoicePaymentSettingsPaymentMethodTypes { } } -impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodTypes { +impl std::str::FromStr for CreateInvoicePaymentSettingsPaymentMethodTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoicePaymentSettingsPaymentMethodTypes::*; + use CreateInvoicePaymentSettingsPaymentMethodTypes::*; match s { "ach_credit_transfer" => Ok(AchCreditTransfer), "ach_debit" => Ok(AchDebit), @@ -5262,14 +4313,12 @@ impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodTypes { "card" => Ok(Card), "cashapp" => Ok(Cashapp), "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), "fpx" => Ok(Fpx), "giropay" => Ok(Giropay), "grabpay" => Ok(Grabpay), "ideal" => Ok(Ideal), "konbini" => Ok(Konbini), "link" => Ok(Link), - "p24" => Ok(P24), "paynow" => Ok(Paynow), "paypal" => Ok(Paypal), "promptpay" => Ok(Promptpay), @@ -5282,18 +4331,71 @@ impl std::str::FromStr for UpdateInvoicePaymentSettingsPaymentMethodTypes { } } } -impl std::fmt::Display for UpdateInvoicePaymentSettingsPaymentMethodTypes { +impl std::fmt::Display for CreateInvoicePaymentSettingsPaymentMethodTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoicePaymentSettingsPaymentMethodTypes { +impl std::fmt::Debug for CreateInvoicePaymentSettingsPaymentMethodTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodTypes { +impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodTypes { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +/// How to handle pending invoice items on invoice creation. +/// One of `include` or `exclude`. +/// `include` will include any pending invoice items, and will create an empty draft invoice if no pending invoice items exist. +/// `exclude` will always create an empty invoice draft regardless if there are pending invoice items or not. +/// Defaults to `exclude` if the parameter is omitted. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CreateInvoicePendingInvoiceItemsBehavior { + Exclude, + Include, + IncludeAndRequire, +} +impl CreateInvoicePendingInvoiceItemsBehavior { + pub fn as_str(self) -> &'static str { + use CreateInvoicePendingInvoiceItemsBehavior::*; + match self { + Exclude => "exclude", + Include => "include", + IncludeAndRequire => "include_and_require", + } + } +} + +impl std::str::FromStr for CreateInvoicePendingInvoiceItemsBehavior { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use CreateInvoicePendingInvoiceItemsBehavior::*; + match s { + "exclude" => Ok(Exclude), + "include" => Ok(Include), + "include_and_require" => Ok(IncludeAndRequire), + _ => Err(()), + } + } +} +impl std::fmt::Display for CreateInvoicePendingInvoiceItemsBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CreateInvoicePendingInvoiceItemsBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for CreateInvoicePendingInvoiceItemsBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5303,18 +4405,18 @@ impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodTypes { } /// The rendering-related settings that control how the invoice is displayed on customer-facing surfaces such as PDF and Hosted Invoice Page. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceRendering { +pub struct CreateInvoiceRendering { /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. /// One of `exclude_tax` or `include_inclusive_tax`. /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: Option<UpdateInvoiceRenderingAmountTaxDisplay>, + pub amount_tax_display: Option<CreateInvoiceRenderingAmountTaxDisplay>, /// Invoice pdf rendering options #[serde(skip_serializing_if = "Option::is_none")] - pub pdf: Option<UpdateInvoiceRenderingPdf>, + pub pdf: Option<CreateInvoiceRenderingPdf>, } -impl UpdateInvoiceRendering { +impl CreateInvoiceRendering { pub fn new() -> Self { Self::default() } @@ -5324,13 +4426,13 @@ impl UpdateInvoiceRendering { /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceRenderingAmountTaxDisplay { +pub enum CreateInvoiceRenderingAmountTaxDisplay { ExcludeTax, IncludeInclusiveTax, } -impl UpdateInvoiceRenderingAmountTaxDisplay { +impl CreateInvoiceRenderingAmountTaxDisplay { pub fn as_str(self) -> &'static str { - use UpdateInvoiceRenderingAmountTaxDisplay::*; + use CreateInvoiceRenderingAmountTaxDisplay::*; match self { ExcludeTax => "exclude_tax", IncludeInclusiveTax => "include_inclusive_tax", @@ -5338,10 +4440,10 @@ impl UpdateInvoiceRenderingAmountTaxDisplay { } } -impl std::str::FromStr for UpdateInvoiceRenderingAmountTaxDisplay { +impl std::str::FromStr for CreateInvoiceRenderingAmountTaxDisplay { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceRenderingAmountTaxDisplay::*; + use CreateInvoiceRenderingAmountTaxDisplay::*; match s { "exclude_tax" => Ok(ExcludeTax), "include_inclusive_tax" => Ok(IncludeInclusiveTax), @@ -5349,18 +4451,18 @@ impl std::str::FromStr for UpdateInvoiceRenderingAmountTaxDisplay { } } } -impl std::fmt::Display for UpdateInvoiceRenderingAmountTaxDisplay { +impl std::fmt::Display for CreateInvoiceRenderingAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceRenderingAmountTaxDisplay { +impl std::fmt::Debug for CreateInvoiceRenderingAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceRenderingAmountTaxDisplay { +impl serde::Serialize for CreateInvoiceRenderingAmountTaxDisplay { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5370,14 +4472,14 @@ impl serde::Serialize for UpdateInvoiceRenderingAmountTaxDisplay { } /// Invoice pdf rendering options #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceRenderingPdf { +pub struct CreateInvoiceRenderingPdf { /// Page size for invoice PDF. Can be set to `a4`, `letter`, or `auto`. /// If set to `auto`, invoice PDF page size defaults to `a4` for customers with /// Japanese locale and `letter` for customers with other locales. #[serde(skip_serializing_if = "Option::is_none")] - pub page_size: Option<UpdateInvoiceRenderingPdfPageSize>, + pub page_size: Option<CreateInvoiceRenderingPdfPageSize>, } -impl UpdateInvoiceRenderingPdf { +impl CreateInvoiceRenderingPdf { pub fn new() -> Self { Self::default() } @@ -5386,14 +4488,14 @@ impl UpdateInvoiceRenderingPdf { /// If set to `auto`, invoice PDF page size defaults to `a4` for customers with /// Japanese locale and `letter` for customers with other locales. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceRenderingPdfPageSize { +pub enum CreateInvoiceRenderingPdfPageSize { A4, Auto, Letter, } -impl UpdateInvoiceRenderingPdfPageSize { +impl CreateInvoiceRenderingPdfPageSize { pub fn as_str(self) -> &'static str { - use UpdateInvoiceRenderingPdfPageSize::*; + use CreateInvoiceRenderingPdfPageSize::*; match self { A4 => "a4", Auto => "auto", @@ -5402,10 +4504,10 @@ impl UpdateInvoiceRenderingPdfPageSize { } } -impl std::str::FromStr for UpdateInvoiceRenderingPdfPageSize { +impl std::str::FromStr for CreateInvoiceRenderingPdfPageSize { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceRenderingPdfPageSize::*; + use CreateInvoiceRenderingPdfPageSize::*; match s { "a4" => Ok(A4), "auto" => Ok(Auto), @@ -5414,18 +4516,18 @@ impl std::str::FromStr for UpdateInvoiceRenderingPdfPageSize { } } } -impl std::fmt::Display for UpdateInvoiceRenderingPdfPageSize { +impl std::fmt::Display for CreateInvoiceRenderingPdfPageSize { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceRenderingPdfPageSize { +impl std::fmt::Debug for CreateInvoiceRenderingPdfPageSize { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceRenderingPdfPageSize { +impl serde::Serialize for CreateInvoiceRenderingPdfPageSize { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5437,15 +4539,15 @@ impl serde::Serialize for UpdateInvoiceRenderingPdfPageSize { /// For details about `rendering_options`, refer to `rendering` instead. /// Options for invoice PDF rendering. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceRenderingOptions { +pub struct CreateInvoiceRenderingOptions { /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. /// One of `exclude_tax` or `include_inclusive_tax`. /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: Option<UpdateInvoiceRenderingOptionsAmountTaxDisplay>, + pub amount_tax_display: Option<CreateInvoiceRenderingOptionsAmountTaxDisplay>, } -impl UpdateInvoiceRenderingOptions { +impl CreateInvoiceRenderingOptions { pub fn new() -> Self { Self::default() } @@ -5455,13 +4557,13 @@ impl UpdateInvoiceRenderingOptions { /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceRenderingOptionsAmountTaxDisplay { +pub enum CreateInvoiceRenderingOptionsAmountTaxDisplay { ExcludeTax, IncludeInclusiveTax, } -impl UpdateInvoiceRenderingOptionsAmountTaxDisplay { +impl CreateInvoiceRenderingOptionsAmountTaxDisplay { pub fn as_str(self) -> &'static str { - use UpdateInvoiceRenderingOptionsAmountTaxDisplay::*; + use CreateInvoiceRenderingOptionsAmountTaxDisplay::*; match self { ExcludeTax => "exclude_tax", IncludeInclusiveTax => "include_inclusive_tax", @@ -5469,10 +4571,10 @@ impl UpdateInvoiceRenderingOptionsAmountTaxDisplay { } } -impl std::str::FromStr for UpdateInvoiceRenderingOptionsAmountTaxDisplay { +impl std::str::FromStr for CreateInvoiceRenderingOptionsAmountTaxDisplay { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceRenderingOptionsAmountTaxDisplay::*; + use CreateInvoiceRenderingOptionsAmountTaxDisplay::*; match s { "exclude_tax" => Ok(ExcludeTax), "include_inclusive_tax" => Ok(IncludeInclusiveTax), @@ -5480,18 +4582,18 @@ impl std::str::FromStr for UpdateInvoiceRenderingOptionsAmountTaxDisplay { } } } -impl std::fmt::Display for UpdateInvoiceRenderingOptionsAmountTaxDisplay { +impl std::fmt::Display for CreateInvoiceRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceRenderingOptionsAmountTaxDisplay { +impl std::fmt::Debug for CreateInvoiceRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceRenderingOptionsAmountTaxDisplay { +impl serde::Serialize for CreateInvoiceRenderingOptionsAmountTaxDisplay { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5501,32 +4603,32 @@ impl serde::Serialize for UpdateInvoiceRenderingOptionsAmountTaxDisplay { } /// Settings for the cost of shipping for this invoice. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceShippingCost<'a> { +pub struct CreateInvoiceShippingCost<'a> { /// The ID of the shipping rate to use for this order. #[serde(skip_serializing_if = "Option::is_none")] pub shipping_rate: Option<&'a str>, /// Parameters to create a new ad-hoc shipping rate for this order. #[serde(skip_serializing_if = "Option::is_none")] - pub shipping_rate_data: Option<UpdateInvoiceShippingCostShippingRateData<'a>>, + pub shipping_rate_data: Option<CreateInvoiceShippingCostShippingRateData<'a>>, } -impl<'a> UpdateInvoiceShippingCost<'a> { +impl<'a> CreateInvoiceShippingCost<'a> { pub fn new() -> Self { Self::default() } } /// Parameters to create a new ad-hoc shipping rate for this order. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceShippingCostShippingRateData<'a> { +pub struct CreateInvoiceShippingCostShippingRateData<'a> { /// The estimated range for how long shipping will take, meant to be displayable to the customer. /// This will appear on CheckoutSessions. #[serde(skip_serializing_if = "Option::is_none")] - pub delivery_estimate: Option<UpdateInvoiceShippingCostShippingRateDataDeliveryEstimate>, + pub delivery_estimate: Option<CreateInvoiceShippingCostShippingRateDataDeliveryEstimate>, /// The name of the shipping rate, meant to be displayable to the customer. /// This will appear on CheckoutSessions. pub display_name: &'a str, /// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. #[serde(skip_serializing_if = "Option::is_none")] - pub fixed_amount: Option<UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a>>, + pub fixed_amount: Option<CreateInvoiceShippingCostShippingRateDataFixedAmount<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -5536,73 +4638,62 @@ pub struct UpdateInvoiceShippingCostShippingRateData<'a> { /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option<UpdateInvoiceShippingCostShippingRateDataTaxBehavior>, + pub tax_behavior: Option<CreateInvoiceShippingCostShippingRateDataTaxBehavior>, /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. /// The Shipping tax code is `txcd_92010001`. #[serde(skip_serializing_if = "Option::is_none")] pub tax_code: Option<&'a str>, /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] - pub type_: Option<UpdateInvoiceShippingCostShippingRateDataType>, + pub type_: Option<CreateInvoiceShippingCostShippingRateDataType>, } -impl<'a> UpdateInvoiceShippingCostShippingRateData<'a> { +impl<'a> CreateInvoiceShippingCostShippingRateData<'a> { pub fn new(display_name: &'a str) -> Self { - Self { - delivery_estimate: None, - display_name, - fixed_amount: None, - metadata: None, - tax_behavior: None, - tax_code: None, - type_: None, - } + Self { delivery_estimate: None, display_name, fixed_amount: None, metadata: None, tax_behavior: None, tax_code: None, type_: None } } } /// The estimated range for how long shipping will take, meant to be displayable to the customer. /// This will appear on CheckoutSessions. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceShippingCostShippingRateDataDeliveryEstimate { +pub struct CreateInvoiceShippingCostShippingRateDataDeliveryEstimate { /// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. #[serde(skip_serializing_if = "Option::is_none")] - pub maximum: Option<UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum>, + pub maximum: Option<CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum>, /// The lower bound of the estimated range. If empty, represents no lower bound. #[serde(skip_serializing_if = "Option::is_none")] - pub minimum: Option<UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum>, + pub minimum: Option<CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum>, } -impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimate { +impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimate { pub fn new() -> Self { Self::default() } } /// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { +pub struct CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { /// A unit of time. - pub unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, + pub unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, /// Must be greater than 0. pub value: i64, } -impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { - pub fn new( - unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, - value: i64, - ) -> Self { +impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximum { + pub fn new(unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit, value: i64) -> Self { Self { unit, value } } } /// A unit of time. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +pub enum CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { BusinessDay, Day, Hour, Month, Week, } -impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { pub fn as_str(self) -> &'static str { - use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; + use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; match self { BusinessDay => "business_day", Day => "day", @@ -5613,10 +4704,10 @@ impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { } } -impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; + use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit::*; match s { "business_day" => Ok(BusinessDay), "day" => Ok(Day), @@ -5627,18 +4718,18 @@ impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataDeliveryEsti } } } -impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { +impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5648,32 +4739,29 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstim } /// The lower bound of the estimated range. If empty, represents no lower bound. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { +pub struct CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { /// A unit of time. - pub unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, + pub unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, /// Must be greater than 0. pub value: i64, } -impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { - pub fn new( - unit: UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, - value: i64, - ) -> Self { +impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { + pub fn new(unit: CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit, value: i64) -> Self { Self { unit, value } } } /// A unit of time. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +pub enum CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { BusinessDay, Day, Hour, Month, Week, } -impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { pub fn as_str(self) -> &'static str { - use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; + use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; match self { BusinessDay => "business_day", Day => "day", @@ -5684,10 +4772,10 @@ impl UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { } } -impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; + use CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit::*; match s { "business_day" => Ok(BusinessDay), "day" => Ok(Day), @@ -5698,18 +4786,18 @@ impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataDeliveryEsti } } } -impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { +impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5719,7 +4807,7 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstim } /// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a> { +pub struct CreateInvoiceShippingCostShippingRateDataFixedAmount<'a> { /// A non-negative integer in cents representing how much to charge. pub amount: i64, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. @@ -5728,14 +4816,9 @@ pub struct UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a> { /// Shipping rates defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - &'a std::collections::HashMap< - stripe_types::Currency, - UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions, - >, - >, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions>>, } -impl<'a> UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a> { +impl<'a> CreateInvoiceShippingCostShippingRateDataFixedAmount<'a> { pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { Self { amount, currency, currency_options: None } } @@ -5743,16 +4826,15 @@ impl<'a> UpdateInvoiceShippingCostShippingRateDataFixedAmount<'a> { /// Shipping rates defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { +pub struct CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { /// A non-negative integer in cents representing how much to charge. pub amount: i64, /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: - Option<UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior>, + pub tax_behavior: Option<CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior>, } -impl UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { +impl CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { pub fn new(amount: i64) -> Self { Self { amount, tax_behavior: None } } @@ -5760,14 +4842,14 @@ impl UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptions { /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { +pub enum CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { +impl CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { pub fn as_str(self) -> &'static str { - use UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; + use CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -5776,12 +4858,10 @@ impl UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehav } } -impl std::str::FromStr - for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; + use CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -5790,24 +4870,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5818,14 +4892,14 @@ impl serde::Serialize /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceShippingCostShippingRateDataTaxBehavior { +pub enum CreateInvoiceShippingCostShippingRateDataTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl UpdateInvoiceShippingCostShippingRateDataTaxBehavior { +impl CreateInvoiceShippingCostShippingRateDataTaxBehavior { pub fn as_str(self) -> &'static str { - use UpdateInvoiceShippingCostShippingRateDataTaxBehavior::*; + use CreateInvoiceShippingCostShippingRateDataTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -5834,10 +4908,10 @@ impl UpdateInvoiceShippingCostShippingRateDataTaxBehavior { } } -impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { +impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataTaxBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceShippingCostShippingRateDataTaxBehavior::*; + use CreateInvoiceShippingCostShippingRateDataTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -5846,18 +4920,18 @@ impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataTaxBehavior } } } -impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { +impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { +impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { +impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataTaxBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5867,40 +4941,40 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { } /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceShippingCostShippingRateDataType { +pub enum CreateInvoiceShippingCostShippingRateDataType { FixedAmount, } -impl UpdateInvoiceShippingCostShippingRateDataType { +impl CreateInvoiceShippingCostShippingRateDataType { pub fn as_str(self) -> &'static str { - use UpdateInvoiceShippingCostShippingRateDataType::*; + use CreateInvoiceShippingCostShippingRateDataType::*; match self { FixedAmount => "fixed_amount", } } } -impl std::str::FromStr for UpdateInvoiceShippingCostShippingRateDataType { +impl std::str::FromStr for CreateInvoiceShippingCostShippingRateDataType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateInvoiceShippingCostShippingRateDataType::*; + use CreateInvoiceShippingCostShippingRateDataType::*; match s { "fixed_amount" => Ok(FixedAmount), _ => Err(()), } } } -impl std::fmt::Display for UpdateInvoiceShippingCostShippingRateDataType { +impl std::fmt::Display for CreateInvoiceShippingCostShippingRateDataType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceShippingCostShippingRateDataType { +impl std::fmt::Debug for CreateInvoiceShippingCostShippingRateDataType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataType { +impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5908,123 +4982,117 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataType { serializer.serialize_str(self.as_str()) } } -impl<'a> UpdateInvoice<'a> { - /// Draft invoices are fully editable. - /// Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized),. - /// monetary values, as well as `collection_method`, become uneditable. - /// - /// If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on,. - /// sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass. - /// `auto_advance=false`. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::Invoice> { - client.send_form(&format!("/invoices/{invoice}"), self, http_types::Method::Post) +impl<'a> CreateInvoice<'a> { + /// This endpoint creates a draft invoice for a given customer. + /// The invoice remains a draft until you [finalize](https://stripe.com/docs/api#finalize_invoice) the invoice, which allows you to [pay](https://stripe.com/docs/api#pay_invoice) or [send](https://stripe.com/docs/api#send_invoice) the invoice to your customers. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Invoice> { + client.send_form("/invoices", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct FinalizeInvoiceInvoice<'a> { - /// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. - /// If `false`, the invoice's state doesn't automatically advance without an explicit action. +pub struct ListInvoice<'a> { + /// The collection method of the invoice to retrieve. Either `charge_automatically` or `send_invoice`. #[serde(skip_serializing_if = "Option::is_none")] - pub auto_advance: Option<bool>, + pub collection_method: Option<stripe_shared::InvoiceCollectionMethod>, + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// Only return invoices for the customer specified by this customer ID. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + #[serde(skip_serializing_if = "Option::is_none")] + pub due_date: Option<stripe_types::RangeQueryTs>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// The status of the invoice, one of `draft`, `open`, `paid`, `uncollectible`, or `void`. + /// [Learn more](https://stripe.com/docs/billing/invoices/workflow#workflow-overview). + #[serde(skip_serializing_if = "Option::is_none")] + pub status: Option<stripe_shared::InvoiceStatus>, + /// Only return invoices for the subscription specified by this subscription ID. + #[serde(skip_serializing_if = "Option::is_none")] + pub subscription: Option<&'a str>, } -impl<'a> FinalizeInvoiceInvoice<'a> { +impl<'a> ListInvoice<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> FinalizeInvoiceInvoice<'a> { - /// Stripe automatically finalizes drafts before sending and attempting payment on invoices. - /// However, if you’d like to finalize a draft invoice manually, you can do so using this method. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::Invoice> { - client.send_form(&format!("/invoices/{invoice}/finalize"), self, http_types::Method::Post) +impl<'a> ListInvoice<'a> { + /// You can list all invoices, or list the invoices for a specific customer. + /// The invoices are returned sorted by creation date, with the most recently created invoices appearing first. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Invoice>> { + client.get_query("/invoices", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Invoice>> { + stripe::ListPaginator::from_list_params("/invoices", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct MarkUncollectibleInvoice<'a> { +pub struct RetrieveInvoice<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> MarkUncollectibleInvoice<'a> { +impl<'a> RetrieveInvoice<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> MarkUncollectibleInvoice<'a> { - /// Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::Invoice> { - client.send_form( - &format!("/invoices/{invoice}/mark_uncollectible"), - self, - http_types::Method::Post, - ) +impl<'a> RetrieveInvoice<'a> { + /// Retrieves the invoice with the given ID. + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::Invoice> { + client.get_query(&format!("/invoices/{invoice}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct PayInvoice<'a> { +pub struct DeleteInvoice {} +impl DeleteInvoice { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteInvoice { + /// Permanently deletes a one-off invoice draft. + /// This cannot be undone. + /// Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::DeletedInvoice> { + client.send_form(&format!("/invoices/{invoice}"), self, http_types::Method::Delete) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct FinalizeInvoiceInvoice<'a> { + /// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. + /// If `false`, the invoice's state doesn't automatically advance without an explicit action. + #[serde(skip_serializing_if = "Option::is_none")] + pub auto_advance: Option<bool>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// In cases where the source used to pay the invoice has insufficient funds, passing `forgive=true` controls whether a charge should be attempted for the full amount available on the source, up to the amount to fully pay the invoice. - /// This effectively forgives the difference between the amount available on the source and the amount due. - /// - /// - /// Passing `forgive=false` will fail the charge if the source hasn't been pre-funded with the right amount. - /// An example for this case is with ACH Credit Transfers and wires: if the amount wired is less than the amount due by a small amount, you might want to forgive the difference. - /// Defaults to `false`. - #[serde(skip_serializing_if = "Option::is_none")] - pub forgive: Option<bool>, - /// ID of the mandate to be used for this invoice. - /// It must correspond to the payment method used to pay the invoice, including the payment_method param or the invoice's default_payment_method or default_source, if set. - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate: Option<&'a str>, - /// Indicates if a customer is on or off-session while an invoice payment is attempted. - /// Defaults to `true` (off-session). - #[serde(skip_serializing_if = "Option::is_none")] - pub off_session: Option<bool>, - /// Boolean representing whether an invoice is paid outside of Stripe. - /// This will result in no charge being made. - /// Defaults to `false`. - #[serde(skip_serializing_if = "Option::is_none")] - pub paid_out_of_band: Option<bool>, - /// A PaymentMethod to be charged. - /// The PaymentMethod must be the ID of a PaymentMethod belonging to the customer associated with the invoice being paid. - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method: Option<&'a str>, - /// A payment source to be charged. - /// The source must be the ID of a source belonging to the customer associated with the invoice being paid. - #[serde(skip_serializing_if = "Option::is_none")] - pub source: Option<&'a str>, } -impl<'a> PayInvoice<'a> { +impl<'a> FinalizeInvoiceInvoice<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> PayInvoice<'a> { - /// Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). - /// However, if you’d like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::Invoice> { - client.send_form(&format!("/invoices/{invoice}/pay"), self, http_types::Method::Post) +impl<'a> FinalizeInvoiceInvoice<'a> { + /// Stripe automatically finalizes drafts before sending and attempting payment on invoices. + /// However, if you’d like to finalize a draft invoice manually, you can do so using this method. + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::Invoice> { + client.send_form(&format!("/invoices/{invoice}/finalize"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -6044,15 +5112,28 @@ impl<'a> SendInvoiceInvoice<'a> { /// When sending invoices that have already been paid, there will be no reference to the payment in the email. /// /// Requests made in test-mode result in no emails being sent, despite sending an `invoice.sent` event. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::Invoice> { + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::Invoice> { client.send_form(&format!("/invoices/{invoice}/send"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct MarkUncollectibleInvoice<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> MarkUncollectibleInvoice<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> MarkUncollectibleInvoice<'a> { + /// Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::Invoice> { + client.send_form(&format!("/invoices/{invoice}/mark_uncollectible"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct VoidInvoiceInvoice<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -6067,14 +5148,21 @@ impl<'a> VoidInvoiceInvoice<'a> { /// Mark a finalized invoice as void. /// This cannot be undone. /// Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_shared::Invoice> { + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_shared::Invoice> { client.send_form(&format!("/invoices/{invoice}/void"), self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct AutomaticTaxParam { + /// Whether Stripe automatically computes tax on this invoice. + /// Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. + pub enabled: bool, +} +impl AutomaticTaxParam { + pub fn new(enabled: bool) -> Self { + Self { enabled } + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct OptionalFieldsAddress<'a> { /// City, district, suburb, town, or village. @@ -6122,9 +5210,6 @@ pub struct DiscountsDataParam<'a> { /// ID of an existing discount on the object (or one of its ancestors) to reuse. #[serde(skip_serializing_if = "Option::is_none")] pub discount: Option<&'a str>, - /// ID of the promotion code to create a new discount for. - #[serde(skip_serializing_if = "Option::is_none")] - pub promotion_code: Option<&'a str>, } impl<'a> DiscountsDataParam<'a> { pub fn new() -> Self { @@ -6212,7 +5297,7 @@ pub struct BankTransferParam<'a> { pub eu_bank_transfer: Option<EuBankTransferParam<'a>>, /// The bank transfer type that can be used for funding. /// Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<&'a str>, } diff --git a/generated/stripe_billing/src/invoice_item/requests.rs b/generated/stripe_billing/src/invoice_item/requests.rs index be135e7f6..624011068 100644 --- a/generated/stripe_billing/src/invoice_item/requests.rs +++ b/generated/stripe_billing/src/invoice_item/requests.rs @@ -1,22 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteInvoiceItem {} -impl DeleteInvoiceItem { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteInvoiceItem { - /// Deletes an invoice item, removing it from an invoice. - /// Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice. - pub fn send( - &self, - client: &stripe::Client, - invoiceitem: &stripe_shared::InvoiceItemId, - ) -> stripe::Response<stripe_shared::DeletedInvoiceitem> { - client.send_form(&format!("/invoiceitems/{invoiceitem}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListInvoiceItem<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub created: Option<stripe_types::RangeQueryTs>, @@ -60,37 +42,13 @@ impl<'a> ListInvoiceItem<'a> { impl<'a> ListInvoiceItem<'a> { /// Returns a list of your invoice items. /// Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::InvoiceItem>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::InvoiceItem>> { client.get_query("/invoiceitems", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::InvoiceItem>> { stripe::ListPaginator::from_list_params("/invoiceitems", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveInvoiceItem<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveInvoiceItem<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveInvoiceItem<'a> { - /// Retrieves the invoice item with the given ID. - pub fn send( - &self, - client: &stripe::Client, - invoiceitem: &stripe_shared::InvoiceItemId, - ) -> stripe::Response<stripe_shared::InvoiceItem> { - client.get_query(&format!("/invoiceitems/{invoiceitem}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateInvoiceItem<'a> { /// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. @@ -337,6 +295,23 @@ impl<'a> CreateInvoiceItem<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveInvoiceItem<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveInvoiceItem<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveInvoiceItem<'a> { + /// Retrieves the invoice item with the given ID. + pub fn send(&self, client: &stripe::Client, invoiceitem: &stripe_shared::InvoiceItemId) -> stripe::Response<stripe_shared::InvoiceItem> { + client.get_query(&format!("/invoiceitems/{invoiceitem}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateInvoiceItem<'a> { /// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. /// If you want to apply a credit to the customer's account, pass a negative amount. @@ -543,15 +518,25 @@ impl serde::Serialize for UpdateInvoiceItemTaxBehavior { impl<'a> UpdateInvoiceItem<'a> { /// Updates the amount or description of an invoice item on an upcoming invoice. /// Updating an invoice item is only possible before the invoice it’s attached to is closed. - pub fn send( - &self, - client: &stripe::Client, - invoiceitem: &stripe_shared::InvoiceItemId, - ) -> stripe::Response<stripe_shared::InvoiceItem> { + pub fn send(&self, client: &stripe::Client, invoiceitem: &stripe_shared::InvoiceItemId) -> stripe::Response<stripe_shared::InvoiceItem> { client.send_form(&format!("/invoiceitems/{invoiceitem}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteInvoiceItem {} +impl DeleteInvoiceItem { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteInvoiceItem { + /// Deletes an invoice item, removing it from an invoice. + /// Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice. + pub fn send(&self, client: &stripe::Client, invoiceitem: &stripe_shared::InvoiceItemId) -> stripe::Response<stripe_shared::DeletedInvoiceitem> { + client.send_form(&format!("/invoiceitems/{invoiceitem}"), self, http_types::Method::Delete) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct DiscountsDataParam<'a> { /// ID of the coupon to create a new discount for. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/generated/stripe_billing/src/invoice_line_item/requests.rs b/generated/stripe_billing/src/invoice_line_item/requests.rs index 0ea7ef846..311e53118 100644 --- a/generated/stripe_billing/src/invoice_line_item/requests.rs +++ b/generated/stripe_billing/src/invoice_line_item/requests.rs @@ -26,17 +26,10 @@ impl<'a> ListInvoiceInvoiceLineItem<'a> { impl<'a> ListInvoiceInvoiceLineItem<'a> { /// When retrieving an invoice, you’ll get a **lines** property containing the total count of line items and the first handful of those items. /// There is also a URL where you can retrieve the full (paginated) list of line items. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::Response<stripe_types::List<stripe_shared::InvoiceLineItem>> { + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId) -> stripe::Response<stripe_types::List<stripe_shared::InvoiceLineItem>> { client.get_query(&format!("/invoices/{invoice}/lines"), self) } - pub fn paginate( - self, - invoice: &stripe_shared::InvoiceId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::InvoiceLineItem>> { + pub fn paginate(self, invoice: &stripe_shared::InvoiceId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::InvoiceLineItem>> { stripe::ListPaginator::from_list_params(&format!("/invoices/{invoice}/lines"), self) } } @@ -164,14 +157,7 @@ pub struct UpdateInvoiceLineItemPriceData<'a> { } impl<'a> UpdateInvoiceLineItemPriceData<'a> { pub fn new(currency: stripe_types::Currency) -> Self { - Self { - currency, - product: None, - product_data: None, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + Self { currency, product: None, product_data: None, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// Data used to generate a new product object inline. One of `product` or `product_data` is required. @@ -271,11 +257,7 @@ pub struct UpdateInvoiceLineItemTaxAmounts<'a> { pub taxable_amount: i64, } impl<'a> UpdateInvoiceLineItemTaxAmounts<'a> { - pub fn new( - amount: i64, - tax_rate_data: UpdateInvoiceLineItemTaxAmountsTaxRateData<'a>, - taxable_amount: i64, - ) -> Self { + pub fn new(amount: i64, tax_rate_data: UpdateInvoiceLineItemTaxAmountsTaxRateData<'a>, taxable_amount: i64) -> Self { Self { amount, tax_rate_data, taxable_amount } } } @@ -317,16 +299,7 @@ pub struct UpdateInvoiceLineItemTaxAmountsTaxRateData<'a> { } impl<'a> UpdateInvoiceLineItemTaxAmountsTaxRateData<'a> { pub fn new(display_name: &'a str, inclusive: bool, percentage: f64) -> Self { - Self { - country: None, - description: None, - display_name, - inclusive, - jurisdiction: None, - percentage, - state: None, - tax_type: None, - } + Self { country: None, description: None, display_name, inclusive, jurisdiction: None, percentage, state: None, tax_type: None } } } /// The high-level tax type, such as `vat` or `sales_tax`. @@ -419,16 +392,7 @@ impl<'a> UpdateInvoiceLineItem<'a> { /// Other fields, such as `amount`, live on both the invoice. /// item and the invoice line item, so updates on this endpoint will propagate to the invoice item as well. /// Updating an invoice’s line item is only possible before the invoice is finalized. - pub fn send( - &self, - client: &stripe::Client, - invoice: &stripe_shared::InvoiceId, - line_item_id: &str, - ) -> stripe::Response<stripe_shared::InvoiceLineItem> { - client.send_form( - &format!("/invoices/{invoice}/lines/{line_item_id}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, invoice: &stripe_shared::InvoiceId, line_item_id: &str) -> stripe::Response<stripe_shared::InvoiceLineItem> { + client.send_form(&format!("/invoices/{invoice}/lines/{line_item_id}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_billing/src/mod.rs b/generated/stripe_billing/src/mod.rs index 354f802ff..49b7d6072 100644 --- a/generated/stripe_billing/src/mod.rs +++ b/generated/stripe_billing/src/mod.rs @@ -7,6 +7,9 @@ //! for requests mentioned in the `Billing` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_billing; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub use billing_portal_configuration::types::*; pub use stripe_shared::automatic_tax::*; pub mod billing_portal_configuration; @@ -26,7 +29,31 @@ pub use stripe_shared::deleted_tax_id::*; pub use stripe_shared::deleted_test_helpers_test_clock::*; pub use stripe_shared::discounts_resource_discount_amount::*; pub mod invoice; -pub use stripe_shared::invoice::*;pub use stripe_shared::invoice_installments_card::*;pub use stripe_shared::invoice_item_threshold_reason::*;pub use stripe_shared::invoice_line_item_period::*;pub use stripe_shared::invoice_mandate_options_card::*;pub use stripe_shared::invoice_payment_method_options_acss_debit::*;pub use stripe_shared::invoice_payment_method_options_acss_debit_mandate_options::*;pub use stripe_shared::invoice_payment_method_options_bancontact::*;pub use stripe_shared::invoice_payment_method_options_card::*;pub use stripe_shared::invoice_payment_method_options_customer_balance::*;pub use stripe_shared::invoice_payment_method_options_customer_balance_bank_transfer::*;pub use stripe_shared::invoice_payment_method_options_customer_balance_bank_transfer_eu_bank_transfer::*;pub use stripe_shared::invoice_payment_method_options_konbini::*;pub use stripe_shared::invoice_payment_method_options_us_bank_account::*;pub use stripe_shared::invoice_payment_method_options_us_bank_account_linked_account_options::*;pub use stripe_shared::invoice_rendering_pdf::*;pub use stripe_shared::invoice_setting_custom_field::*;pub use stripe_shared::invoice_setting_customer_setting::*;pub use stripe_shared::invoice_setting_quote_setting::*;pub use stripe_shared::invoice_setting_rendering_options::*;pub use stripe_shared::invoice_setting_subscription_schedule_phase_setting::*;pub use stripe_shared::invoice_setting_subscription_schedule_setting::*;pub use stripe_shared::invoice_tax_amount::*;pub use stripe_shared::invoice_threshold_reason::*;pub use stripe_shared::invoice_transfer_data::*; +pub use stripe_shared::invoice::*; +pub use stripe_shared::invoice_installments_card::*; +pub use stripe_shared::invoice_item_threshold_reason::*; +pub use stripe_shared::invoice_line_item_period::*; +pub use stripe_shared::invoice_mandate_options_card::*; +pub use stripe_shared::invoice_payment_method_options_acss_debit::*; +pub use stripe_shared::invoice_payment_method_options_acss_debit_mandate_options::*; +pub use stripe_shared::invoice_payment_method_options_bancontact::*; +pub use stripe_shared::invoice_payment_method_options_card::*; +pub use stripe_shared::invoice_payment_method_options_customer_balance::*; +pub use stripe_shared::invoice_payment_method_options_customer_balance_bank_transfer::*; +pub use stripe_shared::invoice_payment_method_options_customer_balance_bank_transfer_eu_bank_transfer::*; +pub use stripe_shared::invoice_payment_method_options_konbini::*; +pub use stripe_shared::invoice_payment_method_options_us_bank_account::*; +pub use stripe_shared::invoice_payment_method_options_us_bank_account_linked_account_options::*; +pub use stripe_shared::invoice_rendering_pdf::*; +pub use stripe_shared::invoice_setting_custom_field::*; +pub use stripe_shared::invoice_setting_customer_setting::*; +pub use stripe_shared::invoice_setting_quote_setting::*; +pub use stripe_shared::invoice_setting_rendering_options::*; +pub use stripe_shared::invoice_setting_subscription_schedule_phase_setting::*; +pub use stripe_shared::invoice_setting_subscription_schedule_setting::*; +pub use stripe_shared::invoice_tax_amount::*; +pub use stripe_shared::invoice_threshold_reason::*; +pub use stripe_shared::invoice_transfer_data::*; pub mod invoice_item; pub use stripe_shared::checkout_session_item::*; pub use stripe_shared::invoice_item::*; @@ -165,12 +192,10 @@ pub use stripe_shared::subscription_schedule_phase_configuration::*; pub use stripe_shared::subscription_schedules_resource_default_settings::*; pub use stripe_shared::subscription_schedules_resource_default_settings_automatic_tax::*; pub use stripe_shared::subscription_transfer_data::*; -pub use stripe_shared::subscriptions_resource_billing_cycle_anchor_config::*; pub use stripe_shared::subscriptions_resource_pause_collection::*; pub use stripe_shared::subscriptions_resource_payment_method_options::*; pub use stripe_shared::subscriptions_resource_payment_settings::*; pub use stripe_shared::subscriptions_resource_pending_update::*; -pub use stripe_shared::tax_i_ds_owner::*; pub mod tax_id; pub use stripe_shared::tax_id::*; pub use stripe_shared::tax_id_verification::*; diff --git a/generated/stripe_billing/src/plan/requests.rs b/generated/stripe_billing/src/plan/requests.rs index c2394c9db..f984de3a4 100644 --- a/generated/stripe_billing/src/plan/requests.rs +++ b/generated/stripe_billing/src/plan/requests.rs @@ -1,21 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeletePlan {} -impl DeletePlan { - pub fn new() -> Self { - Self::default() - } -} -impl DeletePlan { - /// Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected. - pub fn send( - &self, - client: &stripe::Client, - plan: &stripe_shared::PlanId, - ) -> stripe::Response<stripe_shared::DeletedPlan> { - client.send_form(&format!("/plans/{plan}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListPlan<'a> { /// Only return plans that are active or inactive (e.g., pass `false` to list all inactive plans). #[serde(skip_serializing_if = "Option::is_none")] @@ -52,37 +35,13 @@ impl<'a> ListPlan<'a> { } impl<'a> ListPlan<'a> { /// Returns a list of your plans. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Plan>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Plan>> { client.get_query("/plans", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Plan>> { stripe::ListPaginator::from_list_params("/plans", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrievePlan<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrievePlan<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrievePlan<'a> { - /// Retrieves the plan with the given ID. - pub fn send( - &self, - client: &stripe::Client, - plan: &stripe_shared::PlanId, - ) -> stripe::Response<stripe_shared::Plan> { - client.get_query(&format!("/plans/{plan}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePlan<'a> { /// Whether the plan is currently available for new subscriptions. Defaults to `true`. @@ -122,7 +81,7 @@ pub struct CreatePlan<'a> { pub interval: stripe_shared::PlanInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. @@ -226,15 +185,7 @@ pub struct CreatePlanInlineProductParams<'a> { } impl<'a> CreatePlanInlineProductParams<'a> { pub fn new(name: &'a str) -> Self { - Self { - active: None, - id: None, - metadata: None, - name, - statement_descriptor: None, - tax_code: None, - unit_label: None, - } + Self { active: None, id: None, metadata: None, name, statement_descriptor: None, tax_code: None, unit_label: None } } } /// Each element represents a pricing tier. @@ -263,13 +214,7 @@ pub struct CreatePlanTiers<'a> { } impl<'a> CreatePlanTiers<'a> { pub fn new(up_to: CreatePlanTiersUpTo) -> Self { - Self { - flat_amount: None, - flat_amount_decimal: None, - unit_amount: None, - unit_amount_decimal: None, - up_to, - } + Self { flat_amount: None, flat_amount_decimal: None, unit_amount: None, unit_amount_decimal: None, up_to } } } /// Specifies the upper bound of this tier. @@ -349,6 +294,23 @@ impl<'a> CreatePlan<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrievePlan<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrievePlan<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrievePlan<'a> { + /// Retrieves the plan with the given ID. + pub fn send(&self, client: &stripe::Client, plan: &stripe_shared::PlanId) -> stripe::Response<stripe_shared::Plan> { + client.get_query(&format!("/plans/{plan}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePlan<'a> { /// Whether the plan is currently available for new subscriptions. #[serde(skip_serializing_if = "Option::is_none")] @@ -382,11 +344,20 @@ impl<'a> UpdatePlan<'a> { /// Updates the specified plan by setting the values of the parameters passed. /// Any parameters not provided are left unchanged. /// By design, you cannot change a plan’s ID, amount, currency, or billing cycle. - pub fn send( - &self, - client: &stripe::Client, - plan: &stripe_shared::PlanId, - ) -> stripe::Response<stripe_shared::Plan> { + pub fn send(&self, client: &stripe::Client, plan: &stripe_shared::PlanId) -> stripe::Response<stripe_shared::Plan> { client.send_form(&format!("/plans/{plan}"), self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeletePlan {} +impl DeletePlan { + pub fn new() -> Self { + Self::default() + } +} +impl DeletePlan { + /// Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected. + pub fn send(&self, client: &stripe::Client, plan: &stripe_shared::PlanId) -> stripe::Response<stripe_shared::DeletedPlan> { + client.send_form(&format!("/plans/{plan}"), self, http_types::Method::Delete) + } +} diff --git a/generated/stripe_billing/src/portal_business_profile.rs b/generated/stripe_billing/src/portal_business_profile.rs index 3252be5c4..709a882de 100644 --- a/generated/stripe_billing/src/portal_business_profile.rs +++ b/generated/stripe_billing/src/portal_business_profile.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalBusinessProfile { /// The messaging shown to customers in the portal. pub headline: Option<String>, @@ -7,3 +9,97 @@ pub struct PortalBusinessProfile { /// A link to the business’s publicly available terms of service. pub terms_of_service_url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PortalBusinessProfileBuilder { + headline: Option<Option<String>>, + privacy_policy_url: Option<Option<String>>, + terms_of_service_url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalBusinessProfile { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalBusinessProfile>, + builder: PortalBusinessProfileBuilder, + } + + impl Visitor for Place<PortalBusinessProfile> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalBusinessProfileBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalBusinessProfileBuilder { + type Out = PortalBusinessProfile; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "headline" => Deserialize::begin(&mut self.headline), + "privacy_policy_url" => Deserialize::begin(&mut self.privacy_policy_url), + "terms_of_service_url" => Deserialize::begin(&mut self.terms_of_service_url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { headline: Deserialize::default(), privacy_policy_url: Deserialize::default(), terms_of_service_url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let headline = self.headline.take()?; + let privacy_policy_url = self.privacy_policy_url.take()?; + let terms_of_service_url = self.terms_of_service_url.take()?; + + Some(Self::Out { headline, privacy_policy_url, terms_of_service_url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalBusinessProfile { + type Builder = PortalBusinessProfileBuilder; + } + + impl FromValueOpt for PortalBusinessProfile { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalBusinessProfileBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "headline" => b.headline = Some(FromValueOpt::from_value(v)?), + "privacy_policy_url" => b.privacy_policy_url = Some(FromValueOpt::from_value(v)?), + "terms_of_service_url" => b.terms_of_service_url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_customer_update.rs b/generated/stripe_billing/src/portal_customer_update.rs index 7bb767b97..b517d3b69 100644 --- a/generated/stripe_billing/src/portal_customer_update.rs +++ b/generated/stripe_billing/src/portal_customer_update.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalCustomerUpdate { /// The types of customer updates that are supported. When empty, customers are not updateable. pub allowed_updates: Vec<PortalCustomerUpdateAllowedUpdates>, /// Whether the feature is enabled. pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PortalCustomerUpdateBuilder { + allowed_updates: Option<Vec<PortalCustomerUpdateAllowedUpdates>>, + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalCustomerUpdate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalCustomerUpdate>, + builder: PortalCustomerUpdateBuilder, + } + + impl Visitor for Place<PortalCustomerUpdate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalCustomerUpdateBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalCustomerUpdateBuilder { + type Out = PortalCustomerUpdate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allowed_updates" => Deserialize::begin(&mut self.allowed_updates), + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_updates: Deserialize::default(), enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allowed_updates = self.allowed_updates.take()?; + let enabled = self.enabled.take()?; + + Some(Self::Out { allowed_updates, enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalCustomerUpdate { + type Builder = PortalCustomerUpdateBuilder; + } + + impl FromValueOpt for PortalCustomerUpdate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalCustomerUpdateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allowed_updates" => b.allowed_updates = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The types of customer updates that are supported. When empty, customers are not updateable. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PortalCustomerUpdateAllowedUpdates { @@ -67,8 +159,24 @@ impl<'de> serde::Deserialize<'de> for PortalCustomerUpdateAllowedUpdates { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PortalCustomerUpdateAllowedUpdates") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalCustomerUpdateAllowedUpdates")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalCustomerUpdateAllowedUpdates { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalCustomerUpdateAllowedUpdates> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalCustomerUpdateAllowedUpdates::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalCustomerUpdateAllowedUpdates); diff --git a/generated/stripe_billing/src/portal_features.rs b/generated/stripe_billing/src/portal_features.rs index e5ad9e671..9bccd3129 100644 --- a/generated/stripe_billing/src/portal_features.rs +++ b/generated/stripe_billing/src/portal_features.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFeatures { pub customer_update: stripe_billing::PortalCustomerUpdate, pub invoice_history: stripe_billing::PortalInvoiceList, @@ -7,3 +9,116 @@ pub struct PortalFeatures { pub subscription_pause: stripe_billing::PortalSubscriptionPause, pub subscription_update: stripe_billing::PortalSubscriptionUpdate, } +#[cfg(feature = "min-ser")] +pub struct PortalFeaturesBuilder { + customer_update: Option<stripe_billing::PortalCustomerUpdate>, + invoice_history: Option<stripe_billing::PortalInvoiceList>, + payment_method_update: Option<stripe_billing::PortalPaymentMethodUpdate>, + subscription_cancel: Option<stripe_billing::PortalSubscriptionCancel>, + subscription_pause: Option<stripe_billing::PortalSubscriptionPause>, + subscription_update: Option<stripe_billing::PortalSubscriptionUpdate>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFeatures { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFeatures>, + builder: PortalFeaturesBuilder, + } + + impl Visitor for Place<PortalFeatures> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFeaturesBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFeaturesBuilder { + type Out = PortalFeatures; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "customer_update" => Deserialize::begin(&mut self.customer_update), + "invoice_history" => Deserialize::begin(&mut self.invoice_history), + "payment_method_update" => Deserialize::begin(&mut self.payment_method_update), + "subscription_cancel" => Deserialize::begin(&mut self.subscription_cancel), + "subscription_pause" => Deserialize::begin(&mut self.subscription_pause), + "subscription_update" => Deserialize::begin(&mut self.subscription_update), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + customer_update: Deserialize::default(), + invoice_history: Deserialize::default(), + payment_method_update: Deserialize::default(), + subscription_cancel: Deserialize::default(), + subscription_pause: Deserialize::default(), + subscription_update: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let customer_update = self.customer_update.take()?; + let invoice_history = self.invoice_history.take()?; + let payment_method_update = self.payment_method_update.take()?; + let subscription_cancel = self.subscription_cancel.take()?; + let subscription_pause = self.subscription_pause.take()?; + let subscription_update = self.subscription_update.take()?; + + Some(Self::Out { customer_update, invoice_history, payment_method_update, subscription_cancel, subscription_pause, subscription_update }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFeatures { + type Builder = PortalFeaturesBuilder; + } + + impl FromValueOpt for PortalFeatures { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFeaturesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "customer_update" => b.customer_update = Some(FromValueOpt::from_value(v)?), + "invoice_history" => b.invoice_history = Some(FromValueOpt::from_value(v)?), + "payment_method_update" => b.payment_method_update = Some(FromValueOpt::from_value(v)?), + "subscription_cancel" => b.subscription_cancel = Some(FromValueOpt::from_value(v)?), + "subscription_pause" => b.subscription_pause = Some(FromValueOpt::from_value(v)?), + "subscription_update" => b.subscription_update = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_after_completion_hosted_confirmation.rs b/generated/stripe_billing/src/portal_flows_after_completion_hosted_confirmation.rs index 1c65b58ad..bb75bff36 100644 --- a/generated/stripe_billing/src/portal_flows_after_completion_hosted_confirmation.rs +++ b/generated/stripe_billing/src/portal_flows_after_completion_hosted_confirmation.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsAfterCompletionHostedConfirmation { /// A custom message to display to the customer after the flow is completed. pub custom_message: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsAfterCompletionHostedConfirmationBuilder { + custom_message: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsAfterCompletionHostedConfirmation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsAfterCompletionHostedConfirmation>, + builder: PortalFlowsAfterCompletionHostedConfirmationBuilder, + } + + impl Visitor for Place<PortalFlowsAfterCompletionHostedConfirmation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsAfterCompletionHostedConfirmationBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsAfterCompletionHostedConfirmationBuilder { + type Out = PortalFlowsAfterCompletionHostedConfirmation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom_message" => Deserialize::begin(&mut self.custom_message), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom_message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom_message = self.custom_message.take()?; + + Some(Self::Out { custom_message }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsAfterCompletionHostedConfirmation { + type Builder = PortalFlowsAfterCompletionHostedConfirmationBuilder; + } + + impl FromValueOpt for PortalFlowsAfterCompletionHostedConfirmation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsAfterCompletionHostedConfirmationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom_message" => b.custom_message = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_after_completion_redirect.rs b/generated/stripe_billing/src/portal_flows_after_completion_redirect.rs index e8a4b2d5c..78360d877 100644 --- a/generated/stripe_billing/src/portal_flows_after_completion_redirect.rs +++ b/generated/stripe_billing/src/portal_flows_after_completion_redirect.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsAfterCompletionRedirect { /// The URL the customer will be redirected to after the flow is completed. pub return_url: String, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsAfterCompletionRedirectBuilder { + return_url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsAfterCompletionRedirect { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsAfterCompletionRedirect>, + builder: PortalFlowsAfterCompletionRedirectBuilder, + } + + impl Visitor for Place<PortalFlowsAfterCompletionRedirect> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsAfterCompletionRedirectBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsAfterCompletionRedirectBuilder { + type Out = PortalFlowsAfterCompletionRedirect; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "return_url" => Deserialize::begin(&mut self.return_url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { return_url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let return_url = self.return_url.take()?; + + Some(Self::Out { return_url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsAfterCompletionRedirect { + type Builder = PortalFlowsAfterCompletionRedirectBuilder; + } + + impl FromValueOpt for PortalFlowsAfterCompletionRedirect { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsAfterCompletionRedirectBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_coupon_offer.rs b/generated/stripe_billing/src/portal_flows_coupon_offer.rs index d56e0fd0f..4445db69d 100644 --- a/generated/stripe_billing/src/portal_flows_coupon_offer.rs +++ b/generated/stripe_billing/src/portal_flows_coupon_offer.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsCouponOffer { /// The ID of the coupon to be offered. pub coupon: String, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsCouponOfferBuilder { + coupon: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsCouponOffer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsCouponOffer>, + builder: PortalFlowsCouponOfferBuilder, + } + + impl Visitor for Place<PortalFlowsCouponOffer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsCouponOfferBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsCouponOfferBuilder { + type Out = PortalFlowsCouponOffer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "coupon" => Deserialize::begin(&mut self.coupon), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { coupon: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let coupon = self.coupon.take()?; + + Some(Self::Out { coupon }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsCouponOffer { + type Builder = PortalFlowsCouponOfferBuilder; + } + + impl FromValueOpt for PortalFlowsCouponOffer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsCouponOfferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "coupon" => b.coupon = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_flow.rs b/generated/stripe_billing/src/portal_flows_flow.rs index 6258cfb43..1822de76f 100644 --- a/generated/stripe_billing/src/portal_flows_flow.rs +++ b/generated/stripe_billing/src/portal_flows_flow.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsFlow { pub after_completion: stripe_billing::PortalFlowsFlowAfterCompletion, /// Configuration when `flow.type=subscription_cancel`. @@ -6,12 +8,119 @@ pub struct PortalFlowsFlow { /// Configuration when `flow.type=subscription_update`. pub subscription_update: Option<stripe_billing::PortalFlowsFlowSubscriptionUpdate>, /// Configuration when `flow.type=subscription_update_confirm`. - pub subscription_update_confirm: - Option<stripe_billing::PortalFlowsFlowSubscriptionUpdateConfirm>, + pub subscription_update_confirm: Option<stripe_billing::PortalFlowsFlowSubscriptionUpdateConfirm>, /// Type of flow that the customer will go through. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PortalFlowsFlowType, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsFlowBuilder { + after_completion: Option<stripe_billing::PortalFlowsFlowAfterCompletion>, + subscription_cancel: Option<Option<stripe_billing::PortalFlowsFlowSubscriptionCancel>>, + subscription_update: Option<Option<stripe_billing::PortalFlowsFlowSubscriptionUpdate>>, + subscription_update_confirm: Option<Option<stripe_billing::PortalFlowsFlowSubscriptionUpdateConfirm>>, + type_: Option<PortalFlowsFlowType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsFlow { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsFlow>, + builder: PortalFlowsFlowBuilder, + } + + impl Visitor for Place<PortalFlowsFlow> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsFlowBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsFlowBuilder { + type Out = PortalFlowsFlow; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "after_completion" => Deserialize::begin(&mut self.after_completion), + "subscription_cancel" => Deserialize::begin(&mut self.subscription_cancel), + "subscription_update" => Deserialize::begin(&mut self.subscription_update), + "subscription_update_confirm" => Deserialize::begin(&mut self.subscription_update_confirm), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + after_completion: Deserialize::default(), + subscription_cancel: Deserialize::default(), + subscription_update: Deserialize::default(), + subscription_update_confirm: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let after_completion = self.after_completion.take()?; + let subscription_cancel = self.subscription_cancel.take()?; + let subscription_update = self.subscription_update.take()?; + let subscription_update_confirm = self.subscription_update_confirm.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { after_completion, subscription_cancel, subscription_update, subscription_update_confirm, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsFlow { + type Builder = PortalFlowsFlowBuilder; + } + + impl FromValueOpt for PortalFlowsFlow { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsFlowBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "after_completion" => b.after_completion = Some(FromValueOpt::from_value(v)?), + "subscription_cancel" => b.subscription_cancel = Some(FromValueOpt::from_value(v)?), + "subscription_update" => b.subscription_update = Some(FromValueOpt::from_value(v)?), + "subscription_update_confirm" => b.subscription_update_confirm = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of flow that the customer will go through. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PortalFlowsFlowType { @@ -68,7 +177,24 @@ impl<'de> serde::Deserialize<'de> for PortalFlowsFlowType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PortalFlowsFlowType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalFlowsFlowType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalFlowsFlowType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalFlowsFlowType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalFlowsFlowType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalFlowsFlowType); diff --git a/generated/stripe_billing/src/portal_flows_flow_after_completion.rs b/generated/stripe_billing/src/portal_flows_flow_after_completion.rs index 7c36e7a79..71c0f6498 100644 --- a/generated/stripe_billing/src/portal_flows_flow_after_completion.rs +++ b/generated/stripe_billing/src/portal_flows_flow_after_completion.rs @@ -1,13 +1,109 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsFlowAfterCompletion { /// Configuration when `after_completion.type=hosted_confirmation`. pub hosted_confirmation: Option<stripe_billing::PortalFlowsAfterCompletionHostedConfirmation>, /// Configuration when `after_completion.type=redirect`. pub redirect: Option<stripe_billing::PortalFlowsAfterCompletionRedirect>, /// The specified type of behavior after the flow is completed. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PortalFlowsFlowAfterCompletionType, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsFlowAfterCompletionBuilder { + hosted_confirmation: Option<Option<stripe_billing::PortalFlowsAfterCompletionHostedConfirmation>>, + redirect: Option<Option<stripe_billing::PortalFlowsAfterCompletionRedirect>>, + type_: Option<PortalFlowsFlowAfterCompletionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsFlowAfterCompletion { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsFlowAfterCompletion>, + builder: PortalFlowsFlowAfterCompletionBuilder, + } + + impl Visitor for Place<PortalFlowsFlowAfterCompletion> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsFlowAfterCompletionBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsFlowAfterCompletionBuilder { + type Out = PortalFlowsFlowAfterCompletion; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "hosted_confirmation" => Deserialize::begin(&mut self.hosted_confirmation), + "redirect" => Deserialize::begin(&mut self.redirect), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { hosted_confirmation: Deserialize::default(), redirect: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let hosted_confirmation = self.hosted_confirmation.take()?; + let redirect = self.redirect.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { hosted_confirmation, redirect, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsFlowAfterCompletion { + type Builder = PortalFlowsFlowAfterCompletionBuilder; + } + + impl FromValueOpt for PortalFlowsFlowAfterCompletion { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsFlowAfterCompletionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "hosted_confirmation" => b.hosted_confirmation = Some(FromValueOpt::from_value(v)?), + "redirect" => b.redirect = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The specified type of behavior after the flow is completed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PortalFlowsFlowAfterCompletionType { @@ -61,8 +157,24 @@ impl<'de> serde::Deserialize<'de> for PortalFlowsFlowAfterCompletionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PortalFlowsFlowAfterCompletionType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalFlowsFlowAfterCompletionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalFlowsFlowAfterCompletionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalFlowsFlowAfterCompletionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalFlowsFlowAfterCompletionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalFlowsFlowAfterCompletionType); diff --git a/generated/stripe_billing/src/portal_flows_flow_subscription_cancel.rs b/generated/stripe_billing/src/portal_flows_flow_subscription_cancel.rs index 64d6de5d8..61601044e 100644 --- a/generated/stripe_billing/src/portal_flows_flow_subscription_cancel.rs +++ b/generated/stripe_billing/src/portal_flows_flow_subscription_cancel.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsFlowSubscriptionCancel { /// Specify a retention strategy to be used in the cancellation flow. pub retention: Option<stripe_billing::PortalFlowsRetention>, /// The ID of the subscription to be canceled. pub subscription: String, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsFlowSubscriptionCancelBuilder { + retention: Option<Option<stripe_billing::PortalFlowsRetention>>, + subscription: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsFlowSubscriptionCancel { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsFlowSubscriptionCancel>, + builder: PortalFlowsFlowSubscriptionCancelBuilder, + } + + impl Visitor for Place<PortalFlowsFlowSubscriptionCancel> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsFlowSubscriptionCancelBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsFlowSubscriptionCancelBuilder { + type Out = PortalFlowsFlowSubscriptionCancel; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "retention" => Deserialize::begin(&mut self.retention), + "subscription" => Deserialize::begin(&mut self.subscription), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { retention: Deserialize::default(), subscription: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let retention = self.retention.take()?; + let subscription = self.subscription.take()?; + + Some(Self::Out { retention, subscription }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsFlowSubscriptionCancel { + type Builder = PortalFlowsFlowSubscriptionCancelBuilder; + } + + impl FromValueOpt for PortalFlowsFlowSubscriptionCancel { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsFlowSubscriptionCancelBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "retention" => b.retention = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_flow_subscription_update.rs b/generated/stripe_billing/src/portal_flows_flow_subscription_update.rs index 36545392d..57dfec11d 100644 --- a/generated/stripe_billing/src/portal_flows_flow_subscription_update.rs +++ b/generated/stripe_billing/src/portal_flows_flow_subscription_update.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsFlowSubscriptionUpdate { /// The ID of the subscription to be updated. pub subscription: String, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsFlowSubscriptionUpdateBuilder { + subscription: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsFlowSubscriptionUpdate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsFlowSubscriptionUpdate>, + builder: PortalFlowsFlowSubscriptionUpdateBuilder, + } + + impl Visitor for Place<PortalFlowsFlowSubscriptionUpdate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsFlowSubscriptionUpdateBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsFlowSubscriptionUpdateBuilder { + type Out = PortalFlowsFlowSubscriptionUpdate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "subscription" => Deserialize::begin(&mut self.subscription), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { subscription: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let subscription = self.subscription.take()?; + + Some(Self::Out { subscription }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsFlowSubscriptionUpdate { + type Builder = PortalFlowsFlowSubscriptionUpdateBuilder; + } + + impl FromValueOpt for PortalFlowsFlowSubscriptionUpdate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsFlowSubscriptionUpdateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_flow_subscription_update_confirm.rs b/generated/stripe_billing/src/portal_flows_flow_subscription_update_confirm.rs index 6b2ff9a61..a8960d2e4 100644 --- a/generated/stripe_billing/src/portal_flows_flow_subscription_update_confirm.rs +++ b/generated/stripe_billing/src/portal_flows_flow_subscription_update_confirm.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsFlowSubscriptionUpdateConfirm { /// The coupon or promotion code to apply to this subscription update. /// Currently, only up to one may be specified. @@ -9,3 +11,97 @@ pub struct PortalFlowsFlowSubscriptionUpdateConfirm { /// The ID of the subscription to be updated. pub subscription: String, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsFlowSubscriptionUpdateConfirmBuilder { + discounts: Option<Option<Vec<stripe_billing::PortalFlowsSubscriptionUpdateConfirmDiscount>>>, + items: Option<Vec<stripe_billing::PortalFlowsSubscriptionUpdateConfirmItem>>, + subscription: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsFlowSubscriptionUpdateConfirm { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsFlowSubscriptionUpdateConfirm>, + builder: PortalFlowsFlowSubscriptionUpdateConfirmBuilder, + } + + impl Visitor for Place<PortalFlowsFlowSubscriptionUpdateConfirm> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsFlowSubscriptionUpdateConfirmBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsFlowSubscriptionUpdateConfirmBuilder { + type Out = PortalFlowsFlowSubscriptionUpdateConfirm; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "discounts" => Deserialize::begin(&mut self.discounts), + "items" => Deserialize::begin(&mut self.items), + "subscription" => Deserialize::begin(&mut self.subscription), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { discounts: Deserialize::default(), items: Deserialize::default(), subscription: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let discounts = self.discounts.take()?; + let items = self.items.take()?; + let subscription = self.subscription.take()?; + + Some(Self::Out { discounts, items, subscription }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsFlowSubscriptionUpdateConfirm { + type Builder = PortalFlowsFlowSubscriptionUpdateConfirmBuilder; + } + + impl FromValueOpt for PortalFlowsFlowSubscriptionUpdateConfirm { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsFlowSubscriptionUpdateConfirmBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "items" => b.items = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_retention.rs b/generated/stripe_billing/src/portal_flows_retention.rs index 8b633441f..505bc0d06 100644 --- a/generated/stripe_billing/src/portal_flows_retention.rs +++ b/generated/stripe_billing/src/portal_flows_retention.rs @@ -1,11 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsRetention { /// Configuration when `retention.type=coupon_offer`. pub coupon_offer: Option<stripe_billing::PortalFlowsCouponOffer>, /// Type of retention strategy that will be used. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PortalFlowsRetentionType, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsRetentionBuilder { + coupon_offer: Option<Option<stripe_billing::PortalFlowsCouponOffer>>, + type_: Option<PortalFlowsRetentionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsRetention { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsRetention>, + builder: PortalFlowsRetentionBuilder, + } + + impl Visitor for Place<PortalFlowsRetention> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsRetentionBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsRetentionBuilder { + type Out = PortalFlowsRetention; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "coupon_offer" => Deserialize::begin(&mut self.coupon_offer), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { coupon_offer: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let coupon_offer = self.coupon_offer.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { coupon_offer, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsRetention { + type Builder = PortalFlowsRetentionBuilder; + } + + impl FromValueOpt for PortalFlowsRetention { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsRetentionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "coupon_offer" => b.coupon_offer = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of retention strategy that will be used. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PortalFlowsRetentionType { @@ -53,7 +145,24 @@ impl<'de> serde::Deserialize<'de> for PortalFlowsRetentionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PortalFlowsRetentionType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalFlowsRetentionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalFlowsRetentionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalFlowsRetentionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalFlowsRetentionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalFlowsRetentionType); diff --git a/generated/stripe_billing/src/portal_flows_subscription_update_confirm_discount.rs b/generated/stripe_billing/src/portal_flows_subscription_update_confirm_discount.rs index eb869a581..d3f306008 100644 --- a/generated/stripe_billing/src/portal_flows_subscription_update_confirm_discount.rs +++ b/generated/stripe_billing/src/portal_flows_subscription_update_confirm_discount.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsSubscriptionUpdateConfirmDiscount { /// The ID of the coupon to apply to this subscription update. pub coupon: Option<String>, /// The ID of a promotion code to apply to this subscription update. pub promotion_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsSubscriptionUpdateConfirmDiscountBuilder { + coupon: Option<Option<String>>, + promotion_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsSubscriptionUpdateConfirmDiscount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsSubscriptionUpdateConfirmDiscount>, + builder: PortalFlowsSubscriptionUpdateConfirmDiscountBuilder, + } + + impl Visitor for Place<PortalFlowsSubscriptionUpdateConfirmDiscount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsSubscriptionUpdateConfirmDiscountBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsSubscriptionUpdateConfirmDiscountBuilder { + type Out = PortalFlowsSubscriptionUpdateConfirmDiscount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "coupon" => Deserialize::begin(&mut self.coupon), + "promotion_code" => Deserialize::begin(&mut self.promotion_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { coupon: Deserialize::default(), promotion_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let coupon = self.coupon.take()?; + let promotion_code = self.promotion_code.take()?; + + Some(Self::Out { coupon, promotion_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsSubscriptionUpdateConfirmDiscount { + type Builder = PortalFlowsSubscriptionUpdateConfirmDiscountBuilder; + } + + impl FromValueOpt for PortalFlowsSubscriptionUpdateConfirmDiscount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsSubscriptionUpdateConfirmDiscountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "coupon" => b.coupon = Some(FromValueOpt::from_value(v)?), + "promotion_code" => b.promotion_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item.rs b/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item.rs index 498cdec57..cfb7a92cd 100644 --- a/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item.rs +++ b/generated/stripe_billing/src/portal_flows_subscription_update_confirm_item.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalFlowsSubscriptionUpdateConfirmItem { /// The ID of the [subscription item](https://stripe.com/docs/api/subscriptions/object#subscription_object-items-data-id) to be updated. pub id: Option<stripe_billing::PortalFlowsSubscriptionUpdateConfirmItemId>, @@ -6,9 +8,102 @@ pub struct PortalFlowsSubscriptionUpdateConfirmItem { /// The price must also be included in the configuration's [`features.subscription_update.products`](https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-products). pub price: Option<String>, /// [Quantity](https://stripe.com/docs/subscriptions/quantities) for this item that the customer should subscribe to through this flow. - #[serde(skip_serializing_if = "Option::is_none")] pub quantity: Option<u64>, } +#[cfg(feature = "min-ser")] +pub struct PortalFlowsSubscriptionUpdateConfirmItemBuilder { + id: Option<Option<stripe_billing::PortalFlowsSubscriptionUpdateConfirmItemId>>, + price: Option<Option<String>>, + quantity: Option<Option<u64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalFlowsSubscriptionUpdateConfirmItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalFlowsSubscriptionUpdateConfirmItem>, + builder: PortalFlowsSubscriptionUpdateConfirmItemBuilder, + } + + impl Visitor for Place<PortalFlowsSubscriptionUpdateConfirmItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalFlowsSubscriptionUpdateConfirmItemBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalFlowsSubscriptionUpdateConfirmItemBuilder { + type Out = PortalFlowsSubscriptionUpdateConfirmItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "price" => Deserialize::begin(&mut self.price), + "quantity" => Deserialize::begin(&mut self.quantity), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), price: Deserialize::default(), quantity: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let price = self.price.take()?; + let quantity = self.quantity.take()?; + + Some(Self::Out { id, price, quantity }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalFlowsSubscriptionUpdateConfirmItem { + type Builder = PortalFlowsSubscriptionUpdateConfirmItemBuilder; + } + + impl FromValueOpt for PortalFlowsSubscriptionUpdateConfirmItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalFlowsSubscriptionUpdateConfirmItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "price" => b.price = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for PortalFlowsSubscriptionUpdateConfirmItem { type Id = Option<stripe_billing::PortalFlowsSubscriptionUpdateConfirmItemId>; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_billing/src/portal_invoice_list.rs b/generated/stripe_billing/src/portal_invoice_list.rs index 5bfc9c90a..291eeeadb 100644 --- a/generated/stripe_billing/src/portal_invoice_list.rs +++ b/generated/stripe_billing/src/portal_invoice_list.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalInvoiceList { /// Whether the feature is enabled. pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PortalInvoiceListBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalInvoiceList { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalInvoiceList>, + builder: PortalInvoiceListBuilder, + } + + impl Visitor for Place<PortalInvoiceList> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalInvoiceListBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalInvoiceListBuilder { + type Out = PortalInvoiceList; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalInvoiceList { + type Builder = PortalInvoiceListBuilder; + } + + impl FromValueOpt for PortalInvoiceList { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalInvoiceListBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_login_page.rs b/generated/stripe_billing/src/portal_login_page.rs index 79231eab9..30ae2fbf7 100644 --- a/generated/stripe_billing/src/portal_login_page.rs +++ b/generated/stripe_billing/src/portal_login_page.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalLoginPage { /// If `true`, a shareable `url` will be generated that will take your customers to a hosted login page for the customer portal. /// @@ -8,3 +10,93 @@ pub struct PortalLoginPage { /// Your customers will be able to log in with their [email](https://stripe.com/docs/api/customers/object#customer_object-email) and receive a link to their customer portal. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PortalLoginPageBuilder { + enabled: Option<bool>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalLoginPage { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalLoginPage>, + builder: PortalLoginPageBuilder, + } + + impl Visitor for Place<PortalLoginPage> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalLoginPageBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalLoginPageBuilder { + type Out = PortalLoginPage; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + let url = self.url.take()?; + + Some(Self::Out { enabled, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalLoginPage { + type Builder = PortalLoginPageBuilder; + } + + impl FromValueOpt for PortalLoginPage { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalLoginPageBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_payment_method_update.rs b/generated/stripe_billing/src/portal_payment_method_update.rs index 1c2e06ae5..e66aee496 100644 --- a/generated/stripe_billing/src/portal_payment_method_update.rs +++ b/generated/stripe_billing/src/portal_payment_method_update.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalPaymentMethodUpdate { /// Whether the feature is enabled. pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PortalPaymentMethodUpdateBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalPaymentMethodUpdate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalPaymentMethodUpdate>, + builder: PortalPaymentMethodUpdateBuilder, + } + + impl Visitor for Place<PortalPaymentMethodUpdate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalPaymentMethodUpdateBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalPaymentMethodUpdateBuilder { + type Out = PortalPaymentMethodUpdate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalPaymentMethodUpdate { + type Builder = PortalPaymentMethodUpdateBuilder; + } + + impl FromValueOpt for PortalPaymentMethodUpdate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalPaymentMethodUpdateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_subscription_cancel.rs b/generated/stripe_billing/src/portal_subscription_cancel.rs index 40e5023bb..a436a694f 100644 --- a/generated/stripe_billing/src/portal_subscription_cancel.rs +++ b/generated/stripe_billing/src/portal_subscription_cancel.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalSubscriptionCancel { pub cancellation_reason: stripe_billing::PortalSubscriptionCancellationReason, /// Whether the feature is enabled. @@ -9,6 +11,104 @@ pub struct PortalSubscriptionCancel { /// Possible values are `none` and `create_prorations`. pub proration_behavior: PortalSubscriptionCancelProrationBehavior, } +#[cfg(feature = "min-ser")] +pub struct PortalSubscriptionCancelBuilder { + cancellation_reason: Option<stripe_billing::PortalSubscriptionCancellationReason>, + enabled: Option<bool>, + mode: Option<PortalSubscriptionCancelMode>, + proration_behavior: Option<PortalSubscriptionCancelProrationBehavior>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalSubscriptionCancel { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalSubscriptionCancel>, + builder: PortalSubscriptionCancelBuilder, + } + + impl Visitor for Place<PortalSubscriptionCancel> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalSubscriptionCancelBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalSubscriptionCancelBuilder { + type Out = PortalSubscriptionCancel; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason), + "enabled" => Deserialize::begin(&mut self.enabled), + "mode" => Deserialize::begin(&mut self.mode), + "proration_behavior" => Deserialize::begin(&mut self.proration_behavior), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { cancellation_reason: Deserialize::default(), enabled: Deserialize::default(), mode: Deserialize::default(), proration_behavior: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let cancellation_reason = self.cancellation_reason.take()?; + let enabled = self.enabled.take()?; + let mode = self.mode.take()?; + let proration_behavior = self.proration_behavior.take()?; + + Some(Self::Out { cancellation_reason, enabled, mode, proration_behavior }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalSubscriptionCancel { + type Builder = PortalSubscriptionCancelBuilder; + } + + impl FromValueOpt for PortalSubscriptionCancel { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalSubscriptionCancelBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "cancellation_reason" => b.cancellation_reason = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "mode" => b.mode = Some(FromValueOpt::from_value(v)?), + "proration_behavior" => b.proration_behavior = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether to cancel subscriptions immediately or at the end of the billing period. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PortalSubscriptionCancelMode { @@ -59,10 +159,27 @@ impl<'de> serde::Deserialize<'de> for PortalSubscriptionCancelMode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PortalSubscriptionCancelMode")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalSubscriptionCancelMode")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalSubscriptionCancelMode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalSubscriptionCancelMode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalSubscriptionCancelMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionCancelMode); /// Whether to create prorations when canceling subscriptions. /// Possible values are `none` and `create_prorations`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -117,8 +234,24 @@ impl<'de> serde::Deserialize<'de> for PortalSubscriptionCancelProrationBehavior fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PortalSubscriptionCancelProrationBehavior") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalSubscriptionCancelProrationBehavior")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalSubscriptionCancelProrationBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalSubscriptionCancelProrationBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalSubscriptionCancelProrationBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionCancelProrationBehavior); diff --git a/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs b/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs index 689eb829c..ec1f9d1d8 100644 --- a/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs +++ b/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalSubscriptionCancellationReason { /// Whether the feature is enabled. pub enabled: bool, /// Which cancellation reasons will be given as options to the customer. pub options: Vec<PortalSubscriptionCancellationReasonOptions>, } +#[cfg(feature = "min-ser")] +pub struct PortalSubscriptionCancellationReasonBuilder { + enabled: Option<bool>, + options: Option<Vec<PortalSubscriptionCancellationReasonOptions>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalSubscriptionCancellationReason { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalSubscriptionCancellationReason>, + builder: PortalSubscriptionCancellationReasonBuilder, + } + + impl Visitor for Place<PortalSubscriptionCancellationReason> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalSubscriptionCancellationReasonBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalSubscriptionCancellationReasonBuilder { + type Out = PortalSubscriptionCancellationReason; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "options" => Deserialize::begin(&mut self.options), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + let options = self.options.take()?; + + Some(Self::Out { enabled, options }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalSubscriptionCancellationReason { + type Builder = PortalSubscriptionCancellationReasonBuilder; + } + + impl FromValueOpt for PortalSubscriptionCancellationReason { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalSubscriptionCancellationReasonBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "options" => b.options = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Which cancellation reasons will be given as options to the customer. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PortalSubscriptionCancellationReasonOptions { @@ -73,10 +165,24 @@ impl<'de> serde::Deserialize<'de> for PortalSubscriptionCancellationReasonOption fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PortalSubscriptionCancellationReasonOptions", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalSubscriptionCancellationReasonOptions")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalSubscriptionCancellationReasonOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalSubscriptionCancellationReasonOptions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalSubscriptionCancellationReasonOptions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionCancellationReasonOptions); diff --git a/generated/stripe_billing/src/portal_subscription_pause.rs b/generated/stripe_billing/src/portal_subscription_pause.rs index edb26171c..f4a59c526 100644 --- a/generated/stripe_billing/src/portal_subscription_pause.rs +++ b/generated/stripe_billing/src/portal_subscription_pause.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalSubscriptionPause { /// Whether the feature is enabled. pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PortalSubscriptionPauseBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalSubscriptionPause { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalSubscriptionPause>, + builder: PortalSubscriptionPauseBuilder, + } + + impl Visitor for Place<PortalSubscriptionPause> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalSubscriptionPauseBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalSubscriptionPauseBuilder { + type Out = PortalSubscriptionPause; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalSubscriptionPause { + type Builder = PortalSubscriptionPauseBuilder; + } + + impl FromValueOpt for PortalSubscriptionPause { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalSubscriptionPauseBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/portal_subscription_update.rs b/generated/stripe_billing/src/portal_subscription_update.rs index dad7ba67c..724817c0e 100644 --- a/generated/stripe_billing/src/portal_subscription_update.rs +++ b/generated/stripe_billing/src/portal_subscription_update.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalSubscriptionUpdate { /// The types of subscription updates that are supported for items listed in the `products` attribute. /// When empty, subscriptions are not updateable. @@ -11,6 +13,104 @@ pub struct PortalSubscriptionUpdate { /// Valid values are `none`, `create_prorations`, and `always_invoice`. pub proration_behavior: PortalSubscriptionUpdateProrationBehavior, } +#[cfg(feature = "min-ser")] +pub struct PortalSubscriptionUpdateBuilder { + default_allowed_updates: Option<Vec<PortalSubscriptionUpdateDefaultAllowedUpdates>>, + enabled: Option<bool>, + products: Option<Option<Vec<stripe_billing::PortalSubscriptionUpdateProduct>>>, + proration_behavior: Option<PortalSubscriptionUpdateProrationBehavior>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalSubscriptionUpdate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalSubscriptionUpdate>, + builder: PortalSubscriptionUpdateBuilder, + } + + impl Visitor for Place<PortalSubscriptionUpdate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalSubscriptionUpdateBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalSubscriptionUpdateBuilder { + type Out = PortalSubscriptionUpdate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "default_allowed_updates" => Deserialize::begin(&mut self.default_allowed_updates), + "enabled" => Deserialize::begin(&mut self.enabled), + "products" => Deserialize::begin(&mut self.products), + "proration_behavior" => Deserialize::begin(&mut self.proration_behavior), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { default_allowed_updates: Deserialize::default(), enabled: Deserialize::default(), products: Deserialize::default(), proration_behavior: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let default_allowed_updates = self.default_allowed_updates.take()?; + let enabled = self.enabled.take()?; + let products = self.products.take()?; + let proration_behavior = self.proration_behavior.take()?; + + Some(Self::Out { default_allowed_updates, enabled, products, proration_behavior }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalSubscriptionUpdate { + type Builder = PortalSubscriptionUpdateBuilder; + } + + impl FromValueOpt for PortalSubscriptionUpdate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalSubscriptionUpdateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "default_allowed_updates" => b.default_allowed_updates = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "products" => b.products = Some(FromValueOpt::from_value(v)?), + "proration_behavior" => b.proration_behavior = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The types of subscription updates that are supported for items listed in the `products` attribute. /// When empty, subscriptions are not updateable. #[derive(Copy, Clone, Eq, PartialEq)] @@ -65,13 +165,27 @@ impl<'de> serde::Deserialize<'de> for PortalSubscriptionUpdateDefaultAllowedUpda fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PortalSubscriptionUpdateDefaultAllowedUpdates", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalSubscriptionUpdateDefaultAllowedUpdates")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalSubscriptionUpdateDefaultAllowedUpdates { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalSubscriptionUpdateDefaultAllowedUpdates> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalSubscriptionUpdateDefaultAllowedUpdates::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionUpdateDefaultAllowedUpdates); /// Determines how to handle prorations resulting from subscription updates. /// Valid values are `none`, `create_prorations`, and `always_invoice`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -126,8 +240,24 @@ impl<'de> serde::Deserialize<'de> for PortalSubscriptionUpdateProrationBehavior fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PortalSubscriptionUpdateProrationBehavior") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PortalSubscriptionUpdateProrationBehavior")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PortalSubscriptionUpdateProrationBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PortalSubscriptionUpdateProrationBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalSubscriptionUpdateProrationBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionUpdateProrationBehavior); diff --git a/generated/stripe_billing/src/portal_subscription_update_product.rs b/generated/stripe_billing/src/portal_subscription_update_product.rs index 6eb5cf77c..01af5d8bf 100644 --- a/generated/stripe_billing/src/portal_subscription_update_product.rs +++ b/generated/stripe_billing/src/portal_subscription_update_product.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PortalSubscriptionUpdateProduct { /// The list of price IDs which, when subscribed to, a subscription can be updated. pub prices: Vec<String>, /// The product ID. pub product: String, } +#[cfg(feature = "min-ser")] +pub struct PortalSubscriptionUpdateProductBuilder { + prices: Option<Vec<String>>, + product: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PortalSubscriptionUpdateProduct { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PortalSubscriptionUpdateProduct>, + builder: PortalSubscriptionUpdateProductBuilder, + } + + impl Visitor for Place<PortalSubscriptionUpdateProduct> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PortalSubscriptionUpdateProductBuilder::deser_default() })) + } + } + + impl MapBuilder for PortalSubscriptionUpdateProductBuilder { + type Out = PortalSubscriptionUpdateProduct; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "prices" => Deserialize::begin(&mut self.prices), + "product" => Deserialize::begin(&mut self.product), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { prices: Deserialize::default(), product: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let prices = self.prices.take()?; + let product = self.product.take()?; + + Some(Self::Out { prices, product }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PortalSubscriptionUpdateProduct { + type Builder = PortalSubscriptionUpdateProductBuilder; + } + + impl FromValueOpt for PortalSubscriptionUpdateProduct { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PortalSubscriptionUpdateProductBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "prices" => b.prices = Some(FromValueOpt::from_value(v)?), + "product" => b.product = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_billing/src/quote/requests.rs b/generated/stripe_billing/src/quote/requests.rs index 909de6f16..ff0ffc2c6 100644 --- a/generated/stripe_billing/src/quote/requests.rs +++ b/generated/stripe_billing/src/quote/requests.rs @@ -1,51 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListQuote<'a> { - /// The ID of the customer whose quotes will be retrieved. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// The status of the quote. - #[serde(skip_serializing_if = "Option::is_none")] - pub status: Option<stripe_shared::QuoteStatus>, - /// Provides a list of quotes that are associated with the specified test clock. - /// The response will not include quotes with test clocks if this and the customer parameter is not set. - #[serde(skip_serializing_if = "Option::is_none")] - pub test_clock: Option<&'a str>, -} -impl<'a> ListQuote<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListQuote<'a> { - /// Returns a list of your quotes. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Quote>> { - client.get_query("/quotes", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Quote>> { - stripe::ListPaginator::from_list_params("/quotes", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveQuote<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -58,102 +11,11 @@ impl<'a> RetrieveQuote<'a> { } impl<'a> RetrieveQuote<'a> { /// Retrieves the quote with the given ID. - pub fn send( - &self, - client: &stripe::Client, - quote: &stripe_shared::QuoteId, - ) -> stripe::Response<stripe_shared::Quote> { + pub fn send(&self, client: &stripe::Client, quote: &stripe_shared::QuoteId) -> stripe::Response<stripe_shared::Quote> { client.get_query(&format!("/quotes/{quote}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListComputedUpfrontLineItemsQuote<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListComputedUpfrontLineItemsQuote<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListComputedUpfrontLineItemsQuote<'a> { - /// When retrieving a quote, there is an includable <a href="<https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items>">**computed.upfront.line_items**</a> property containing the first handful of those items. - /// There is also a URL where you can retrieve the full (paginated) list of upfront line items. - pub fn send( - &self, - client: &stripe::Client, - quote: &stripe_shared::QuoteId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { - client.get_query(&format!("/quotes/{quote}/computed_upfront_line_items"), self) - } - pub fn paginate( - self, - quote: &stripe_shared::QuoteId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { - stripe::ListPaginator::from_list_params( - &format!("/quotes/{quote}/computed_upfront_line_items"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListLineItemsQuote<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListLineItemsQuote<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListLineItemsQuote<'a> { - /// When retrieving a quote, there is an includable **line_items** property containing the first handful of those items. - /// There is also a URL where you can retrieve the full (paginated) list of line items. - pub fn send( - &self, - client: &stripe::Client, - quote: &stripe_shared::QuoteId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { - client.get_query(&format!("/quotes/{quote}/line_items"), self) - } - pub fn paginate( - self, - quote: &stripe_shared::QuoteId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { - stripe::ListPaginator::from_list_params(&format!("/quotes/{quote}/line_items"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateQuote<'a> { /// The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. /// There cannot be any line items with recurring prices when using this field. @@ -166,7 +28,7 @@ pub struct CreateQuote<'a> { pub application_fee_percent: Option<f64>, /// Settings for automatic tax lookup for this quote and resulting invoices and subscriptions. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<CreateQuoteAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxParam>, /// Either `charge_automatically`, or `send_invoice`. /// When charging automatically, Stripe will attempt to pay invoices at the end of the subscription cycle or at invoice finalization using the default payment method attached to the subscription or customer. /// When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. @@ -211,7 +73,7 @@ pub struct CreateQuote<'a> { pub header: Option<&'a str>, /// All invoices will be billed using the specified settings. #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<CreateQuoteInvoiceSettings<'a>>, + pub invoice_settings: Option<QuoteParam>, /// A list of line items the customer is being quoted for. /// Each line item includes information about the product, the quantity, and the resulting cost. #[serde(skip_serializing_if = "Option::is_none")] @@ -242,85 +104,6 @@ impl<'a> CreateQuote<'a> { Self::default() } } -/// Settings for automatic tax lookup for this quote and resulting invoices and subscriptions. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateQuoteAutomaticTax<'a> { - /// Controls whether Stripe will automatically compute tax on the resulting invoices or subscriptions as well as the quote itself. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<CreateQuoteAutomaticTaxLiability<'a>>, -} -impl<'a> CreateQuoteAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateQuoteAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateQuoteAutomaticTaxLiabilityType, -} -impl<'a> CreateQuoteAutomaticTaxLiability<'a> { - pub fn new(type_: CreateQuoteAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateQuoteAutomaticTaxLiabilityType { - Account, - Self_, -} -impl CreateQuoteAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use CreateQuoteAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateQuoteAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateQuoteAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateQuoteAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateQuoteAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateQuoteAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Clone an existing quote. /// The new quote will be created in `status=draft`. /// When using this parameter, you cannot specify any other parameters except for `expires_at`. @@ -337,85 +120,6 @@ impl<'a> CreateQuoteFromQuote<'a> { Self { is_revision: None, quote } } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateQuoteInvoiceSettings<'a> { - /// Number of days within which a customer must pay the invoice generated by this quote. - /// This value will be `null` for quotes where `collection_method=charge_automatically`. - #[serde(skip_serializing_if = "Option::is_none")] - pub days_until_due: Option<u32>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreateQuoteInvoiceSettingsIssuer<'a>>, -} -impl<'a> CreateQuoteInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateQuoteInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateQuoteInvoiceSettingsIssuerType, -} -impl<'a> CreateQuoteInvoiceSettingsIssuer<'a> { - pub fn new(type_: CreateQuoteInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateQuoteInvoiceSettingsIssuerType { - Account, - Self_, -} -impl CreateQuoteInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use CreateQuoteInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateQuoteInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateQuoteInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateQuoteInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateQuoteInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateQuoteInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// A list of line items the customer is being quoted for. /// Each line item includes information about the product, the quantity, and the resulting cost. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -468,14 +172,7 @@ pub struct CreateQuoteLineItemsPriceData<'a> { } impl<'a> CreateQuoteLineItemsPriceData<'a> { pub fn new(currency: stripe_types::Currency, product: &'a str) -> Self { - Self { - currency, - product, - recurring: None, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + Self { currency, product, recurring: None, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -485,7 +182,7 @@ pub struct CreateQuoteLineItemsPriceDataRecurring { pub interval: CreateQuoteLineItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -659,7 +356,7 @@ pub struct UpdateQuote<'a> { pub application_fee_percent: Option<f64>, /// Settings for automatic tax lookup for this quote and resulting invoices and subscriptions. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpdateQuoteAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxParam>, /// Either `charge_automatically`, or `send_invoice`. /// When charging automatically, Stripe will attempt to pay invoices at the end of the subscription cycle or at invoice finalization using the default payment method attached to the subscription or customer. /// When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. @@ -695,7 +392,7 @@ pub struct UpdateQuote<'a> { pub header: Option<&'a str>, /// All invoices will be billed using the specified settings. #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<UpdateQuoteInvoiceSettings<'a>>, + pub invoice_settings: Option<QuoteParam>, /// A list of line items the customer is being quoted for. /// Each line item includes information about the product, the quantity, and the resulting cost. #[serde(skip_serializing_if = "Option::is_none")] @@ -723,164 +420,6 @@ impl<'a> UpdateQuote<'a> { Self::default() } } -/// Settings for automatic tax lookup for this quote and resulting invoices and subscriptions. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateQuoteAutomaticTax<'a> { - /// Controls whether Stripe will automatically compute tax on the resulting invoices or subscriptions as well as the quote itself. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpdateQuoteAutomaticTaxLiability<'a>>, -} -impl<'a> UpdateQuoteAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateQuoteAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateQuoteAutomaticTaxLiabilityType, -} -impl<'a> UpdateQuoteAutomaticTaxLiability<'a> { - pub fn new(type_: UpdateQuoteAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateQuoteAutomaticTaxLiabilityType { - Account, - Self_, -} -impl UpdateQuoteAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use UpdateQuoteAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateQuoteAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateQuoteAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateQuoteAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateQuoteAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateQuoteAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateQuoteInvoiceSettings<'a> { - /// Number of days within which a customer must pay the invoice generated by this quote. - /// This value will be `null` for quotes where `collection_method=charge_automatically`. - #[serde(skip_serializing_if = "Option::is_none")] - pub days_until_due: Option<u32>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpdateQuoteInvoiceSettingsIssuer<'a>>, -} -impl<'a> UpdateQuoteInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateQuoteInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateQuoteInvoiceSettingsIssuerType, -} -impl<'a> UpdateQuoteInvoiceSettingsIssuer<'a> { - pub fn new(type_: UpdateQuoteInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateQuoteInvoiceSettingsIssuerType { - Account, - Self_, -} -impl UpdateQuoteInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use UpdateQuoteInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateQuoteInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateQuoteInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateQuoteInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateQuoteInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateQuoteInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// A list of line items the customer is being quoted for. /// Each line item includes information about the product, the quantity, and the resulting cost. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -936,14 +475,7 @@ pub struct UpdateQuoteLineItemsPriceData<'a> { } impl<'a> UpdateQuoteLineItemsPriceData<'a> { pub fn new(currency: stripe_types::Currency, product: &'a str) -> Self { - Self { - currency, - product, - recurring: None, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + Self { currency, product, recurring: None, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -953,7 +485,7 @@ pub struct UpdateQuoteLineItemsPriceDataRecurring { pub interval: UpdateQuoteLineItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -1109,15 +641,49 @@ pub enum UpdateQuoteSubscriptionDataEffectiveDate { } impl<'a> UpdateQuote<'a> { /// A quote models prices and services for a customer. - pub fn send( - &self, - client: &stripe::Client, - quote: &stripe_shared::QuoteId, - ) -> stripe::Response<stripe_shared::Quote> { + pub fn send(&self, client: &stripe::Client, quote: &stripe_shared::QuoteId) -> stripe::Response<stripe_shared::Quote> { client.send_form(&format!("/quotes/{quote}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CancelQuote<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> CancelQuote<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> CancelQuote<'a> { + /// Cancels the quote. + pub fn send(&self, client: &stripe::Client, quote: &stripe_shared::QuoteId) -> stripe::Response<stripe_shared::Quote> { + client.send_form(&format!("/quotes/{quote}/cancel"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct FinalizeQuoteQuote<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A future timestamp on which the quote will be canceled if in `open` or `draft` status. + /// Measured in seconds since the Unix epoch. + #[serde(skip_serializing_if = "Option::is_none")] + pub expires_at: Option<stripe_types::Timestamp>, +} +impl<'a> FinalizeQuoteQuote<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> FinalizeQuoteQuote<'a> { + /// Finalizes the quote. + pub fn send(&self, client: &stripe::Client, quote: &stripe_shared::QuoteId) -> stripe::Response<stripe_shared::Quote> { + client.send_form(&format!("/quotes/{quote}/finalize"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct AcceptQuote<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -1130,58 +696,132 @@ impl<'a> AcceptQuote<'a> { } impl<'a> AcceptQuote<'a> { /// Accepts the specified quote. - pub fn send( - &self, - client: &stripe::Client, - quote: &stripe_shared::QuoteId, - ) -> stripe::Response<stripe_shared::Quote> { + pub fn send(&self, client: &stripe::Client, quote: &stripe_shared::QuoteId) -> stripe::Response<stripe_shared::Quote> { client.send_form(&format!("/quotes/{quote}/accept"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelQuote<'a> { +pub struct ListQuote<'a> { + /// The ID of the customer whose quotes will be retrieved. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// The status of the quote. + #[serde(skip_serializing_if = "Option::is_none")] + pub status: Option<stripe_shared::QuoteStatus>, + /// Provides a list of quotes that are associated with the specified test clock. + /// The response will not include quotes with test clocks if this and the customer parameter is not set. + #[serde(skip_serializing_if = "Option::is_none")] + pub test_clock: Option<&'a str>, } -impl<'a> CancelQuote<'a> { +impl<'a> ListQuote<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> CancelQuote<'a> { - /// Cancels the quote. - pub fn send( - &self, - client: &stripe::Client, - quote: &stripe_shared::QuoteId, - ) -> stripe::Response<stripe_shared::Quote> { - client.send_form(&format!("/quotes/{quote}/cancel"), self, http_types::Method::Post) +impl<'a> ListQuote<'a> { + /// Returns a list of your quotes. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Quote>> { + client.get_query("/quotes", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Quote>> { + stripe::ListPaginator::from_list_params("/quotes", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct FinalizeQuoteQuote<'a> { +pub struct ListLineItemsQuote<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// A future timestamp on which the quote will be canceled if in `open` or `draft` status. - /// Measured in seconds since the Unix epoch. + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. #[serde(skip_serializing_if = "Option::is_none")] - pub expires_at: Option<stripe_types::Timestamp>, + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, } -impl<'a> FinalizeQuoteQuote<'a> { +impl<'a> ListLineItemsQuote<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> FinalizeQuoteQuote<'a> { - /// Finalizes the quote. - pub fn send( - &self, - client: &stripe::Client, - quote: &stripe_shared::QuoteId, - ) -> stripe::Response<stripe_shared::Quote> { - client.send_form(&format!("/quotes/{quote}/finalize"), self, http_types::Method::Post) +impl<'a> ListLineItemsQuote<'a> { + /// When retrieving a quote, there is an includable **line_items** property containing the first handful of those items. + /// There is also a URL where you can retrieve the full (paginated) list of line items. + pub fn send(&self, client: &stripe::Client, quote: &stripe_shared::QuoteId) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + client.get_query(&format!("/quotes/{quote}/line_items"), self) + } + pub fn paginate(self, quote: &stripe_shared::QuoteId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + stripe::ListPaginator::from_list_params(&format!("/quotes/{quote}/line_items"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListComputedUpfrontLineItemsQuote<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListComputedUpfrontLineItemsQuote<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListComputedUpfrontLineItemsQuote<'a> { + /// When retrieving a quote, there is an includable <a href="<https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items>">**computed.upfront.line_items**</a> property containing the first handful of those items. + /// There is also a URL where you can retrieve the full (paginated) list of upfront line items. + pub fn send(&self, client: &stripe::Client, quote: &stripe_shared::QuoteId) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + client.get_query(&format!("/quotes/{quote}/computed_upfront_line_items"), self) + } + pub fn paginate(self, quote: &stripe_shared::QuoteId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + stripe::ListPaginator::from_list_params(&format!("/quotes/{quote}/computed_upfront_line_items"), self) + } +} +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct AutomaticTaxParam { + /// Controls whether Stripe will automatically compute tax on the resulting invoices or subscriptions as well as the quote itself. + pub enabled: bool, +} +impl AutomaticTaxParam { + pub fn new(enabled: bool) -> Self { + Self { enabled } } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -1198,6 +838,18 @@ impl<'a> DiscountsDataParam<'a> { Self::default() } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct QuoteParam { + /// Number of days within which a customer must pay the invoice generated by this quote. + /// This value will be `null` for quotes where `collection_method=charge_automatically`. + #[serde(skip_serializing_if = "Option::is_none")] + pub days_until_due: Option<u32>, +} +impl QuoteParam { + pub fn new() -> Self { + Self::default() + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct TransferDataSpecs<'a> { /// The amount that will be transferred automatically when the invoice is paid. diff --git a/generated/stripe_billing/src/subscription/requests.rs b/generated/stripe_billing/src/subscription/requests.rs index 42f686a8a..a3e933211 100644 --- a/generated/stripe_billing/src/subscription/requests.rs +++ b/generated/stripe_billing/src/subscription/requests.rs @@ -1,145 +1,38 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelSubscription<'a> { - /// Details about why this subscription was cancelled - #[serde(skip_serializing_if = "Option::is_none")] - pub cancellation_details: Option<CancelSubscriptionCancellationDetails<'a>>, +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct SearchSubscription<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_now: Option<bool>, - /// Will generate a proration invoice item that credits remaining unused time until the subscription period end. - #[serde(skip_serializing_if = "Option::is_none")] - pub prorate: Option<bool>, -} -impl<'a> CancelSubscription<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Details about why this subscription was cancelled -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelSubscriptionCancellationDetails<'a> { - /// Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user. + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. #[serde(skip_serializing_if = "Option::is_none")] - pub comment: Option<&'a str>, - /// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user. + pub limit: Option<i64>, + /// A cursor for pagination across multiple pages of results. + /// Don't include this parameter on the first call. + /// Use the next_page value returned in a previous response to request subsequent results. #[serde(skip_serializing_if = "Option::is_none")] - pub feedback: Option<CancelSubscriptionCancellationDetailsFeedback>, -} -impl<'a> CancelSubscriptionCancellationDetails<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CancelSubscriptionCancellationDetailsFeedback { - CustomerService, - LowQuality, - MissingFeatures, - Other, - SwitchedService, - TooComplex, - TooExpensive, - Unused, -} -impl CancelSubscriptionCancellationDetailsFeedback { - pub fn as_str(self) -> &'static str { - use CancelSubscriptionCancellationDetailsFeedback::*; - match self { - CustomerService => "customer_service", - LowQuality => "low_quality", - MissingFeatures => "missing_features", - Other => "other", - SwitchedService => "switched_service", - TooComplex => "too_complex", - TooExpensive => "too_expensive", - Unused => "unused", - } - } -} - -impl std::str::FromStr for CancelSubscriptionCancellationDetailsFeedback { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CancelSubscriptionCancellationDetailsFeedback::*; - match s { - "customer_service" => Ok(CustomerService), - "low_quality" => Ok(LowQuality), - "missing_features" => Ok(MissingFeatures), - "other" => Ok(Other), - "switched_service" => Ok(SwitchedService), - "too_complex" => Ok(TooComplex), - "too_expensive" => Ok(TooExpensive), - "unused" => Ok(Unused), - _ => Err(()), - } - } -} -impl std::fmt::Display for CancelSubscriptionCancellationDetailsFeedback { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CancelSubscriptionCancellationDetailsFeedback { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CancelSubscriptionCancellationDetailsFeedback { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } + pub page: Option<&'a str>, + /// The search query string. + /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for subscriptions](https://stripe.com/docs/search#query-fields-for-subscriptions). + pub query: &'a str, } -impl<'a> CancelSubscription<'a> { - /// Cancels a customer’s subscription immediately. - /// The customer will not be charged again for the subscription. - /// - /// Note, however, that any pending invoice items that you’ve created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). - /// If you’ve set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. - /// But if the subscription is set to cancel immediately, pending prorations will be removed. - /// - /// By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. - /// This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. - /// However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. - /// Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. - pub fn send( - &self, - client: &stripe::Client, - subscription_exposed_id: &stripe_shared::SubscriptionId, - ) -> stripe::Response<stripe_shared::Subscription> { - client.send_form( - &format!("/subscriptions/{subscription_exposed_id}"), - self, - http_types::Method::Delete, - ) +impl<'a> SearchSubscription<'a> { + pub fn new(query: &'a str) -> Self { + Self { expand: None, limit: None, page: None, query } } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteDiscountSubscription {} -impl DeleteDiscountSubscription { - pub fn new() -> Self { - Self::default() +impl<'a> SearchSubscription<'a> { + /// Search for subscriptions you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). + /// Don’t use search in read-after-write flows where strict consistency is necessary. + /// Under normal operating. + /// conditions, data is searchable in less than a minute. + /// Occasionally, propagation of new or updated data can be up. + /// to an hour behind during outages. Search functionality is not available to merchants in India. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::SearchList<stripe_shared::Subscription>> { + client.get_query("/subscriptions/search", self) } -} -impl DeleteDiscountSubscription { - /// Removes the currently applied discount on a subscription. - pub fn send( - &self, - client: &stripe::Client, - subscription_exposed_id: &stripe_shared::SubscriptionId, - ) -> stripe::Response<stripe_shared::DeletedDiscount> { - client.send_form( - &format!("/subscriptions/{subscription_exposed_id}/discount"), - self, - http_types::Method::Delete, - ) + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Subscription>> { + stripe::ListPaginator::from_search_params("/subscriptions/search", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -288,81 +181,13 @@ impl serde::Serialize for ListSubscriptionStatus { impl<'a> ListSubscription<'a> { /// By default, returns a list of subscriptions that have not been canceled. /// In order to list canceled subscriptions, specify `status=canceled`. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Subscription>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Subscription>> { client.get_query("/subscriptions", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Subscription>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Subscription>> { stripe::ListPaginator::from_list_params("/subscriptions", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveSubscription<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveSubscription<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveSubscription<'a> { - /// Retrieves the subscription with the given ID. - pub fn send( - &self, - client: &stripe::Client, - subscription_exposed_id: &stripe_shared::SubscriptionId, - ) -> stripe::Response<stripe_shared::Subscription> { - client.get_query(&format!("/subscriptions/{subscription_exposed_id}"), self) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct SearchSubscription<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for pagination across multiple pages of results. - /// Don't include this parameter on the first call. - /// Use the next_page value returned in a previous response to request subsequent results. - #[serde(skip_serializing_if = "Option::is_none")] - pub page: Option<&'a str>, - /// The search query string. - /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for subscriptions](https://stripe.com/docs/search#query-fields-for-subscriptions). - pub query: &'a str, -} -impl<'a> SearchSubscription<'a> { - pub fn new(query: &'a str) -> Self { - Self { expand: None, limit: None, page: None, query } - } -} -impl<'a> SearchSubscription<'a> { - /// Search for subscriptions you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). - /// Don’t use search in read-after-write flows where strict consistency is necessary. - /// Under normal operating. - /// conditions, data is searchable in less than a minute. - /// Occasionally, propagation of new or updated data can be up. - /// to an hour behind during outages. Search functionality is not available to merchants in India. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::SearchList<stripe_shared::Subscription>> { - client.get_query("/subscriptions/search", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Subscription>> { - stripe::ListPaginator::from_search_params("/subscriptions/search", self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateSubscription<'a> { /// A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. @@ -378,21 +203,17 @@ pub struct CreateSubscription<'a> { /// Automatic tax settings for this subscription. /// We recommend you only include this parameter when the existing value is being changed. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<CreateSubscriptionAutomaticTax<'a>>, + pub automatic_tax: Option<CreateSubscriptionAutomaticTax>, /// For new subscriptions, a past timestamp to backdate the subscription's start date to. /// If set, the first invoice will contain a proration for the timespan between the start date and the current time. /// Can be combined with trials and the billing cycle anchor. #[serde(skip_serializing_if = "Option::is_none")] pub backdate_start_date: Option<stripe_types::Timestamp>, - /// A future timestamp in UTC format to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). - /// The anchor is the reference point that aligns future billing cycle dates. - /// It sets the day of week for `week` intervals, the day of month for `month` and `year` intervals, and the month of year for `year` intervals. + /// A future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). + /// This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. + /// The timestamp is in UTC format. #[serde(skip_serializing_if = "Option::is_none")] pub billing_cycle_anchor: Option<stripe_types::Timestamp>, - /// Mutually exclusive with billing_cycle_anchor and only valid with monthly and yearly price intervals. - /// When provided, the billing_cycle_anchor is set to the next occurence of the day_of_month at the hour, minute, and second UTC. - #[serde(skip_serializing_if = "Option::is_none")] - pub billing_cycle_anchor_config: Option<CreateSubscriptionBillingCycleAnchorConfig>, /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. /// Pass an empty string to remove previously-defined thresholds. #[serde(skip_serializing_if = "Option::is_none")] @@ -448,9 +269,6 @@ pub struct CreateSubscription<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// All invoices will be billed using the specified settings. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<CreateSubscriptionInvoiceSettings<'a>>, /// A list of up to 20 subscription items, each with an attached price. #[serde(skip_serializing_if = "Option::is_none")] pub items: Option<&'a [CreateSubscriptionItems<'a>]>, @@ -538,7 +356,6 @@ impl<'a> CreateSubscription<'a> { automatic_tax: None, backdate_start_date: None, billing_cycle_anchor: None, - billing_cycle_anchor_config: None, billing_thresholds: None, cancel_at: None, cancel_at_period_end: None, @@ -552,7 +369,6 @@ impl<'a> CreateSubscription<'a> { default_tax_rates: None, description: None, expand: None, - invoice_settings: None, items: None, metadata: None, off_session: None, @@ -674,218 +490,47 @@ impl serde::Serialize for CreateSubscriptionAddInvoiceItemsPriceDataTaxBehavior /// Automatic tax settings for this subscription. /// We recommend you only include this parameter when the existing value is being changed. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionAutomaticTax<'a> { +pub struct CreateSubscriptionAutomaticTax { /// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<CreateSubscriptionAutomaticTaxLiability<'a>>, } -impl<'a> CreateSubscriptionAutomaticTax<'a> { +impl CreateSubscriptionAutomaticTax { pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } + Self { enabled } } } -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. +/// A list of up to 20 subscription items, each with an attached price. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreateSubscriptionItems<'a> { + /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. + /// When updating, pass an empty string to remove previously-defined thresholds. #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateSubscriptionAutomaticTaxLiabilityType, -} -impl<'a> CreateSubscriptionAutomaticTaxLiability<'a> { - pub fn new(type_: CreateSubscriptionAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionAutomaticTaxLiabilityType { - Account, - Self_, -} -impl CreateSubscriptionAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use CreateSubscriptionAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateSubscriptionAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSubscriptionAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSubscriptionAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSubscriptionAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSubscriptionAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Mutually exclusive with billing_cycle_anchor and only valid with monthly and yearly price intervals. -/// When provided, the billing_cycle_anchor is set to the next occurence of the day_of_month at the hour, minute, and second UTC. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionBillingCycleAnchorConfig { - /// The day of the month the billing_cycle_anchor should be. Ranges from 1 to 31. - pub day_of_month: i64, - /// The hour of the day the billing_cycle_anchor should be. Ranges from 0 to 23. + pub billing_thresholds: Option<ItemBillingThresholdsParam>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. #[serde(skip_serializing_if = "Option::is_none")] - pub hour: Option<i64>, - /// The minute of the hour the billing_cycle_anchor should be. Ranges from 0 to 59. + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// Plan ID for this item, as a string. #[serde(skip_serializing_if = "Option::is_none")] - pub minute: Option<i64>, - /// The month to start full cycle billing periods. Ranges from 1 to 12. + pub plan: Option<&'a str>, + /// The ID of the price object. #[serde(skip_serializing_if = "Option::is_none")] - pub month: Option<i64>, - /// The second of the minute the billing_cycle_anchor should be. Ranges from 0 to 59. + pub price: Option<&'a str>, + /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[serde(skip_serializing_if = "Option::is_none")] - pub second: Option<i64>, -} -impl CreateSubscriptionBillingCycleAnchorConfig { - pub fn new(day_of_month: i64) -> Self { - Self { day_of_month, hour: None, minute: None, month: None, second: None } - } -} -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSubscriptionInvoiceSettings<'a> { - /// The account tax IDs associated with the subscription. - /// Will be set on invoices generated by the subscription. + pub price_data: Option<CreateSubscriptionItemsPriceData<'a>>, + /// Quantity for this item. #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<&'a [&'a str]>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. + pub quantity: Option<u64>, + /// A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. + /// These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. + /// When updating, pass an empty string to remove previously-defined tax rates. #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreateSubscriptionInvoiceSettingsIssuer<'a>>, + pub tax_rates: Option<&'a [&'a str]>, } -impl<'a> CreateSubscriptionInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateSubscriptionInvoiceSettingsIssuerType, -} -impl<'a> CreateSubscriptionInvoiceSettingsIssuer<'a> { - pub fn new(type_: CreateSubscriptionInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionInvoiceSettingsIssuerType { - Account, - Self_, -} -impl CreateSubscriptionInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use CreateSubscriptionInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateSubscriptionInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSubscriptionInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSubscriptionInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSubscriptionInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSubscriptionInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// A list of up to 20 subscription items, each with an attached price. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSubscriptionItems<'a> { - /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. - /// When updating, pass an empty string to remove previously-defined thresholds. - #[serde(skip_serializing_if = "Option::is_none")] - pub billing_thresholds: Option<ItemBillingThresholdsParam>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Plan ID for this item, as a string. - #[serde(skip_serializing_if = "Option::is_none")] - pub plan: Option<&'a str>, - /// The ID of the price object. - #[serde(skip_serializing_if = "Option::is_none")] - pub price: Option<&'a str>, - /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. - #[serde(skip_serializing_if = "Option::is_none")] - pub price_data: Option<CreateSubscriptionItemsPriceData<'a>>, - /// Quantity for this item. - #[serde(skip_serializing_if = "Option::is_none")] - pub quantity: Option<u64>, - /// A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. - /// These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. - /// When updating, pass an empty string to remove previously-defined tax rates. - #[serde(skip_serializing_if = "Option::is_none")] - pub tax_rates: Option<&'a [&'a str]>, -} -impl<'a> CreateSubscriptionItems<'a> { +impl<'a> CreateSubscriptionItems<'a> { pub fn new() -> Self { Self::default() } @@ -915,19 +560,8 @@ pub struct CreateSubscriptionItemsPriceData<'a> { pub unit_amount_decimal: Option<&'a str>, } impl<'a> CreateSubscriptionItemsPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: CreateSubscriptionItemsPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: CreateSubscriptionItemsPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -937,7 +571,7 @@ pub struct CreateSubscriptionItemsPriceDataRecurring { pub interval: CreateSubscriptionItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -1137,8 +771,7 @@ pub struct CreateSubscriptionPaymentSettings<'a> { /// Either `off`, or `on_subscription`. /// With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds. #[serde(skip_serializing_if = "Option::is_none")] - pub save_default_payment_method: - Option<CreateSubscriptionPaymentSettingsSaveDefaultPaymentMethod>, + pub save_default_payment_method: Option<CreateSubscriptionPaymentSettingsSaveDefaultPaymentMethod>, } impl<'a> CreateSubscriptionPaymentSettings<'a> { pub fn new() -> Self { @@ -1165,8 +798,7 @@ pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub konbini: Option<&'a serde_json::Value>, /// This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, + pub us_bank_account: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, } impl<'a> CreateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub fn new() -> Self { @@ -1178,12 +810,10 @@ impl<'a> CreateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, + pub mandate_options: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, } impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebit { pub fn new() -> Self { @@ -1195,9 +825,7 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebit { pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: Option< - CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType, - >, + pub transaction_type: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { pub fn new() -> Self { @@ -1206,8 +834,7 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOption } /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { Business, Personal, } @@ -1221,9 +848,7 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOption } } -impl std::str::FromStr - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -1234,24 +859,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1277,9 +896,7 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationM } } -impl std::str::FromStr - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; @@ -1291,24 +908,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Display for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1321,8 +932,7 @@ impl serde::Serialize pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_language: - Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, + pub preferred_language: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, } impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontact { pub fn new() -> Self { @@ -1349,9 +959,7 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLan } } -impl std::str::FromStr - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; @@ -1364,24 +972,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Display for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1394,8 +996,7 @@ impl serde::Serialize pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { /// Configuration options for setting up an eMandate for cards issued in India. #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions<'a>>, + pub mandate_options: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions<'a>>, /// Selected network to process this Subscription on. /// Depends on the available networks of the card attached to the Subscription. /// Can be only set confirm-time. @@ -1405,8 +1006,7 @@ pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, + pub request_three_d_secure: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, } impl<'a> CreateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -1423,8 +1023,7 @@ pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptio /// If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. /// If `maximum`, the amount charged can be up to the value passed for the `amount` param. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_type: - Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType>, + pub amount_type: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType>, /// A description of the mandate or subscription that is meant to be displayed to the customer. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<&'a str>, @@ -1452,9 +1051,7 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmou } } -impl std::str::FromStr - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType::*; @@ -1465,24 +1062,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl std::fmt::Display for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1572,7 +1163,6 @@ impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsC pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -1580,43 +1170,33 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecur match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } -impl std::str::FromStr - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } } -impl std::fmt::Display - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl std::fmt::Display for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1629,14 +1209,10 @@ impl serde::Serialize pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: Option< - CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>, - >, + pub financial_connections: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: Option< - CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod, - >, + pub verification_method: Option<CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -1646,19 +1222,16 @@ impl<'a> CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> /// Additional fields for Financial Connections Session creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { - /// The list of permissions to request. + /// The list of permissions to request. /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. -#[serde(skip_serializing_if = "Option::is_none")] -pub permissions: Option<&'a [CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, + #[serde(skip_serializing_if = "Option::is_none")] + pub permissions: Option<&'a [CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. -#[serde(skip_serializing_if = "Option::is_none")] -pub prefetch: Option<&'a [CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, - + #[serde(skip_serializing_if = "Option::is_none")] + pub prefetch: Option<&'a [CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, } -impl<'a> - CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> -{ +impl<'a> CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { pub fn new() -> Self { Self::default() } @@ -1667,8 +1240,7 @@ impl<'a> /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { Balances, Ownership, PaymentMethod, @@ -1678,11 +1250,10 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancial pub fn as_str(self) -> &'static str { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; match self { -Balances => "balances", -Ownership => "ownership", -PaymentMethod => "payment_method", -Transactions => "transactions", - + Balances => "balances", + Ownership => "ownership", + PaymentMethod => "payment_method", + Transactions => "transactions", } } } @@ -1692,12 +1263,11 @@ impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptions fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; match s { - "balances" => Ok(Balances), -"ownership" => Ok(Ownership), -"payment_method" => Ok(PaymentMethod), -"transactions" => Ok(Transactions), -_ => Err(()) - + "balances" => Ok(Balances), + "ownership" => Ok(Ownership), + "payment_method" => Ok(PaymentMethod), + "transactions" => Ok(Transactions), + _ => Err(()), } } } @@ -1713,25 +1283,23 @@ impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUs } } impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } -impl - CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } @@ -1741,10 +1309,8 @@ impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptions fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { - "balances" => Ok(Balances), -"transactions" => Ok(Transactions), -_ => Err(()) - + "balances" => Ok(Balances), + _ => Err(()), } } } @@ -1760,7 +1326,10 @@ impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUs } } impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } @@ -1782,9 +1351,7 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificat } } -impl std::str::FromStr - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; @@ -1796,24 +1363,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::fmt::Display for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::fmt::Debug for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1837,14 +1398,12 @@ pub enum CreateSubscriptionPaymentSettingsPaymentMethodTypes { Card, Cashapp, CustomerBalance, - Eps, Fpx, Giropay, Grabpay, Ideal, Konbini, Link, - P24, Paynow, Paypal, Promptpay, @@ -1870,14 +1429,12 @@ impl CreateSubscriptionPaymentSettingsPaymentMethodTypes { Card => "card", Cashapp => "cashapp", CustomerBalance => "customer_balance", - Eps => "eps", Fpx => "fpx", Giropay => "giropay", Grabpay => "grabpay", Ideal => "ideal", Konbini => "konbini", Link => "link", - P24 => "p24", Paynow => "paynow", Paypal => "paypal", Promptpay => "promptpay", @@ -1906,14 +1463,12 @@ impl std::str::FromStr for CreateSubscriptionPaymentSettingsPaymentMethodTypes { "card" => Ok(Card), "cashapp" => Ok(Cashapp), "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), "fpx" => Ok(Fpx), "giropay" => Ok(Giropay), "grabpay" => Ok(Grabpay), "ideal" => Ok(Ideal), "konbini" => Ok(Konbini), "link" => Ok(Link), - "p24" => Ok(P24), "paynow" => Ok(Paynow), "paypal" => Ok(Paypal), "promptpay" => Ok(Promptpay), @@ -2140,9 +1695,7 @@ pub struct CreateSubscriptionTrialSettingsEndBehavior { pub missing_payment_method: CreateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod, } impl CreateSubscriptionTrialSettingsEndBehavior { - pub fn new( - missing_payment_method: CreateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod, - ) -> Self { + pub fn new(missing_payment_method: CreateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod) -> Self { Self { missing_payment_method } } } @@ -2209,147 +1762,6 @@ impl<'a> CreateSubscription<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ResumeSubscription<'a> { - /// Either `now` or `unchanged`. - /// Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). - /// Setting the value to `unchanged` advances the subscription's billing cycle anchor to the period that surrounds the current time. - /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). - #[serde(skip_serializing_if = "Option::is_none")] - pub billing_cycle_anchor: Option<ResumeSubscriptionBillingCycleAnchor>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. - /// The default value is `create_prorations`. - #[serde(skip_serializing_if = "Option::is_none")] - pub proration_behavior: Option<ResumeSubscriptionProrationBehavior>, - /// If set, the proration will be calculated as though the subscription was resumed at the given time. - /// This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - pub proration_date: Option<stripe_types::Timestamp>, -} -impl<'a> ResumeSubscription<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Either `now` or `unchanged`. -/// Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). -/// Setting the value to `unchanged` advances the subscription's billing cycle anchor to the period that surrounds the current time. -/// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ResumeSubscriptionBillingCycleAnchor { - Now, - Unchanged, -} -impl ResumeSubscriptionBillingCycleAnchor { - pub fn as_str(self) -> &'static str { - use ResumeSubscriptionBillingCycleAnchor::*; - match self { - Now => "now", - Unchanged => "unchanged", - } - } -} - -impl std::str::FromStr for ResumeSubscriptionBillingCycleAnchor { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ResumeSubscriptionBillingCycleAnchor::*; - match s { - "now" => Ok(Now), - "unchanged" => Ok(Unchanged), - _ => Err(()), - } - } -} -impl std::fmt::Display for ResumeSubscriptionBillingCycleAnchor { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ResumeSubscriptionBillingCycleAnchor { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ResumeSubscriptionBillingCycleAnchor { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. -/// The default value is `create_prorations`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ResumeSubscriptionProrationBehavior { - AlwaysInvoice, - CreateProrations, - None, -} -impl ResumeSubscriptionProrationBehavior { - pub fn as_str(self) -> &'static str { - use ResumeSubscriptionProrationBehavior::*; - match self { - AlwaysInvoice => "always_invoice", - CreateProrations => "create_prorations", - None => "none", - } - } -} - -impl std::str::FromStr for ResumeSubscriptionProrationBehavior { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ResumeSubscriptionProrationBehavior::*; - match s { - "always_invoice" => Ok(AlwaysInvoice), - "create_prorations" => Ok(CreateProrations), - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for ResumeSubscriptionProrationBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ResumeSubscriptionProrationBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ResumeSubscriptionProrationBehavior { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> ResumeSubscription<'a> { - /// Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. - /// If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. - /// If payment succeeds the subscription will become `active`, and if payment fails the subscription will be `past_due`. - /// The resumption invoice will void automatically if not paid by the expiration date. - pub fn send( - &self, - client: &stripe::Client, - subscription: &stripe_shared::SubscriptionId, - ) -> stripe::Response<stripe_shared::Subscription> { - client.send_form( - &format!("/subscriptions/{subscription}/resume"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscription<'a> { /// A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. /// You may pass up to 20 items. @@ -2364,7 +1776,7 @@ pub struct UpdateSubscription<'a> { /// Automatic tax settings for this subscription. /// We recommend you only include this parameter when the existing value is being changed. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpdateSubscriptionAutomaticTax<'a>>, + pub automatic_tax: Option<UpdateSubscriptionAutomaticTax>, /// Either `now` or `unchanged`. /// Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -2423,9 +1835,6 @@ pub struct UpdateSubscription<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// All invoices will be billed using the specified settings. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<UpdateSubscriptionInvoiceSettings<'a>>, /// A list of up to 20 subscription items, each with an attached price. #[serde(skip_serializing_if = "Option::is_none")] pub items: Option<&'a [UpdateSubscriptionItems<'a>]>, @@ -2613,124 +2022,56 @@ impl serde::Serialize for UpdateSubscriptionAddInvoiceItemsPriceDataTaxBehavior /// Automatic tax settings for this subscription. /// We recommend you only include this parameter when the existing value is being changed. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionAutomaticTax<'a> { +pub struct UpdateSubscriptionAutomaticTax { /// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpdateSubscriptionAutomaticTaxLiability<'a>>, } -impl<'a> UpdateSubscriptionAutomaticTax<'a> { +impl UpdateSubscriptionAutomaticTax { pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateSubscriptionAutomaticTaxLiabilityType, -} -impl<'a> UpdateSubscriptionAutomaticTaxLiability<'a> { - pub fn new(type_: UpdateSubscriptionAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } + Self { enabled } } } -/// Type of the account referenced in the request. +/// Either `now` or `unchanged`. +/// Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). +/// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionAutomaticTaxLiabilityType { - Account, - Self_, +pub enum UpdateSubscriptionBillingCycleAnchor { + Now, + Unchanged, } -impl UpdateSubscriptionAutomaticTaxLiabilityType { +impl UpdateSubscriptionBillingCycleAnchor { pub fn as_str(self) -> &'static str { - use UpdateSubscriptionAutomaticTaxLiabilityType::*; + use UpdateSubscriptionBillingCycleAnchor::*; match self { - Account => "account", - Self_ => "self", + Now => "now", + Unchanged => "unchanged", } } } -impl std::str::FromStr for UpdateSubscriptionAutomaticTaxLiabilityType { +impl std::str::FromStr for UpdateSubscriptionBillingCycleAnchor { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSubscriptionAutomaticTaxLiabilityType::*; + use UpdateSubscriptionBillingCycleAnchor::*; match s { - "account" => Ok(Account), - "self" => Ok(Self_), + "now" => Ok(Now), + "unchanged" => Ok(Unchanged), _ => Err(()), } } } -impl std::fmt::Display for UpdateSubscriptionAutomaticTaxLiabilityType { +impl std::fmt::Display for UpdateSubscriptionBillingCycleAnchor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateSubscriptionAutomaticTaxLiabilityType { +impl std::fmt::Debug for UpdateSubscriptionBillingCycleAnchor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateSubscriptionAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Either `now` or `unchanged`. -/// Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). -/// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionBillingCycleAnchor { - Now, - Unchanged, -} -impl UpdateSubscriptionBillingCycleAnchor { - pub fn as_str(self) -> &'static str { - use UpdateSubscriptionBillingCycleAnchor::*; - match self { - Now => "now", - Unchanged => "unchanged", - } - } -} - -impl std::str::FromStr for UpdateSubscriptionBillingCycleAnchor { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSubscriptionBillingCycleAnchor::*; - match s { - "now" => Ok(Now), - "unchanged" => Ok(Unchanged), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSubscriptionBillingCycleAnchor { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSubscriptionBillingCycleAnchor { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSubscriptionBillingCycleAnchor { +impl serde::Serialize for UpdateSubscriptionBillingCycleAnchor { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2817,85 +2158,6 @@ impl serde::Serialize for UpdateSubscriptionCancellationDetailsFeedback { serializer.serialize_str(self.as_str()) } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateSubscriptionInvoiceSettings<'a> { - /// The account tax IDs associated with the subscription. - /// Will be set on invoices generated by the subscription. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<&'a [&'a str]>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpdateSubscriptionInvoiceSettingsIssuer<'a>>, -} -impl<'a> UpdateSubscriptionInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateSubscriptionInvoiceSettingsIssuerType, -} -impl<'a> UpdateSubscriptionInvoiceSettingsIssuer<'a> { - pub fn new(type_: UpdateSubscriptionInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionInvoiceSettingsIssuerType { - Account, - Self_, -} -impl UpdateSubscriptionInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use UpdateSubscriptionInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateSubscriptionInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSubscriptionInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSubscriptionInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSubscriptionInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSubscriptionInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// A list of up to 20 subscription items, each with an attached price. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionItems<'a> { @@ -2968,19 +2230,8 @@ pub struct UpdateSubscriptionItemsPriceData<'a> { pub unit_amount_decimal: Option<&'a str>, } impl<'a> UpdateSubscriptionItemsPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: UpdateSubscriptionItemsPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: UpdateSubscriptionItemsPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -2990,7 +2241,7 @@ pub struct UpdateSubscriptionItemsPriceDataRecurring { pub interval: UpdateSubscriptionItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -3250,8 +2501,7 @@ pub struct UpdateSubscriptionPaymentSettings<'a> { /// Either `off`, or `on_subscription`. /// With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds. #[serde(skip_serializing_if = "Option::is_none")] - pub save_default_payment_method: - Option<UpdateSubscriptionPaymentSettingsSaveDefaultPaymentMethod>, + pub save_default_payment_method: Option<UpdateSubscriptionPaymentSettingsSaveDefaultPaymentMethod>, } impl<'a> UpdateSubscriptionPaymentSettings<'a> { pub fn new() -> Self { @@ -3278,8 +2528,7 @@ pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub konbini: Option<&'a serde_json::Value>, /// This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, + pub us_bank_account: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a>>, } impl<'a> UpdateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub fn new() -> Self { @@ -3291,12 +2540,10 @@ impl<'a> UpdateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, + pub mandate_options: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod>, } impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebit { pub fn new() -> Self { @@ -3308,9 +2555,7 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebit { pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: Option< - UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType, - >, + pub transaction_type: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptions { pub fn new() -> Self { @@ -3319,8 +2564,7 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOption } /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { Business, Personal, } @@ -3334,9 +2578,7 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOption } } -impl std::str::FromStr - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -3347,24 +2589,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3390,9 +2626,7 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationM } } -impl std::str::FromStr - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod::*; @@ -3404,24 +2638,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Display for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod -{ +impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3434,8 +2662,7 @@ impl serde::Serialize pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_language: - Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, + pub preferred_language: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage>, } impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontact { pub fn new() -> Self { @@ -3462,9 +2689,7 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLan } } -impl std::str::FromStr - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage::*; @@ -3477,24 +2702,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Display for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage -{ +impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3507,8 +2726,7 @@ impl serde::Serialize pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { /// Configuration options for setting up an eMandate for cards issued in India. #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions<'a>>, + pub mandate_options: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptions<'a>>, /// Selected network to process this Subscription on. /// Depends on the available networks of the card attached to the Subscription. /// Can be only set confirm-time. @@ -3518,8 +2736,7 @@ pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, + pub request_three_d_secure: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure>, } impl<'a> UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -3536,8 +2753,7 @@ pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptio /// If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. /// If `maximum`, the amount charged can be up to the value passed for the `amount` param. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_type: - Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType>, + pub amount_type: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType>, /// A description of the mandate or subscription that is meant to be displayed to the customer. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<&'a str>, @@ -3565,9 +2781,7 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmou } } -impl std::str::FromStr - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType::*; @@ -3578,24 +2792,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl std::fmt::Display for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType -{ +impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3685,7 +2893,6 @@ impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsC pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -3693,43 +2900,33 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecur match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } -impl std::str::FromStr - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure::*; match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } } -impl std::fmt::Display - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl std::fmt::Display for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure -{ +impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3742,14 +2939,10 @@ impl serde::Serialize pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: Option< - UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>, - >, + pub financial_connections: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: Option< - UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod, - >, + pub verification_method: Option<UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -3759,19 +2952,16 @@ impl<'a> UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> /// Additional fields for Financial Connections Session creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { - /// The list of permissions to request. + /// The list of permissions to request. /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. -#[serde(skip_serializing_if = "Option::is_none")] -pub permissions: Option<&'a [UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, + #[serde(skip_serializing_if = "Option::is_none")] + pub permissions: Option<&'a [UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. -#[serde(skip_serializing_if = "Option::is_none")] -pub prefetch: Option<&'a [UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, - + #[serde(skip_serializing_if = "Option::is_none")] + pub prefetch: Option<&'a [UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, } -impl<'a> - UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> -{ +impl<'a> UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { pub fn new() -> Self { Self::default() } @@ -3780,8 +2970,7 @@ impl<'a> /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { Balances, Ownership, PaymentMethod, @@ -3791,11 +2980,10 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancial pub fn as_str(self) -> &'static str { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; match self { -Balances => "balances", -Ownership => "ownership", -PaymentMethod => "payment_method", -Transactions => "transactions", - + Balances => "balances", + Ownership => "ownership", + PaymentMethod => "payment_method", + Transactions => "transactions", } } } @@ -3805,12 +2993,11 @@ impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptions fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; match s { - "balances" => Ok(Balances), -"ownership" => Ok(Ownership), -"payment_method" => Ok(PaymentMethod), -"transactions" => Ok(Transactions), -_ => Err(()) - + "balances" => Ok(Balances), + "ownership" => Ok(Ownership), + "payment_method" => Ok(PaymentMethod), + "transactions" => Ok(Transactions), + _ => Err(()), } } } @@ -3826,25 +3013,23 @@ impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUs } } impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } -impl - UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } @@ -3854,10 +3039,8 @@ impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptions fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { - "balances" => Ok(Balances), -"transactions" => Ok(Transactions), -_ => Err(()) - + "balances" => Ok(Balances), + _ => Err(()), } } } @@ -3873,7 +3056,10 @@ impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUs } } impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } @@ -3895,9 +3081,7 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificat } } -impl std::str::FromStr - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod::*; @@ -3909,24 +3093,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::fmt::Display for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::fmt::Debug for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3950,14 +3128,12 @@ pub enum UpdateSubscriptionPaymentSettingsPaymentMethodTypes { Card, Cashapp, CustomerBalance, - Eps, Fpx, Giropay, Grabpay, Ideal, Konbini, Link, - P24, Paynow, Paypal, Promptpay, @@ -3983,14 +3159,12 @@ impl UpdateSubscriptionPaymentSettingsPaymentMethodTypes { Card => "card", Cashapp => "cashapp", CustomerBalance => "customer_balance", - Eps => "eps", Fpx => "fpx", Giropay => "giropay", Grabpay => "grabpay", Ideal => "ideal", Konbini => "konbini", Link => "link", - P24 => "p24", Paynow => "paynow", Paypal => "paypal", Promptpay => "promptpay", @@ -4019,14 +3193,12 @@ impl std::str::FromStr for UpdateSubscriptionPaymentSettingsPaymentMethodTypes { "card" => Ok(Card), "cashapp" => Ok(Cashapp), "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), "fpx" => Ok(Fpx), "giropay" => Ok(Giropay), "grabpay" => Ok(Grabpay), "ideal" => Ok(Ideal), "konbini" => Ok(Konbini), "link" => Ok(Link), - "p24" => Ok(P24), "paynow" => Ok(Paynow), "paypal" => Ok(Paypal), "promptpay" => Ok(Promptpay), @@ -4253,9 +3425,7 @@ pub struct UpdateSubscriptionTrialSettingsEndBehavior { pub missing_payment_method: UpdateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod, } impl UpdateSubscriptionTrialSettingsEndBehavior { - pub fn new( - missing_payment_method: UpdateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod, - ) -> Self { + pub fn new(missing_payment_method: UpdateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod) -> Self { Self { missing_payment_method } } } @@ -4340,16 +3510,286 @@ impl<'a> UpdateSubscription<'a> { /// /// Updating the quantity on a subscription many times in an hour may result in [rate limiting](https://stripe.com/docs/rate-limits). /// If you need to bill for a frequently changing quantity, consider integrating [usage-based billing](https://stripe.com/docs/billing/subscriptions/usage-based) instead. - pub fn send( - &self, - client: &stripe::Client, - subscription_exposed_id: &stripe_shared::SubscriptionId, - ) -> stripe::Response<stripe_shared::Subscription> { - client.send_form( - &format!("/subscriptions/{subscription_exposed_id}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, subscription_exposed_id: &stripe_shared::SubscriptionId) -> stripe::Response<stripe_shared::Subscription> { + client.send_form(&format!("/subscriptions/{subscription_exposed_id}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveSubscription<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveSubscription<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveSubscription<'a> { + /// Retrieves the subscription with the given ID. + pub fn send(&self, client: &stripe::Client, subscription_exposed_id: &stripe_shared::SubscriptionId) -> stripe::Response<stripe_shared::Subscription> { + client.get_query(&format!("/subscriptions/{subscription_exposed_id}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CancelSubscription<'a> { + /// Details about why this subscription was cancelled + #[serde(skip_serializing_if = "Option::is_none")] + pub cancellation_details: Option<CancelSubscriptionCancellationDetails<'a>>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Will generate a final invoice that invoices for any un-invoiced metered usage and new/pending proration invoice items. + #[serde(skip_serializing_if = "Option::is_none")] + pub invoice_now: Option<bool>, + /// Will generate a proration invoice item that credits remaining unused time until the subscription period end. + #[serde(skip_serializing_if = "Option::is_none")] + pub prorate: Option<bool>, +} +impl<'a> CancelSubscription<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Details about why this subscription was cancelled +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CancelSubscriptionCancellationDetails<'a> { + /// Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user. + #[serde(skip_serializing_if = "Option::is_none")] + pub comment: Option<&'a str>, + /// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user. + #[serde(skip_serializing_if = "Option::is_none")] + pub feedback: Option<CancelSubscriptionCancellationDetailsFeedback>, +} +impl<'a> CancelSubscriptionCancellationDetails<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CancelSubscriptionCancellationDetailsFeedback { + CustomerService, + LowQuality, + MissingFeatures, + Other, + SwitchedService, + TooComplex, + TooExpensive, + Unused, +} +impl CancelSubscriptionCancellationDetailsFeedback { + pub fn as_str(self) -> &'static str { + use CancelSubscriptionCancellationDetailsFeedback::*; + match self { + CustomerService => "customer_service", + LowQuality => "low_quality", + MissingFeatures => "missing_features", + Other => "other", + SwitchedService => "switched_service", + TooComplex => "too_complex", + TooExpensive => "too_expensive", + Unused => "unused", + } + } +} + +impl std::str::FromStr for CancelSubscriptionCancellationDetailsFeedback { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use CancelSubscriptionCancellationDetailsFeedback::*; + match s { + "customer_service" => Ok(CustomerService), + "low_quality" => Ok(LowQuality), + "missing_features" => Ok(MissingFeatures), + "other" => Ok(Other), + "switched_service" => Ok(SwitchedService), + "too_complex" => Ok(TooComplex), + "too_expensive" => Ok(TooExpensive), + "unused" => Ok(Unused), + _ => Err(()), + } + } +} +impl std::fmt::Display for CancelSubscriptionCancellationDetailsFeedback { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CancelSubscriptionCancellationDetailsFeedback { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for CancelSubscriptionCancellationDetailsFeedback { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> CancelSubscription<'a> { + /// Cancels a customer’s subscription immediately. + /// The customer will not be charged again for the subscription. + /// + /// Note, however, that any pending invoice items that you’ve created will still be charged for at the end of the period, unless manually [deleted](https://stripe.com/docs/api#delete_invoiceitem). + /// If you’ve set the subscription to cancel at the end of the period, any pending prorations will also be left in place and collected at the end of the period. + /// But if the subscription is set to cancel immediately, pending prorations will be removed. + /// + /// By default, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. + /// This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. + /// However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. + /// Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all. + pub fn send(&self, client: &stripe::Client, subscription_exposed_id: &stripe_shared::SubscriptionId) -> stripe::Response<stripe_shared::Subscription> { + client.send_form(&format!("/subscriptions/{subscription_exposed_id}"), self, http_types::Method::Delete) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ResumeSubscription<'a> { + /// Either `now` or `unchanged`. + /// Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). + /// Setting the value to `unchanged` advances the subscription's billing cycle anchor to the period that surrounds the current time. + /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). + #[serde(skip_serializing_if = "Option::is_none")] + pub billing_cycle_anchor: Option<ResumeSubscriptionBillingCycleAnchor>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. + /// The default value is `create_prorations`. + #[serde(skip_serializing_if = "Option::is_none")] + pub proration_behavior: Option<ResumeSubscriptionProrationBehavior>, + /// If set, the proration will be calculated as though the subscription was resumed at the given time. + /// This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + pub proration_date: Option<stripe_types::Timestamp>, +} +impl<'a> ResumeSubscription<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Either `now` or `unchanged`. +/// Setting the value to `now` resets the subscription's billing cycle anchor to the current time (in UTC). +/// Setting the value to `unchanged` advances the subscription's billing cycle anchor to the period that surrounds the current time. +/// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ResumeSubscriptionBillingCycleAnchor { + Now, + Unchanged, +} +impl ResumeSubscriptionBillingCycleAnchor { + pub fn as_str(self) -> &'static str { + use ResumeSubscriptionBillingCycleAnchor::*; + match self { + Now => "now", + Unchanged => "unchanged", + } + } +} + +impl std::str::FromStr for ResumeSubscriptionBillingCycleAnchor { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use ResumeSubscriptionBillingCycleAnchor::*; + match s { + "now" => Ok(Now), + "unchanged" => Ok(Unchanged), + _ => Err(()), + } + } +} +impl std::fmt::Display for ResumeSubscriptionBillingCycleAnchor { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ResumeSubscriptionBillingCycleAnchor { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for ResumeSubscriptionBillingCycleAnchor { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +/// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. +/// The default value is `create_prorations`. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ResumeSubscriptionProrationBehavior { + AlwaysInvoice, + CreateProrations, + None, +} +impl ResumeSubscriptionProrationBehavior { + pub fn as_str(self) -> &'static str { + use ResumeSubscriptionProrationBehavior::*; + match self { + AlwaysInvoice => "always_invoice", + CreateProrations => "create_prorations", + None => "none", + } + } +} + +impl std::str::FromStr for ResumeSubscriptionProrationBehavior { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use ResumeSubscriptionProrationBehavior::*; + match s { + "always_invoice" => Ok(AlwaysInvoice), + "create_prorations" => Ok(CreateProrations), + "none" => Ok(None), + _ => Err(()), + } + } +} +impl std::fmt::Display for ResumeSubscriptionProrationBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ResumeSubscriptionProrationBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for ResumeSubscriptionProrationBehavior { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> ResumeSubscription<'a> { + /// Initiates resumption of a paused subscription, optionally resetting the billing cycle anchor and creating prorations. + /// If a resumption invoice is generated, it must be paid or marked uncollectible before the subscription will be unpaused. + /// If payment succeeds the subscription will become `active`, and if payment fails the subscription will be `past_due`. + /// The resumption invoice will void automatically if not paid by the expiration date. + pub fn send(&self, client: &stripe::Client, subscription: &stripe_shared::SubscriptionId) -> stripe::Response<stripe_shared::Subscription> { + client.send_form(&format!("/subscriptions/{subscription}/resume"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteDiscountSubscription {} +impl DeleteDiscountSubscription { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteDiscountSubscription { + /// Removes the currently applied discount on a subscription. + pub fn send(&self, client: &stripe::Client, subscription_exposed_id: &stripe_shared::SubscriptionId) -> stripe::Response<stripe_shared::DeletedDiscount> { + client.send_form(&format!("/subscriptions/{subscription_exposed_id}/discount"), self, http_types::Method::Delete) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -4410,7 +3850,7 @@ pub struct BankTransferParam<'a> { pub eu_bank_transfer: Option<EuBankTransferParam<'a>>, /// The bank transfer type that can be used for funding. /// Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<&'a str>, } diff --git a/generated/stripe_billing/src/subscription_item/requests.rs b/generated/stripe_billing/src/subscription_item/requests.rs index e56045b5e..f7d87a178 100644 --- a/generated/stripe_billing/src/subscription_item/requests.rs +++ b/generated/stripe_billing/src/subscription_item/requests.rs @@ -1,84 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteSubscriptionItem { - /// Delete all usage for the given subscription item. - /// Allowed only when the current plan's `usage_type` is `metered`. - #[serde(skip_serializing_if = "Option::is_none")] - pub clear_usage: Option<bool>, - /// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. - /// The default value is `create_prorations`. - #[serde(skip_serializing_if = "Option::is_none")] - pub proration_behavior: Option<DeleteSubscriptionItemProrationBehavior>, - /// If set, the proration will be calculated as though the subscription was updated at the given time. - /// This can be used to apply the same proration that was previewed with the [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint. - #[serde(skip_serializing_if = "Option::is_none")] - pub proration_date: Option<stripe_types::Timestamp>, -} -impl DeleteSubscriptionItem { - pub fn new() -> Self { - Self::default() - } -} -/// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. -/// The default value is `create_prorations`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum DeleteSubscriptionItemProrationBehavior { - AlwaysInvoice, - CreateProrations, - None, -} -impl DeleteSubscriptionItemProrationBehavior { - pub fn as_str(self) -> &'static str { - use DeleteSubscriptionItemProrationBehavior::*; - match self { - AlwaysInvoice => "always_invoice", - CreateProrations => "create_prorations", - None => "none", - } - } -} - -impl std::str::FromStr for DeleteSubscriptionItemProrationBehavior { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use DeleteSubscriptionItemProrationBehavior::*; - match s { - "always_invoice" => Ok(AlwaysInvoice), - "create_prorations" => Ok(CreateProrations), - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for DeleteSubscriptionItemProrationBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for DeleteSubscriptionItemProrationBehavior { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for DeleteSubscriptionItemProrationBehavior { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl DeleteSubscriptionItem { - /// Deletes an item from the subscription. - /// Removing a subscription item from a subscription will not cancel the subscription. - pub fn send( - &self, - client: &stripe::Client, - item: &stripe_shared::SubscriptionItemId, - ) -> stripe::Response<stripe_shared::DeletedSubscriptionItem> { - client.send_form(&format!("/subscription_items/{item}"), self, http_types::Method::Delete) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ListSubscriptionItem<'a> { /// A cursor for use in pagination. @@ -108,15 +27,10 @@ impl<'a> ListSubscriptionItem<'a> { } impl<'a> ListSubscriptionItem<'a> { /// Returns a list of your subscription items for a given subscription. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::SubscriptionItem>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::SubscriptionItem>> { client.get_query("/subscription_items", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SubscriptionItem>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SubscriptionItem>> { stripe::ListPaginator::from_list_params("/subscription_items", self) } } @@ -133,66 +47,10 @@ impl<'a> RetrieveSubscriptionItem<'a> { } impl<'a> RetrieveSubscriptionItem<'a> { /// Retrieves the subscription item with the given ID. - pub fn send( - &self, - client: &stripe::Client, - item: &stripe_shared::SubscriptionItemId, - ) -> stripe::Response<stripe_shared::SubscriptionItem> { + pub fn send(&self, client: &stripe::Client, item: &stripe_shared::SubscriptionItemId) -> stripe::Response<stripe_shared::SubscriptionItem> { client.get_query(&format!("/subscription_items/{item}"), self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UsageRecordSummariesSubscriptionItem<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> UsageRecordSummariesSubscriptionItem<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> UsageRecordSummariesSubscriptionItem<'a> { - /// For the specified subscription item, returns a list of summary objects. - /// Each object in the list provides usage information that’s been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September). - /// - /// The list is sorted in reverse-chronological order (newest first). - /// The first list item represents the most current usage period that hasn’t ended yet. - /// Since new usage records can still be added, the returned summary information for the subscription item’s ID should be seen as unstable until the subscription billing period ends. - pub fn send( - &self, - client: &stripe::Client, - subscription_item: &stripe_shared::SubscriptionItemId, - ) -> stripe::Response<stripe_types::List<stripe_shared::UsageRecordSummary>> { - client.get_query( - &format!("/subscription_items/{subscription_item}/usage_record_summaries"), - self, - ) - } - pub fn paginate( - self, - subscription_item: &stripe_shared::SubscriptionItemId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::UsageRecordSummary>> { - stripe::ListPaginator::from_list_params( - &format!("/subscription_items/{subscription_item}/usage_record_summaries"), - self, - ) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateSubscriptionItem<'a> { /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. @@ -366,19 +224,8 @@ pub struct CreateSubscriptionItemPriceData<'a> { pub unit_amount_decimal: Option<&'a str>, } impl<'a> CreateSubscriptionItemPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: CreateSubscriptionItemPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: CreateSubscriptionItemPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -388,7 +235,7 @@ pub struct CreateSubscriptionItemPriceDataRecurring { pub interval: CreateSubscriptionItemPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -553,10 +400,7 @@ impl serde::Serialize for CreateSubscriptionItemProrationBehavior { } impl<'a> CreateSubscriptionItem<'a> { /// Adds a new item to an existing subscription. No existing items will be changed or replaced. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_shared::SubscriptionItem> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::SubscriptionItem> { client.send_form("/subscription_items", self, http_types::Method::Post) } } @@ -722,19 +566,8 @@ pub struct UpdateSubscriptionItemPriceData<'a> { pub unit_amount_decimal: Option<&'a str>, } impl<'a> UpdateSubscriptionItemPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: UpdateSubscriptionItemPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: UpdateSubscriptionItemPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -744,7 +577,7 @@ pub struct UpdateSubscriptionItemPriceDataRecurring { pub interval: UpdateSubscriptionItemPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -909,14 +742,126 @@ impl serde::Serialize for UpdateSubscriptionItemProrationBehavior { } impl<'a> UpdateSubscriptionItem<'a> { /// Updates the plan or quantity of an item on a current subscription. - pub fn send( - &self, - client: &stripe::Client, - item: &stripe_shared::SubscriptionItemId, - ) -> stripe::Response<stripe_shared::SubscriptionItem> { + pub fn send(&self, client: &stripe::Client, item: &stripe_shared::SubscriptionItemId) -> stripe::Response<stripe_shared::SubscriptionItem> { client.send_form(&format!("/subscription_items/{item}"), self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteSubscriptionItem { + /// Delete all usage for the given subscription item. + /// Allowed only when the current plan's `usage_type` is `metered`. + #[serde(skip_serializing_if = "Option::is_none")] + pub clear_usage: Option<bool>, + /// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. + /// The default value is `create_prorations`. + #[serde(skip_serializing_if = "Option::is_none")] + pub proration_behavior: Option<DeleteSubscriptionItemProrationBehavior>, + /// If set, the proration will be calculated as though the subscription was updated at the given time. + /// This can be used to apply the same proration that was previewed with the [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint. + #[serde(skip_serializing_if = "Option::is_none")] + pub proration_date: Option<stripe_types::Timestamp>, +} +impl DeleteSubscriptionItem { + pub fn new() -> Self { + Self::default() + } +} +/// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. +/// The default value is `create_prorations`. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeleteSubscriptionItemProrationBehavior { + AlwaysInvoice, + CreateProrations, + None, +} +impl DeleteSubscriptionItemProrationBehavior { + pub fn as_str(self) -> &'static str { + use DeleteSubscriptionItemProrationBehavior::*; + match self { + AlwaysInvoice => "always_invoice", + CreateProrations => "create_prorations", + None => "none", + } + } +} + +impl std::str::FromStr for DeleteSubscriptionItemProrationBehavior { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use DeleteSubscriptionItemProrationBehavior::*; + match s { + "always_invoice" => Ok(AlwaysInvoice), + "create_prorations" => Ok(CreateProrations), + "none" => Ok(None), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeleteSubscriptionItemProrationBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeleteSubscriptionItemProrationBehavior { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for DeleteSubscriptionItemProrationBehavior { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl DeleteSubscriptionItem { + /// Deletes an item from the subscription. + /// Removing a subscription item from a subscription will not cancel the subscription. + pub fn send(&self, client: &stripe::Client, item: &stripe_shared::SubscriptionItemId) -> stripe::Response<stripe_shared::DeletedSubscriptionItem> { + client.send_form(&format!("/subscription_items/{item}"), self, http_types::Method::Delete) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UsageRecordSummariesSubscriptionItem<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> UsageRecordSummariesSubscriptionItem<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> UsageRecordSummariesSubscriptionItem<'a> { + /// For the specified subscription item, returns a list of summary objects. + /// Each object in the list provides usage information that’s been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September). + /// + /// The list is sorted in reverse-chronological order (newest first). + /// The first list item represents the most current usage period that hasn’t ended yet. + /// Since new usage records can still be added, the returned summary information for the subscription item’s ID should be seen as unstable until the subscription billing period ends. + pub fn send(&self, client: &stripe::Client, subscription_item: &stripe_shared::SubscriptionItemId) -> stripe::Response<stripe_types::List<stripe_shared::UsageRecordSummary>> { + client.get_query(&format!("/subscription_items/{subscription_item}/usage_record_summaries"), self) + } + pub fn paginate(self, subscription_item: &stripe_shared::SubscriptionItemId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::UsageRecordSummary>> { + stripe::ListPaginator::from_list_params(&format!("/subscription_items/{subscription_item}/usage_record_summaries"), self) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ItemBillingThresholdsParam { /// Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte)). diff --git a/generated/stripe_billing/src/subscription_schedule/requests.rs b/generated/stripe_billing/src/subscription_schedule/requests.rs index a3e60f65e..97b93cb4e 100644 --- a/generated/stripe_billing/src/subscription_schedule/requests.rs +++ b/generated/stripe_billing/src/subscription_schedule/requests.rs @@ -43,41 +43,14 @@ impl<'a> ListSubscriptionSchedule<'a> { } impl<'a> ListSubscriptionSchedule<'a> { /// Retrieves the list of your subscription schedules. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::SubscriptionSchedule>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::SubscriptionSchedule>> { client.get_query("/subscription_schedules", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SubscriptionSchedule>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SubscriptionSchedule>> { stripe::ListPaginator::from_list_params("/subscription_schedules", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveSubscriptionSchedule<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveSubscriptionSchedule<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveSubscriptionSchedule<'a> { - /// Retrieves the details of an existing subscription schedule. - /// You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation. - pub fn send( - &self, - client: &stripe::Client, - schedule: &stripe_shared::SubscriptionScheduleId, - ) -> stripe::Response<stripe_shared::SubscriptionSchedule> { - client.get_query(&format!("/subscription_schedules/{schedule}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionSchedule<'a> { /// The identifier of the customer to create the subscription schedule for. #[serde(skip_serializing_if = "Option::is_none")] @@ -87,8 +60,7 @@ pub struct CreateSubscriptionSchedule<'a> { pub default_settings: Option<CreateSubscriptionScheduleDefaultSettings<'a>>, /// Behavior of the subscription schedule and underlying subscription when it ends. /// Possible values are `release` or `cancel` with the default being `release`. - /// `release` will end the subscription schedule and keep the underlying subscription running. - /// `cancel` will end the subscription schedule and cancel the underlying subscription. + /// `release` will end the subscription schedule and keep the underlying subscription running.`cancel` will end the subscription schedule and cancel the underlying subscription. #[serde(skip_serializing_if = "Option::is_none")] pub end_behavior: Option<stripe_shared::SubscriptionScheduleEndBehavior>, /// Specifies which fields in the response should be expanded. @@ -133,7 +105,7 @@ pub struct CreateSubscriptionScheduleDefaultSettings<'a> { pub application_fee_percent: Option<f64>, /// Default settings for automatic tax computation. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<CreateSubscriptionScheduleDefaultSettingsAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxConfig>, /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -160,7 +132,7 @@ pub struct CreateSubscriptionScheduleDefaultSettings<'a> { pub description: Option<&'a str>, /// All invoices will be billed using the specified settings. #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<CreateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a>>, + pub invoice_settings: Option<SubscriptionScheduleDefaultSettingsParam>, /// The account on behalf of which to charge, for each of the associated subscription's invoices. #[serde(skip_serializing_if = "Option::is_none")] pub on_behalf_of: Option<&'a str>, @@ -173,85 +145,6 @@ impl<'a> CreateSubscriptionScheduleDefaultSettings<'a> { Self::default() } } -/// Default settings for automatic tax computation. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionScheduleDefaultSettingsAutomaticTax<'a> { - /// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiability<'a>>, -} -impl<'a> CreateSubscriptionScheduleDefaultSettingsAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType, -} -impl<'a> CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiability<'a> { - pub fn new(type_: CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - Account, - Self_, -} -impl CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -349,89 +242,6 @@ impl serde::Serialize for CreateSubscriptionScheduleDefaultSettingsCollectionMet serializer.serialize_str(self.as_str()) } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a> { - /// The account tax IDs associated with the subscription schedule. - /// Will be set on invoices generated by the subscription schedule. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<&'a [&'a str]>, - /// Number of days within which a customer must pay invoices generated by this subscription schedule. - /// This value will be `null` for subscription schedules where `collection_method=charge_automatically`. - #[serde(skip_serializing_if = "Option::is_none")] - pub days_until_due: Option<u32>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuer<'a>>, -} -impl<'a> CreateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType, -} -impl<'a> CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuer<'a> { - pub fn new(type_: CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - Account, - Self_, -} -impl CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// List representing phases of the subscription schedule. /// Each phase can be customized to have different durations, plans, and coupons. /// If there are multiple phases, the `end_date` of one phase will always equal the `start_date` of the next phase. @@ -449,7 +259,7 @@ pub struct CreateSubscriptionSchedulePhases<'a> { pub application_fee_percent: Option<f64>, /// Automatic tax settings for this phase. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<CreateSubscriptionSchedulePhasesAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxConfig>, /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -491,7 +301,7 @@ pub struct CreateSubscriptionSchedulePhases<'a> { pub end_date: Option<stripe_types::Timestamp>, /// All invoices will be billed using the specified settings. #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<CreateSubscriptionSchedulePhasesInvoiceSettings<'a>>, + pub invoice_settings: Option<InvoiceSettings>, /// List of configuration items, each with an attached price, to apply during this phase of the subscription schedule. pub items: &'a [CreateSubscriptionSchedulePhasesItems<'a>], /// Integer representing the multiplier applied to the price interval. @@ -653,85 +463,6 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesAddInvoiceItemsPriceDa serializer.serialize_str(self.as_str()) } } -/// Automatic tax settings for this phase. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionSchedulePhasesAutomaticTax<'a> { - /// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<CreateSubscriptionSchedulePhasesAutomaticTaxLiability<'a>>, -} -impl<'a> CreateSubscriptionSchedulePhasesAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionSchedulePhasesAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType, -} -impl<'a> CreateSubscriptionSchedulePhasesAutomaticTaxLiability<'a> { - pub fn new(type_: CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - Account, - Self_, -} -impl CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -829,89 +560,6 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesCollectionMethod { serializer.serialize_str(self.as_str()) } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSubscriptionSchedulePhasesInvoiceSettings<'a> { - /// The account tax IDs associated with this phase of the subscription schedule. - /// Will be set on invoices generated by this phase of the subscription schedule. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<&'a [&'a str]>, - /// Number of days within which a customer must pay invoices generated by this subscription schedule. - /// This value will be `null` for subscription schedules where `billing=charge_automatically`. - #[serde(skip_serializing_if = "Option::is_none")] - pub days_until_due: Option<u32>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreateSubscriptionSchedulePhasesInvoiceSettingsIssuer<'a>>, -} -impl<'a> CreateSubscriptionSchedulePhasesInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSubscriptionSchedulePhasesInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType, -} -impl<'a> CreateSubscriptionSchedulePhasesInvoiceSettingsIssuer<'a> { - pub fn new(type_: CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - Account, - Self_, -} -impl CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// List of configuration items, each with an attached price, to apply during this phase of the subscription schedule. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionSchedulePhasesItems<'a> { @@ -974,19 +622,8 @@ pub struct CreateSubscriptionSchedulePhasesItemsPriceData<'a> { pub unit_amount_decimal: Option<&'a str>, } impl<'a> CreateSubscriptionSchedulePhasesItemsPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: CreateSubscriptionSchedulePhasesItemsPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: CreateSubscriptionSchedulePhasesItemsPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -996,7 +633,7 @@ pub struct CreateSubscriptionSchedulePhasesItemsPriceDataRecurring { pub interval: CreateSubscriptionSchedulePhasesItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -1173,22 +810,36 @@ pub enum CreateSubscriptionScheduleStartDate { impl<'a> CreateSubscriptionSchedule<'a> { /// Creates a new subscription schedule object. /// Each customer can have up to 500 active or scheduled subscriptions. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_shared::SubscriptionSchedule> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::SubscriptionSchedule> { client.send_form("/subscription_schedules", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveSubscriptionSchedule<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveSubscriptionSchedule<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveSubscriptionSchedule<'a> { + /// Retrieves the details of an existing subscription schedule. + /// You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation. + pub fn send(&self, client: &stripe::Client, schedule: &stripe_shared::SubscriptionScheduleId) -> stripe::Response<stripe_shared::SubscriptionSchedule> { + client.get_query(&format!("/subscription_schedules/{schedule}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionSchedule<'a> { /// Object representing the subscription schedule's default settings. #[serde(skip_serializing_if = "Option::is_none")] pub default_settings: Option<UpdateSubscriptionScheduleDefaultSettings<'a>>, /// Behavior of the subscription schedule and underlying subscription when it ends. /// Possible values are `release` or `cancel` with the default being `release`. - /// `release` will end the subscription schedule and keep the underlying subscription running. - /// `cancel` will end the subscription schedule and cancel the underlying subscription. + /// `release` will end the subscription schedule and keep the underlying subscription running.`cancel` will end the subscription schedule and cancel the underlying subscription. #[serde(skip_serializing_if = "Option::is_none")] pub end_behavior: Option<stripe_shared::SubscriptionScheduleEndBehavior>, /// Specifies which fields in the response should be expanded. @@ -1227,7 +878,7 @@ pub struct UpdateSubscriptionScheduleDefaultSettings<'a> { pub application_fee_percent: Option<f64>, /// Default settings for automatic tax computation. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpdateSubscriptionScheduleDefaultSettingsAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxConfig>, /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -1254,7 +905,7 @@ pub struct UpdateSubscriptionScheduleDefaultSettings<'a> { pub description: Option<&'a str>, /// All invoices will be billed using the specified settings. #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<UpdateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a>>, + pub invoice_settings: Option<SubscriptionScheduleDefaultSettingsParam>, /// The account on behalf of which to charge, for each of the associated subscription's invoices. #[serde(skip_serializing_if = "Option::is_none")] pub on_behalf_of: Option<&'a str>, @@ -1267,85 +918,6 @@ impl<'a> UpdateSubscriptionScheduleDefaultSettings<'a> { Self::default() } } -/// Default settings for automatic tax computation. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionScheduleDefaultSettingsAutomaticTax<'a> { - /// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiability<'a>>, -} -impl<'a> UpdateSubscriptionScheduleDefaultSettingsAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType, -} -impl<'a> UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiability<'a> { - pub fn new(type_: UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - Account, - Self_, -} -impl UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -1443,89 +1015,6 @@ impl serde::Serialize for UpdateSubscriptionScheduleDefaultSettingsCollectionMet serializer.serialize_str(self.as_str()) } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a> { - /// The account tax IDs associated with the subscription schedule. - /// Will be set on invoices generated by the subscription schedule. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<&'a [&'a str]>, - /// Number of days within which a customer must pay invoices generated by this subscription schedule. - /// This value will be `null` for subscription schedules where `collection_method=charge_automatically`. - #[serde(skip_serializing_if = "Option::is_none")] - pub days_until_due: Option<u32>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuer<'a>>, -} -impl<'a> UpdateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType, -} -impl<'a> UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuer<'a> { - pub fn new(type_: UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - Account, - Self_, -} -impl UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// List representing phases of the subscription schedule. /// Each phase can be customized to have different durations, plans, and coupons. /// If there are multiple phases, the `end_date` of one phase will always equal the `start_date` of the next phase. @@ -1544,7 +1033,7 @@ pub struct UpdateSubscriptionSchedulePhases<'a> { pub application_fee_percent: Option<f64>, /// Automatic tax settings for this phase. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpdateSubscriptionSchedulePhasesAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxConfig>, /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -1586,7 +1075,7 @@ pub struct UpdateSubscriptionSchedulePhases<'a> { pub end_date: Option<UpdateSubscriptionSchedulePhasesEndDate>, /// All invoices will be billed using the specified settings. #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<UpdateSubscriptionSchedulePhasesInvoiceSettings<'a>>, + pub invoice_settings: Option<InvoiceSettings>, /// List of configuration items, each with an attached price, to apply during this phase of the subscription schedule. pub items: &'a [UpdateSubscriptionSchedulePhasesItems<'a>], /// Integer representing the multiplier applied to the price interval. @@ -1753,85 +1242,6 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesAddInvoiceItemsPriceDa serializer.serialize_str(self.as_str()) } } -/// Automatic tax settings for this phase. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionSchedulePhasesAutomaticTax<'a> { - /// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpdateSubscriptionSchedulePhasesAutomaticTaxLiability<'a>>, -} -impl<'a> UpdateSubscriptionSchedulePhasesAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionSchedulePhasesAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType, -} -impl<'a> UpdateSubscriptionSchedulePhasesAutomaticTaxLiability<'a> { - pub fn new(type_: UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - Account, - Self_, -} -impl UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Can be set to `phase_start` to set the anchor to the start of the phase or `automatic` to automatically change it if needed. /// Cannot be set to `phase_start` if this phase specifies a trial. /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle). @@ -1937,89 +1347,6 @@ pub enum UpdateSubscriptionSchedulePhasesEndDate { Timestamp(stripe_types::Timestamp), Now, } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateSubscriptionSchedulePhasesInvoiceSettings<'a> { - /// The account tax IDs associated with this phase of the subscription schedule. - /// Will be set on invoices generated by this phase of the subscription schedule. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<&'a [&'a str]>, - /// Number of days within which a customer must pay invoices generated by this subscription schedule. - /// This value will be `null` for subscription schedules where `billing=charge_automatically`. - #[serde(skip_serializing_if = "Option::is_none")] - pub days_until_due: Option<u32>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuer<'a>>, -} -impl<'a> UpdateSubscriptionSchedulePhasesInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType, -} -impl<'a> UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuer<'a> { - pub fn new(type_: UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - Account, - Self_, -} -impl UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// List of configuration items, each with an attached price, to apply during this phase of the subscription schedule. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionSchedulePhasesItems<'a> { @@ -2082,19 +1409,8 @@ pub struct UpdateSubscriptionSchedulePhasesItemsPriceData<'a> { pub unit_amount_decimal: Option<&'a str>, } impl<'a> UpdateSubscriptionSchedulePhasesItemsPriceData<'a> { - pub fn new( - currency: stripe_types::Currency, - product: &'a str, - recurring: UpdateSubscriptionSchedulePhasesItemsPriceDataRecurring, - ) -> Self { - Self { - currency, - product, - recurring, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + pub fn new(currency: stripe_types::Currency, product: &'a str, recurring: UpdateSubscriptionSchedulePhasesItemsPriceDataRecurring) -> Self { + Self { currency, product, recurring, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// The recurring components of a price such as `interval` and `interval_count`. @@ -2104,7 +1420,7 @@ pub struct UpdateSubscriptionSchedulePhasesItemsPriceDataRecurring { pub interval: UpdateSubscriptionSchedulePhasesItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -2337,16 +1653,8 @@ impl serde::Serialize for UpdateSubscriptionScheduleProrationBehavior { } impl<'a> UpdateSubscriptionSchedule<'a> { /// Updates an existing subscription schedule. - pub fn send( - &self, - client: &stripe::Client, - schedule: &stripe_shared::SubscriptionScheduleId, - ) -> stripe::Response<stripe_shared::SubscriptionSchedule> { - client.send_form( - &format!("/subscription_schedules/{schedule}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, schedule: &stripe_shared::SubscriptionScheduleId) -> stripe::Response<stripe_shared::SubscriptionSchedule> { + client.send_form(&format!("/subscription_schedules/{schedule}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -2371,16 +1679,8 @@ impl<'a> CancelSubscriptionSchedule<'a> { impl<'a> CancelSubscriptionSchedule<'a> { /// Cancels a subscription schedule and its associated subscription immediately (if the subscription schedule has an active subscription). /// A subscription schedule can only be canceled if its status is `not_started` or `active`. - pub fn send( - &self, - client: &stripe::Client, - schedule: &stripe_shared::SubscriptionScheduleId, - ) -> stripe::Response<stripe_shared::SubscriptionSchedule> { - client.send_form( - &format!("/subscription_schedules/{schedule}/cancel"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, schedule: &stripe_shared::SubscriptionScheduleId) -> stripe::Response<stripe_shared::SubscriptionSchedule> { + client.send_form(&format!("/subscription_schedules/{schedule}/cancel"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -2401,16 +1701,18 @@ impl<'a> ReleaseSubscriptionSchedule<'a> { /// Releases the subscription schedule immediately, which will stop scheduling of its phases, but leave any existing subscription in place. /// A schedule can only be released if its status is `not_started` or `active`. /// If the subscription schedule is currently associated with a subscription, releasing it will remove its `subscription` property and set the subscription’s ID to the `released_subscription` property. - pub fn send( - &self, - client: &stripe::Client, - schedule: &stripe_shared::SubscriptionScheduleId, - ) -> stripe::Response<stripe_shared::SubscriptionSchedule> { - client.send_form( - &format!("/subscription_schedules/{schedule}/release"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, schedule: &stripe_shared::SubscriptionScheduleId) -> stripe::Response<stripe_shared::SubscriptionSchedule> { + client.send_form(&format!("/subscription_schedules/{schedule}/release"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct AutomaticTaxConfig { + /// Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription. + pub enabled: bool, +} +impl AutomaticTaxConfig { + pub fn new(enabled: bool) -> Self { + Self { enabled } } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -2428,6 +1730,18 @@ impl BillingThresholdsParam { Self::default() } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct SubscriptionScheduleDefaultSettingsParam { + /// Number of days within which a customer must pay invoices generated by this subscription schedule. + /// This value will be `null` for subscription schedules where `collection_method=charge_automatically`. + #[serde(skip_serializing_if = "Option::is_none")] + pub days_until_due: Option<u32>, +} +impl SubscriptionScheduleDefaultSettingsParam { + pub fn new() -> Self { + Self::default() + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct TransferDataSpecs<'a> { /// A non-negative decimal between 0 and 100, with at most two decimal places. @@ -2443,6 +1757,18 @@ impl<'a> TransferDataSpecs<'a> { Self { amount_percent: None, destination } } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct InvoiceSettings { + /// Number of days within which a customer must pay invoices generated by this subscription schedule. + /// This value will be `null` for subscription schedules where `billing=charge_automatically`. + #[serde(skip_serializing_if = "Option::is_none")] + pub days_until_due: Option<u32>, +} +impl InvoiceSettings { + pub fn new() -> Self { + Self::default() + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ItemBillingThresholdsParam { /// Number of units that meets the billing threshold to advance the subscription to a new billing period (e.g., it takes 10 $5 units to meet a $50 [monetary threshold](https://stripe.com/docs/api/subscriptions/update#update_subscription-billing_thresholds-amount_gte)). diff --git a/generated/stripe_billing/src/tax_id/requests.rs b/generated/stripe_billing/src/tax_id/requests.rs index 89de3b060..c204b8af1 100644 --- a/generated/stripe_billing/src/tax_id/requests.rs +++ b/generated/stripe_billing/src/tax_id/requests.rs @@ -1,243 +1,10 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteCustomerTaxId {} -impl DeleteCustomerTaxId { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteCustomerTaxId { - /// Deletes an existing `tax_id` object. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<stripe_shared::DeletedTaxId> { - client.send_form( - &format!("/customers/{customer}/tax_ids/{id}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteIdTaxId {} -impl DeleteIdTaxId { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteIdTaxId { - /// Deletes an existing account or customer `tax_id` object. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::TaxIdId, - ) -> stripe::Response<stripe_shared::DeletedTaxId> { - client.send_form(&format!("/tax_ids/{id}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListCustomerTaxId<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListCustomerTaxId<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListCustomerTaxId<'a> { - /// Returns a list of tax IDs for a customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_types::List<stripe_shared::TaxId>> { - client.get_query(&format!("/customers/{customer}/tax_ids"), self) - } - pub fn paginate( - self, - customer: &stripe_shared::CustomerId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TaxId>> { - stripe::ListPaginator::from_list_params(&format!("/customers/{customer}/tax_ids"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveCustomerTaxId<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveCustomerTaxId<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveCustomerTaxId<'a> { - /// Retrieves the `tax_id` object with the given identifier. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<stripe_shared::TaxId> { - client.get_query(&format!("/customers/{customer}/tax_ids/{id}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListTaxId<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// The account or customer the tax ID belongs to. Defaults to `owner[type]=self`. - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<ListTaxIdOwner<'a>>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListTaxId<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The account or customer the tax ID belongs to. Defaults to `owner[type]=self`. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ListTaxIdOwner<'a> { - /// Account the tax ID belongs to. Required when `type=account` - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Customer the tax ID belongs to. Required when `type=customer` - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// Type of owner referenced. - #[serde(rename = "type")] - pub type_: ListTaxIdOwnerType, -} -impl<'a> ListTaxIdOwner<'a> { - pub fn new(type_: ListTaxIdOwnerType) -> Self { - Self { account: None, customer: None, type_ } - } -} -/// Type of owner referenced. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ListTaxIdOwnerType { - Account, - Application, - Customer, - Self_, -} -impl ListTaxIdOwnerType { - pub fn as_str(self) -> &'static str { - use ListTaxIdOwnerType::*; - match self { - Account => "account", - Application => "application", - Customer => "customer", - Self_ => "self", - } - } -} - -impl std::str::FromStr for ListTaxIdOwnerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ListTaxIdOwnerType::*; - match s { - "account" => Ok(Account), - "application" => Ok(Application), - "customer" => Ok(Customer), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for ListTaxIdOwnerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ListTaxIdOwnerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ListTaxIdOwnerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> ListTaxId<'a> { - /// Returns a list of tax IDs. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::TaxId>> { - client.get_query("/tax_ids", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TaxId>> { - stripe::ListPaginator::from_list_params("/tax_ids", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveIdTaxId<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveIdTaxId<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveIdTaxId<'a> { - /// Retrieves an account or customer `tax_id` object. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::TaxIdId, - ) -> stripe::Response<stripe_shared::TaxId> { - client.get_query(&format!("/tax_ids/{id}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCustomerTaxId<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateCustomerTaxIdType, /// Value of the tax ID. pub value: &'a str, @@ -491,348 +258,71 @@ impl serde::Serialize for CreateCustomerTaxIdType { } impl<'a> CreateCustomerTaxId<'a> { /// Creates a new `tax_id` object for a customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::TaxId> { + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::TaxId> { client.send_form(&format!("/customers/{customer}/tax_ids"), self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateTaxId<'a> { +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTaxId<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// The account or customer the tax ID belongs to. Defaults to `owner[type]=self`. - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<CreateTaxIdOwner<'a>>, - /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. - #[serde(rename = "type")] - pub type_: CreateTaxIdType, - /// Value of the tax ID. - pub value: &'a str, -} -impl<'a> CreateTaxId<'a> { - pub fn new(type_: CreateTaxIdType, value: &'a str) -> Self { - Self { expand: None, owner: None, type_, value } - } -} -/// The account or customer the tax ID belongs to. Defaults to `owner[type]=self`. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateTaxIdOwner<'a> { - /// Account the tax ID belongs to. Required when `type=account` - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Customer the tax ID belongs to. Required when `type=customer` - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// Type of owner referenced. - #[serde(rename = "type")] - pub type_: CreateTaxIdOwnerType, -} -impl<'a> CreateTaxIdOwner<'a> { - pub fn new(type_: CreateTaxIdOwnerType) -> Self { - Self { account: None, customer: None, type_ } - } -} -/// Type of owner referenced. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateTaxIdOwnerType { - Account, - Application, - Customer, - Self_, -} -impl CreateTaxIdOwnerType { - pub fn as_str(self) -> &'static str { - use CreateTaxIdOwnerType::*; - match self { - Account => "account", - Application => "application", - Customer => "customer", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateTaxIdOwnerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateTaxIdOwnerType::*; - match s { - "account" => Ok(Account), - "application" => Ok(Application), - "customer" => Ok(Customer), - "self" => Ok(Self_), - _ => Err(()), - } - } } -impl std::fmt::Display for CreateTaxIdOwnerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateTaxIdOwnerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) +impl<'a> RetrieveTaxId<'a> { + pub fn new() -> Self { + Self::default() } } -impl serde::Serialize for CreateTaxIdOwnerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl<'a> RetrieveTaxId<'a> { + /// Retrieves the `tax_id` object with the given identifier. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<stripe_shared::TaxId> { + client.get_query(&format!("/customers/{customer}/tax_ids/{id}"), self) } } -/// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. -#[derive(Copy, Clone, Eq, PartialEq)] -#[non_exhaustive] -pub enum CreateTaxIdType { - AdNrt, - AeTrn, - ArCuit, - AuAbn, - AuArn, - BgUic, - BoTin, - BrCnpj, - BrCpf, - CaBn, - CaGstHst, - CaPstBc, - CaPstMb, - CaPstSk, - CaQst, - ChVat, - ClTin, - CnTin, - CoNit, - CrTin, - DoRcn, - EcRuc, - EgTin, - EsCif, - EuOssVat, - EuVat, - GbVat, - GeVat, - HkBr, - HuTin, - IdNpwp, - IlVat, - InGst, - IsVat, - JpCn, - JpRn, - JpTrn, - KePin, - KrBrn, - LiUid, - MxRfc, - MyFrp, - MyItn, - MySst, - NoVat, - NzGst, - PeRuc, - PhTin, - RoTin, - RsPib, - RuInn, - RuKpp, - SaVat, - SgGst, - SgUen, - SiTin, - SvNit, - ThVat, - TrTin, - TwVat, - UaVat, - UsEin, - UyRuc, - VeRif, - VnTin, - ZaVat, - /// An unrecognized value from Stripe. Should not be used as a request parameter. - Unknown, -} -impl CreateTaxIdType { - pub fn as_str(self) -> &'static str { - use CreateTaxIdType::*; - match self { - AdNrt => "ad_nrt", - AeTrn => "ae_trn", - ArCuit => "ar_cuit", - AuAbn => "au_abn", - AuArn => "au_arn", - BgUic => "bg_uic", - BoTin => "bo_tin", - BrCnpj => "br_cnpj", - BrCpf => "br_cpf", - CaBn => "ca_bn", - CaGstHst => "ca_gst_hst", - CaPstBc => "ca_pst_bc", - CaPstMb => "ca_pst_mb", - CaPstSk => "ca_pst_sk", - CaQst => "ca_qst", - ChVat => "ch_vat", - ClTin => "cl_tin", - CnTin => "cn_tin", - CoNit => "co_nit", - CrTin => "cr_tin", - DoRcn => "do_rcn", - EcRuc => "ec_ruc", - EgTin => "eg_tin", - EsCif => "es_cif", - EuOssVat => "eu_oss_vat", - EuVat => "eu_vat", - GbVat => "gb_vat", - GeVat => "ge_vat", - HkBr => "hk_br", - HuTin => "hu_tin", - IdNpwp => "id_npwp", - IlVat => "il_vat", - InGst => "in_gst", - IsVat => "is_vat", - JpCn => "jp_cn", - JpRn => "jp_rn", - JpTrn => "jp_trn", - KePin => "ke_pin", - KrBrn => "kr_brn", - LiUid => "li_uid", - MxRfc => "mx_rfc", - MyFrp => "my_frp", - MyItn => "my_itn", - MySst => "my_sst", - NoVat => "no_vat", - NzGst => "nz_gst", - PeRuc => "pe_ruc", - PhTin => "ph_tin", - RoTin => "ro_tin", - RsPib => "rs_pib", - RuInn => "ru_inn", - RuKpp => "ru_kpp", - SaVat => "sa_vat", - SgGst => "sg_gst", - SgUen => "sg_uen", - SiTin => "si_tin", - SvNit => "sv_nit", - ThVat => "th_vat", - TrTin => "tr_tin", - TwVat => "tw_vat", - UaVat => "ua_vat", - UsEin => "us_ein", - UyRuc => "uy_ruc", - VeRif => "ve_rif", - VnTin => "vn_tin", - ZaVat => "za_vat", - Unknown => "unknown", - } - } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListCustomerTaxId<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, } - -impl std::str::FromStr for CreateTaxIdType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateTaxIdType::*; - match s { - "ad_nrt" => Ok(AdNrt), - "ae_trn" => Ok(AeTrn), - "ar_cuit" => Ok(ArCuit), - "au_abn" => Ok(AuAbn), - "au_arn" => Ok(AuArn), - "bg_uic" => Ok(BgUic), - "bo_tin" => Ok(BoTin), - "br_cnpj" => Ok(BrCnpj), - "br_cpf" => Ok(BrCpf), - "ca_bn" => Ok(CaBn), - "ca_gst_hst" => Ok(CaGstHst), - "ca_pst_bc" => Ok(CaPstBc), - "ca_pst_mb" => Ok(CaPstMb), - "ca_pst_sk" => Ok(CaPstSk), - "ca_qst" => Ok(CaQst), - "ch_vat" => Ok(ChVat), - "cl_tin" => Ok(ClTin), - "cn_tin" => Ok(CnTin), - "co_nit" => Ok(CoNit), - "cr_tin" => Ok(CrTin), - "do_rcn" => Ok(DoRcn), - "ec_ruc" => Ok(EcRuc), - "eg_tin" => Ok(EgTin), - "es_cif" => Ok(EsCif), - "eu_oss_vat" => Ok(EuOssVat), - "eu_vat" => Ok(EuVat), - "gb_vat" => Ok(GbVat), - "ge_vat" => Ok(GeVat), - "hk_br" => Ok(HkBr), - "hu_tin" => Ok(HuTin), - "id_npwp" => Ok(IdNpwp), - "il_vat" => Ok(IlVat), - "in_gst" => Ok(InGst), - "is_vat" => Ok(IsVat), - "jp_cn" => Ok(JpCn), - "jp_rn" => Ok(JpRn), - "jp_trn" => Ok(JpTrn), - "ke_pin" => Ok(KePin), - "kr_brn" => Ok(KrBrn), - "li_uid" => Ok(LiUid), - "mx_rfc" => Ok(MxRfc), - "my_frp" => Ok(MyFrp), - "my_itn" => Ok(MyItn), - "my_sst" => Ok(MySst), - "no_vat" => Ok(NoVat), - "nz_gst" => Ok(NzGst), - "pe_ruc" => Ok(PeRuc), - "ph_tin" => Ok(PhTin), - "ro_tin" => Ok(RoTin), - "rs_pib" => Ok(RsPib), - "ru_inn" => Ok(RuInn), - "ru_kpp" => Ok(RuKpp), - "sa_vat" => Ok(SaVat), - "sg_gst" => Ok(SgGst), - "sg_uen" => Ok(SgUen), - "si_tin" => Ok(SiTin), - "sv_nit" => Ok(SvNit), - "th_vat" => Ok(ThVat), - "tr_tin" => Ok(TrTin), - "tw_vat" => Ok(TwVat), - "ua_vat" => Ok(UaVat), - "us_ein" => Ok(UsEin), - "uy_ruc" => Ok(UyRuc), - "ve_rif" => Ok(VeRif), - "vn_tin" => Ok(VnTin), - "za_vat" => Ok(ZaVat), - _ => Err(()), - } +impl<'a> ListCustomerTaxId<'a> { + pub fn new() -> Self { + Self::default() } } -impl std::fmt::Display for CreateTaxIdType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) +impl<'a> ListCustomerTaxId<'a> { + /// Returns a list of tax IDs for a customer. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_types::List<stripe_shared::TaxId>> { + client.get_query(&format!("/customers/{customer}/tax_ids"), self) } -} - -impl std::fmt::Debug for CreateTaxIdType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + pub fn paginate(self, customer: &stripe_shared::CustomerId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TaxId>> { + stripe::ListPaginator::from_list_params(&format!("/customers/{customer}/tax_ids"), self) } } -impl serde::Serialize for CreateTaxIdType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteTaxId {} +impl DeleteTaxId { + pub fn new() -> Self { + Self::default() } } -impl<'a> CreateTaxId<'a> { - /// Creates a new account or customer `tax_id` object. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::TaxId> { - client.send_form("/tax_ids", self, http_types::Method::Post) +impl DeleteTaxId { + /// Deletes an existing `tax_id` object. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<stripe_shared::DeletedTaxId> { + client.send_form(&format!("/customers/{customer}/tax_ids/{id}"), self, http_types::Method::Delete) } } diff --git a/generated/stripe_billing/src/test_helpers_test_clock/requests.rs b/generated/stripe_billing/src/test_helpers_test_clock/requests.rs index 5afa16c10..da1a03ce5 100644 --- a/generated/stripe_billing/src/test_helpers_test_clock/requests.rs +++ b/generated/stripe_billing/src/test_helpers_test_clock/requests.rs @@ -1,64 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteTestHelpersTestClock {} -impl DeleteTestHelpersTestClock { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteTestHelpersTestClock { - /// Deletes a test clock. - pub fn send( - &self, - client: &stripe::Client, - test_clock: &stripe_shared::TestHelpersTestClockId, - ) -> stripe::Response<stripe_shared::DeletedTestHelpersTestClock> { - client.send_form( - &format!("/test_helpers/test_clocks/{test_clock}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListTestHelpersTestClock<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListTestHelpersTestClock<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListTestHelpersTestClock<'a> { - /// Returns a list of your test clocks. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::TestHelpersTestClock>> { - client.get_query("/test_helpers/test_clocks", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TestHelpersTestClock>> { - stripe::ListPaginator::from_list_params("/test_helpers/test_clocks", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveTestHelpersTestClock<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -71,11 +11,7 @@ impl<'a> RetrieveTestHelpersTestClock<'a> { } impl<'a> RetrieveTestHelpersTestClock<'a> { /// Retrieves a test clock. - pub fn send( - &self, - client: &stripe::Client, - test_clock: &stripe_shared::TestHelpersTestClockId, - ) -> stripe::Response<stripe_shared::TestHelpersTestClock> { + pub fn send(&self, client: &stripe::Client, test_clock: &stripe_shared::TestHelpersTestClockId) -> stripe::Response<stripe_shared::TestHelpersTestClock> { client.get_query(&format!("/test_helpers/test_clocks/{test_clock}"), self) } } @@ -97,13 +33,23 @@ impl<'a> CreateTestHelpersTestClock<'a> { } impl<'a> CreateTestHelpersTestClock<'a> { /// Creates a new test clock that can be attached to new customers and quotes. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_shared::TestHelpersTestClock> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::TestHelpersTestClock> { client.send_form("/test_helpers/test_clocks", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteTestHelpersTestClock {} +impl DeleteTestHelpersTestClock { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteTestHelpersTestClock { + /// Deletes a test clock. + pub fn send(&self, client: &stripe::Client, test_clock: &stripe_shared::TestHelpersTestClockId) -> stripe::Response<stripe_shared::DeletedTestHelpersTestClock> { + client.send_form(&format!("/test_helpers/test_clocks/{test_clock}"), self, http_types::Method::Delete) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct AdvanceTestHelpersTestClock<'a> { /// Specifies which fields in the response should be expanded. @@ -123,15 +69,41 @@ impl<'a> AdvanceTestHelpersTestClock<'a> { impl<'a> AdvanceTestHelpersTestClock<'a> { /// Starts advancing a test clock to a specified time in the future. /// Advancement is done when status changes to `Ready`. - pub fn send( - &self, - client: &stripe::Client, - test_clock: &stripe_shared::TestHelpersTestClockId, - ) -> stripe::Response<stripe_shared::TestHelpersTestClock> { - client.send_form( - &format!("/test_helpers/test_clocks/{test_clock}/advance"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, test_clock: &stripe_shared::TestHelpersTestClockId) -> stripe::Response<stripe_shared::TestHelpersTestClock> { + client.send_form(&format!("/test_helpers/test_clocks/{test_clock}/advance"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListTestHelpersTestClock<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListTestHelpersTestClock<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListTestHelpersTestClock<'a> { + /// Returns a list of your test clocks. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::TestHelpersTestClock>> { + client.get_query("/test_helpers/test_clocks", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TestHelpersTestClock>> { + stripe::ListPaginator::from_list_params("/test_helpers/test_clocks", self) } } diff --git a/generated/stripe_billing/src/usage_record/requests.rs b/generated/stripe_billing/src/usage_record/requests.rs index f684d93eb..888aa7af4 100644 --- a/generated/stripe_billing/src/usage_record/requests.rs +++ b/generated/stripe_billing/src/usage_record/requests.rs @@ -95,15 +95,7 @@ impl<'a> CreateSubscriptionItemUsageRecord<'a> { /// /// The default pricing model for metered billing is [per-unit pricing](https://stripe.com/docs/api/plans/object#plan_object-billing_scheme). /// For finer granularity, you can configure metered billing to have a [tiered pricing](https://stripe.com/docs/billing/subscriptions/tiers) model. - pub fn send( - &self, - client: &stripe::Client, - subscription_item: &stripe_shared::SubscriptionItemId, - ) -> stripe::Response<stripe_billing::UsageRecord> { - client.send_form( - &format!("/subscription_items/{subscription_item}/usage_records"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, subscription_item: &stripe_shared::SubscriptionItemId) -> stripe::Response<stripe_billing::UsageRecord> { + client.send_form(&format!("/subscription_items/{subscription_item}/usage_records"), self, http_types::Method::Post) } } diff --git a/generated/stripe_billing/src/usage_record/types.rs b/generated/stripe_billing/src/usage_record/types.rs index 92c7a9fae..489a111ca 100644 --- a/generated/stripe_billing/src/usage_record/types.rs +++ b/generated/stripe_billing/src/usage_record/types.rs @@ -4,7 +4,9 @@ /// Related guide: [Metered billing](https://stripe.com/docs/billing/subscriptions/metered-billing) /// /// For more details see <<https://stripe.com/docs/api/usage_records/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct UsageRecord { /// Unique identifier for the object. pub id: stripe_billing::UsageRecordId, @@ -17,6 +19,108 @@ pub struct UsageRecord { /// The timestamp when this usage occurred. pub timestamp: stripe_types::Timestamp, } +#[cfg(feature = "min-ser")] +pub struct UsageRecordBuilder { + id: Option<stripe_billing::UsageRecordId>, + livemode: Option<bool>, + quantity: Option<u64>, + subscription_item: Option<String>, + timestamp: Option<stripe_types::Timestamp>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for UsageRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<UsageRecord>, + builder: UsageRecordBuilder, + } + + impl Visitor for Place<UsageRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: UsageRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for UsageRecordBuilder { + type Out = UsageRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "quantity" => Deserialize::begin(&mut self.quantity), + "subscription_item" => Deserialize::begin(&mut self.subscription_item), + "timestamp" => Deserialize::begin(&mut self.timestamp), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), livemode: Deserialize::default(), quantity: Deserialize::default(), subscription_item: Deserialize::default(), timestamp: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let quantity = self.quantity.take()?; + let subscription_item = self.subscription_item.take()?; + let timestamp = self.timestamp.take()?; + + Some(Self::Out { id, livemode, quantity, subscription_item, timestamp }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for UsageRecord { + type Builder = UsageRecordBuilder; + } + + impl FromValueOpt for UsageRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = UsageRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "subscription_item" => b.subscription_item = Some(FromValueOpt::from_value(v)?), + "timestamp" => b.timestamp = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for UsageRecord { type Id = stripe_billing::UsageRecordId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_billing/src/usage_record_summary/requests.rs b/generated/stripe_billing/src/usage_record_summary/requests.rs index af87b912b..8153b3227 100644 --- a/generated/stripe_billing/src/usage_record_summary/requests.rs +++ b/generated/stripe_billing/src/usage_record_summary/requests.rs @@ -30,23 +30,10 @@ impl<'a> ListSubscriptionItemUsageRecordSummary<'a> { /// The list is sorted in reverse-chronological order (newest first). /// The first list item represents the most current usage period that hasn’t ended yet. /// Since new usage records can still be added, the returned summary information for the subscription item’s ID should be seen as unstable until the subscription billing period ends. - pub fn send( - &self, - client: &stripe::Client, - subscription_item: &stripe_shared::SubscriptionItemId, - ) -> stripe::Response<stripe_types::List<stripe_shared::UsageRecordSummary>> { - client.get_query( - &format!("/subscription_items/{subscription_item}/usage_record_summaries"), - self, - ) + pub fn send(&self, client: &stripe::Client, subscription_item: &stripe_shared::SubscriptionItemId) -> stripe::Response<stripe_types::List<stripe_shared::UsageRecordSummary>> { + client.get_query(&format!("/subscription_items/{subscription_item}/usage_record_summaries"), self) } - pub fn paginate( - self, - subscription_item: &stripe_shared::SubscriptionItemId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::UsageRecordSummary>> { - stripe::ListPaginator::from_list_params( - &format!("/subscription_items/{subscription_item}/usage_record_summaries"), - self, - ) + pub fn paginate(self, subscription_item: &stripe_shared::SubscriptionItemId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::UsageRecordSummary>> { + stripe::ListPaginator::from_list_params(&format!("/subscription_items/{subscription_item}/usage_record_summaries"), self) } } diff --git a/generated/stripe_checkout/.rustfmt.toml b/generated/stripe_checkout/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_checkout/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_checkout/Cargo.toml b/generated/stripe_checkout/Cargo.toml index 11ffe804b..7833d54a4 100644 --- a/generated/stripe_checkout/Cargo.toml +++ b/generated/stripe_checkout/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_checkout/src/checkout_acss_debit_mandate_options.rs b/generated/stripe_checkout/src/checkout_acss_debit_mandate_options.rs index 59a1eee71..53eae6f1b 100644 --- a/generated/stripe_checkout/src/checkout_acss_debit_mandate_options.rs +++ b/generated/stripe_checkout/src/checkout_acss_debit_mandate_options.rs @@ -1,11 +1,11 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutAcssDebitMandateOptions { /// A URL for custom mandate text - #[serde(skip_serializing_if = "Option::is_none")] pub custom_mandate_url: Option<String>, /// List of Stripe products where this mandate can be selected automatically. /// Returned when the Session is in `setup` mode. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for: Option<Vec<CheckoutAcssDebitMandateOptionsDefaultFor>>, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. @@ -15,6 +15,114 @@ pub struct CheckoutAcssDebitMandateOptions { /// Transaction type of the mandate. pub transaction_type: Option<CheckoutAcssDebitMandateOptionsTransactionType>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutAcssDebitMandateOptionsBuilder { + custom_mandate_url: Option<Option<String>>, + default_for: Option<Option<Vec<CheckoutAcssDebitMandateOptionsDefaultFor>>>, + interval_description: Option<Option<String>>, + payment_schedule: Option<Option<CheckoutAcssDebitMandateOptionsPaymentSchedule>>, + transaction_type: Option<Option<CheckoutAcssDebitMandateOptionsTransactionType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutAcssDebitMandateOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutAcssDebitMandateOptions>, + builder: CheckoutAcssDebitMandateOptionsBuilder, + } + + impl Visitor for Place<CheckoutAcssDebitMandateOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutAcssDebitMandateOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutAcssDebitMandateOptionsBuilder { + type Out = CheckoutAcssDebitMandateOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom_mandate_url" => Deserialize::begin(&mut self.custom_mandate_url), + "default_for" => Deserialize::begin(&mut self.default_for), + "interval_description" => Deserialize::begin(&mut self.interval_description), + "payment_schedule" => Deserialize::begin(&mut self.payment_schedule), + "transaction_type" => Deserialize::begin(&mut self.transaction_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + custom_mandate_url: Deserialize::default(), + default_for: Deserialize::default(), + interval_description: Deserialize::default(), + payment_schedule: Deserialize::default(), + transaction_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom_mandate_url = self.custom_mandate_url.take()?; + let default_for = self.default_for.take()?; + let interval_description = self.interval_description.take()?; + let payment_schedule = self.payment_schedule.take()?; + let transaction_type = self.transaction_type.take()?; + + Some(Self::Out { custom_mandate_url, default_for, interval_description, payment_schedule, transaction_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutAcssDebitMandateOptions { + type Builder = CheckoutAcssDebitMandateOptionsBuilder; + } + + impl FromValueOpt for CheckoutAcssDebitMandateOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutAcssDebitMandateOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom_mandate_url" => b.custom_mandate_url = Some(FromValueOpt::from_value(v)?), + "default_for" => b.default_for = Some(FromValueOpt::from_value(v)?), + "interval_description" => b.interval_description = Some(FromValueOpt::from_value(v)?), + "payment_schedule" => b.payment_schedule = Some(FromValueOpt::from_value(v)?), + "transaction_type" => b.transaction_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// List of Stripe products where this mandate can be selected automatically. /// Returned when the Session is in `setup` mode. #[derive(Copy, Clone, Eq, PartialEq)] @@ -66,11 +174,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsDefaultFor fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for CheckoutAcssDebitMandateOptionsDefaultFor") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAcssDebitMandateOptionsDefaultFor")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsDefaultFor { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsDefaultFor> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAcssDebitMandateOptionsDefaultFor::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsDefaultFor); /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutAcssDebitMandateOptionsPaymentSchedule { @@ -124,13 +248,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsPaymentSche fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAcssDebitMandateOptionsPaymentSchedule", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAcssDebitMandateOptionsPaymentSchedule")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsPaymentSchedule { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsPaymentSchedule> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAcssDebitMandateOptionsPaymentSchedule::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsPaymentSchedule); /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutAcssDebitMandateOptionsTransactionType { @@ -181,10 +319,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsTransaction fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAcssDebitMandateOptionsTransactionType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAcssDebitMandateOptionsTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitMandateOptionsTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAcssDebitMandateOptionsTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsTransactionType); diff --git a/generated/stripe_checkout/src/checkout_acss_debit_payment_method_options.rs b/generated/stripe_checkout/src/checkout_acss_debit_payment_method_options.rs index 68061a1ca..a8df93774 100644 --- a/generated/stripe_checkout/src/checkout_acss_debit_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_acss_debit_payment_method_options.rs @@ -1,9 +1,9 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutAcssDebitPaymentMethodOptions { /// Currency supported by the bank account. Returned when the Session is in `setup` mode. - #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<CheckoutAcssDebitPaymentMethodOptionsCurrency>, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option<stripe_checkout::CheckoutAcssDebitMandateOptions>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -11,12 +11,108 @@ pub struct CheckoutAcssDebitPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutAcssDebitPaymentMethodOptionsBuilder { + currency: Option<Option<CheckoutAcssDebitPaymentMethodOptionsCurrency>>, + mandate_options: Option<Option<stripe_checkout::CheckoutAcssDebitMandateOptions>>, + setup_future_usage: Option<Option<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage>>, + verification_method: Option<Option<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutAcssDebitPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutAcssDebitPaymentMethodOptions>, + builder: CheckoutAcssDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutAcssDebitPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutAcssDebitPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutAcssDebitPaymentMethodOptionsBuilder { + type Out = CheckoutAcssDebitPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "currency" => Deserialize::begin(&mut self.currency), + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { currency: Deserialize::default(), mandate_options: Deserialize::default(), setup_future_usage: Deserialize::default(), verification_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let currency = self.currency.take()?; + let mandate_options = self.mandate_options.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { currency, mandate_options, setup_future_usage, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutAcssDebitPaymentMethodOptions { + type Builder = CheckoutAcssDebitPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutAcssDebitPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutAcssDebitPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Currency supported by the bank account. Returned when the Session is in `setup` mode. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutAcssDebitPaymentMethodOptionsCurrency { @@ -67,13 +163,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsCurre fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAcssDebitPaymentMethodOptionsCurrency", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAcssDebitPaymentMethodOptionsCurrency")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsCurrency { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitPaymentMethodOptionsCurrency> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAcssDebitPaymentMethodOptionsCurrency::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsCurrency); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -132,13 +242,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsSetup fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage); /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutAcssDebitPaymentMethodOptionsVerificationMethod { @@ -192,10 +316,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsVerif fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAcssDebitPaymentMethodOptionsVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsVerificationMethod); diff --git a/generated/stripe_checkout/src/checkout_affirm_payment_method_options.rs b/generated/stripe_checkout/src/checkout_affirm_payment_method_options.rs index 80604c1c6..0ad7ff97e 100644 --- a/generated/stripe_checkout/src/checkout_affirm_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_affirm_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutAffirmPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutAffirmPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutAffirmPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutAffirmPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutAffirmPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutAffirmPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutAffirmPaymentMethodOptions>, + builder: CheckoutAffirmPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutAffirmPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutAffirmPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutAffirmPaymentMethodOptionsBuilder { + type Out = CheckoutAffirmPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutAffirmPaymentMethodOptions { + type Builder = CheckoutAffirmPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutAffirmPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutAffirmPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutAffirmPaymentMethodOptionsSetupFut fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAffirmPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAffirmPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAffirmPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_afterpay_clearpay_payment_method_options.rs b/generated/stripe_checkout/src/checkout_afterpay_clearpay_payment_method_options.rs index c61d395ef..7296b7cc8 100644 --- a/generated/stripe_checkout/src/checkout_afterpay_clearpay_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_afterpay_clearpay_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutAfterpayClearpayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutAfterpayClearpayPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutAfterpayClearpayPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutAfterpayClearpayPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutAfterpayClearpayPaymentMethodOptions>, + builder: CheckoutAfterpayClearpayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutAfterpayClearpayPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutAfterpayClearpayPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutAfterpayClearpayPaymentMethodOptionsBuilder { + type Out = CheckoutAfterpayClearpayPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutAfterpayClearpayPaymentMethodOptions { + type Builder = CheckoutAfterpayClearpayPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutAfterpayClearpayPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutAfterpayClearpayPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutAfterpayClearpayPaymentMethodOptio fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_alipay_payment_method_options.rs b/generated/stripe_checkout/src/checkout_alipay_payment_method_options.rs index 6d3b2d22f..62af264ff 100644 --- a/generated/stripe_checkout/src/checkout_alipay_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_alipay_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutAlipayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutAlipayPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutAlipayPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutAlipayPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutAlipayPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutAlipayPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutAlipayPaymentMethodOptions>, + builder: CheckoutAlipayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutAlipayPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutAlipayPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutAlipayPaymentMethodOptionsBuilder { + type Out = CheckoutAlipayPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutAlipayPaymentMethodOptions { + type Builder = CheckoutAlipayPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutAlipayPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutAlipayPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutAlipayPaymentMethodOptionsSetupFut fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAlipayPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAlipayPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAlipayPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_au_becs_debit_payment_method_options.rs b/generated/stripe_checkout/src/checkout_au_becs_debit_payment_method_options.rs index 4f9c61203..f75a906fa 100644 --- a/generated/stripe_checkout/src/checkout_au_becs_debit_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_au_becs_debit_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutAuBecsDebitPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutAuBecsDebitPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutAuBecsDebitPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutAuBecsDebitPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutAuBecsDebitPaymentMethodOptions>, + builder: CheckoutAuBecsDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutAuBecsDebitPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutAuBecsDebitPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutAuBecsDebitPaymentMethodOptionsBuilder { + type Out = CheckoutAuBecsDebitPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutAuBecsDebitPaymentMethodOptions { + type Builder = CheckoutAuBecsDebitPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutAuBecsDebitPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutAuBecsDebitPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutAuBecsDebitPaymentMethodOptionsSet fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_bacs_debit_payment_method_options.rs b/generated/stripe_checkout/src/checkout_bacs_debit_payment_method_options.rs index b0f75f13d..259f3a215 100644 --- a/generated/stripe_checkout/src/checkout_bacs_debit_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_bacs_debit_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutBacsDebitPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutBacsDebitPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutBacsDebitPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutBacsDebitPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutBacsDebitPaymentMethodOptions>, + builder: CheckoutBacsDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutBacsDebitPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutBacsDebitPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutBacsDebitPaymentMethodOptionsBuilder { + type Out = CheckoutBacsDebitPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutBacsDebitPaymentMethodOptions { + type Builder = CheckoutBacsDebitPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutBacsDebitPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutBacsDebitPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -67,10 +154,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutBacsDebitPaymentMethodOptionsSetup fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_bancontact_payment_method_options.rs b/generated/stripe_checkout/src/checkout_bancontact_payment_method_options.rs index 314fae8b3..e18e77d82 100644 --- a/generated/stripe_checkout/src/checkout_bancontact_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_bancontact_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutBancontactPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutBancontactPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutBancontactPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutBancontactPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutBancontactPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutBancontactPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutBancontactPaymentMethodOptions>, + builder: CheckoutBancontactPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutBancontactPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutBancontactPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutBancontactPaymentMethodOptionsBuilder { + type Out = CheckoutBancontactPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutBancontactPaymentMethodOptions { + type Builder = CheckoutBancontactPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutBancontactPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutBancontactPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutBancontactPaymentMethodOptionsSetu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutBancontactPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutBancontactPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutBancontactPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_boleto_payment_method_options.rs b/generated/stripe_checkout/src/checkout_boleto_payment_method_options.rs index ae3822b76..7e449212a 100644 --- a/generated/stripe_checkout/src/checkout_boleto_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_boleto_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutBoletoPaymentMethodOptions { /// The number of calendar days before a Boleto voucher expires. /// For example, if you create a Boleto voucher on Monday and you set expires_after_days to 2, the Boleto voucher will expire on Wednesday at 23:59 America/Sao_Paulo time. @@ -9,9 +11,98 @@ pub struct CheckoutBoletoPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutBoletoPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutBoletoPaymentMethodOptionsBuilder { + expires_after_days: Option<u32>, + setup_future_usage: Option<Option<CheckoutBoletoPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutBoletoPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutBoletoPaymentMethodOptions>, + builder: CheckoutBoletoPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutBoletoPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutBoletoPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutBoletoPaymentMethodOptionsBuilder { + type Out = CheckoutBoletoPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after_days" => Deserialize::begin(&mut self.expires_after_days), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_days: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after_days = self.expires_after_days.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { expires_after_days, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutBoletoPaymentMethodOptions { + type Builder = CheckoutBoletoPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutBoletoPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutBoletoPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after_days" => b.expires_after_days = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -70,10 +161,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutBoletoPaymentMethodOptionsSetupFut fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutBoletoPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutBoletoPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutBoletoPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_card_installments_options.rs b/generated/stripe_checkout/src/checkout_card_installments_options.rs index 369b58057..ee064d0e3 100644 --- a/generated/stripe_checkout/src/checkout_card_installments_options.rs +++ b/generated/stripe_checkout/src/checkout_card_installments_options.rs @@ -1,6 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutCardInstallmentsOptions { /// Indicates if installments are enabled - #[serde(skip_serializing_if = "Option::is_none")] pub enabled: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutCardInstallmentsOptionsBuilder { + enabled: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutCardInstallmentsOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutCardInstallmentsOptions>, + builder: CheckoutCardInstallmentsOptionsBuilder, + } + + impl Visitor for Place<CheckoutCardInstallmentsOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutCardInstallmentsOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutCardInstallmentsOptionsBuilder { + type Out = CheckoutCardInstallmentsOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutCardInstallmentsOptions { + type Builder = CheckoutCardInstallmentsOptionsBuilder; + } + + impl FromValueOpt for CheckoutCardInstallmentsOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutCardInstallmentsOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/checkout_card_payment_method_options.rs b/generated/stripe_checkout/src/checkout_card_payment_method_options.rs index 9ffb49170..f539f8f5e 100644 --- a/generated/stripe_checkout/src/checkout_card_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_card_payment_method_options.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutCardPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub installments: Option<stripe_checkout::CheckoutCardInstallmentsOptions>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -8,21 +9,121 @@ pub struct CheckoutCardPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutCardPaymentMethodOptionsSetupFutureUsage>, /// Provides information about a card payment that customers see on their statements. /// Concatenated with the Kana prefix (shortened Kana descriptor) or Kana statement descriptor that’s set on the account to form the complete statement descriptor. /// Maximum 22 characters. /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 22 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix_kana: Option<String>, /// Provides information about a card payment that customers see on their statements. /// Concatenated with the Kanji prefix (shortened Kanji descriptor) or Kanji statement descriptor that’s set on the account to form the complete statement descriptor. /// Maximum 17 characters. /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 17 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix_kanji: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutCardPaymentMethodOptionsBuilder { + installments: Option<Option<stripe_checkout::CheckoutCardInstallmentsOptions>>, + setup_future_usage: Option<Option<CheckoutCardPaymentMethodOptionsSetupFutureUsage>>, + statement_descriptor_suffix_kana: Option<Option<String>>, + statement_descriptor_suffix_kanji: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutCardPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutCardPaymentMethodOptions>, + builder: CheckoutCardPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutCardPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutCardPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutCardPaymentMethodOptionsBuilder { + type Out = CheckoutCardPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "installments" => Deserialize::begin(&mut self.installments), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "statement_descriptor_suffix_kana" => Deserialize::begin(&mut self.statement_descriptor_suffix_kana), + "statement_descriptor_suffix_kanji" => Deserialize::begin(&mut self.statement_descriptor_suffix_kanji), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + installments: Deserialize::default(), + setup_future_usage: Deserialize::default(), + statement_descriptor_suffix_kana: Deserialize::default(), + statement_descriptor_suffix_kanji: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let installments = self.installments.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let statement_descriptor_suffix_kana = self.statement_descriptor_suffix_kana.take()?; + let statement_descriptor_suffix_kanji = self.statement_descriptor_suffix_kanji.take()?; + + Some(Self::Out { installments, setup_future_usage, statement_descriptor_suffix_kana, statement_descriptor_suffix_kanji }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutCardPaymentMethodOptions { + type Builder = CheckoutCardPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutCardPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutCardPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "installments" => b.installments = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_suffix_kana" => b.statement_descriptor_suffix_kana = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_suffix_kanji" => b.statement_descriptor_suffix_kanji = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -81,10 +182,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsSetupFutur fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutCardPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutCardPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutCardPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutCardPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_cashapp_payment_method_options.rs b/generated/stripe_checkout/src/checkout_cashapp_payment_method_options.rs index 46f388cf5..05b6c9785 100644 --- a/generated/stripe_checkout/src/checkout_cashapp_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_cashapp_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutCashappPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutCashappPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutCashappPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutCashappPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutCashappPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutCashappPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutCashappPaymentMethodOptions>, + builder: CheckoutCashappPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutCashappPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutCashappPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutCashappPaymentMethodOptionsBuilder { + type Out = CheckoutCashappPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutCashappPaymentMethodOptions { + type Builder = CheckoutCashappPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutCashappPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutCashappPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutCashappPaymentMethodOptionsSetupFu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutCashappPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutCashappPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutCashappPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutCashappPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutCashappPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutCashappPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_customer_balance_bank_transfer_payment_method_options.rs b/generated/stripe_checkout/src/checkout_customer_balance_bank_transfer_payment_method_options.rs index 3641e961b..5472bd1cd 100644 --- a/generated/stripe_checkout/src/checkout_customer_balance_bank_transfer_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_customer_balance_bank_transfer_payment_method_options.rs @@ -1,18 +1,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutCustomerBalanceBankTransferPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub eu_bank_transfer: Option<stripe_shared::PaymentMethodOptionsCustomerBalanceEuBankAccount>, /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. - #[serde(skip_serializing_if = "Option::is_none")] - pub requested_address_types: - Option<Vec<CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes>>, + pub requested_address_types: Option<Vec<CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes>>, /// The bank transfer type that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder { + eu_bank_transfer: Option<Option<stripe_shared::PaymentMethodOptionsCustomerBalanceEuBankAccount>>, + requested_address_types: Option<Option<Vec<CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes>>>, + type_: Option<Option<CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutCustomerBalanceBankTransferPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutCustomerBalanceBankTransferPaymentMethodOptions>, + builder: CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutCustomerBalanceBankTransferPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder { + type Out = CheckoutCustomerBalanceBankTransferPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "eu_bank_transfer" => Deserialize::begin(&mut self.eu_bank_transfer), + "requested_address_types" => Deserialize::begin(&mut self.requested_address_types), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eu_bank_transfer: Deserialize::default(), requested_address_types: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let eu_bank_transfer = self.eu_bank_transfer.take()?; + let requested_address_types = self.requested_address_types.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { eu_bank_transfer, requested_address_types, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutCustomerBalanceBankTransferPaymentMethodOptions { + type Builder = CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutCustomerBalanceBankTransferPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "eu_bank_transfer" => b.eu_bank_transfer = Some(FromValueOpt::from_value(v)?), + "requested_address_types" => b.requested_address_types = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// @@ -42,9 +135,7 @@ impl CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressType } } -impl std::str::FromStr - for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes -{ +impl std::str::FromStr for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes::*; @@ -60,24 +151,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes -{ +impl std::fmt::Display for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes -{ +impl std::fmt::Debug for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes -{ +impl serde::Serialize for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -85,15 +170,31 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes -{ +impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes); /// The bank transfer type that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType { @@ -153,10 +254,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalanceBankTransferPayment fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType); diff --git a/generated/stripe_checkout/src/checkout_customer_balance_payment_method_options.rs b/generated/stripe_checkout/src/checkout_customer_balance_payment_method_options.rs index 19bab27af..aba3744d9 100644 --- a/generated/stripe_checkout/src/checkout_customer_balance_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_customer_balance_payment_method_options.rs @@ -1,8 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutCustomerBalancePaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] - pub bank_transfer: - Option<stripe_checkout::CheckoutCustomerBalanceBankTransferPaymentMethodOptions>, + pub bank_transfer: Option<stripe_checkout::CheckoutCustomerBalanceBankTransferPaymentMethodOptions>, /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. pub funding_type: Option<CheckoutCustomerBalancePaymentMethodOptionsFundingType>, @@ -12,9 +12,102 @@ pub struct CheckoutCustomerBalancePaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutCustomerBalancePaymentMethodOptionsBuilder { + bank_transfer: Option<Option<stripe_checkout::CheckoutCustomerBalanceBankTransferPaymentMethodOptions>>, + funding_type: Option<Option<CheckoutCustomerBalancePaymentMethodOptionsFundingType>>, + setup_future_usage: Option<Option<CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutCustomerBalancePaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutCustomerBalancePaymentMethodOptions>, + builder: CheckoutCustomerBalancePaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutCustomerBalancePaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutCustomerBalancePaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutCustomerBalancePaymentMethodOptionsBuilder { + type Out = CheckoutCustomerBalancePaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_transfer" => Deserialize::begin(&mut self.bank_transfer), + "funding_type" => Deserialize::begin(&mut self.funding_type), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transfer: Deserialize::default(), funding_type: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_transfer = self.bank_transfer.take()?; + let funding_type = self.funding_type.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { bank_transfer, funding_type, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutCustomerBalancePaymentMethodOptions { + type Builder = CheckoutCustomerBalancePaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutCustomerBalancePaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutCustomerBalancePaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_transfer" => b.bank_transfer = Some(FromValueOpt::from_value(v)?), + "funding_type" => b.funding_type = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -63,13 +156,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalancePaymentMethodOption fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutCustomerBalancePaymentMethodOptionsFundingType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutCustomerBalancePaymentMethodOptionsFundingType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutCustomerBalancePaymentMethodOptionsFundingType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutCustomerBalancePaymentMethodOptionsFundingType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutCustomerBalancePaymentMethodOptionsFundingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutCustomerBalancePaymentMethodOptionsFundingType); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -122,10 +229,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalancePaymentMethodOption fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_eps_payment_method_options.rs b/generated/stripe_checkout/src/checkout_eps_payment_method_options.rs index 41fe0654f..1309e7cc8 100644 --- a/generated/stripe_checkout/src/checkout_eps_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_eps_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutEpsPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutEpsPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutEpsPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutEpsPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutEpsPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutEpsPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutEpsPaymentMethodOptions>, + builder: CheckoutEpsPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutEpsPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutEpsPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutEpsPaymentMethodOptionsBuilder { + type Out = CheckoutEpsPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutEpsPaymentMethodOptions { + type Builder = CheckoutEpsPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutEpsPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutEpsPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutEpsPaymentMethodOptionsSetupFuture fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutEpsPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutEpsPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutEpsPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutEpsPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutEpsPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutEpsPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_fpx_payment_method_options.rs b/generated/stripe_checkout/src/checkout_fpx_payment_method_options.rs index 62c72842b..72a136982 100644 --- a/generated/stripe_checkout/src/checkout_fpx_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_fpx_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutFpxPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutFpxPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutFpxPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutFpxPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutFpxPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutFpxPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutFpxPaymentMethodOptions>, + builder: CheckoutFpxPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutFpxPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutFpxPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutFpxPaymentMethodOptionsBuilder { + type Out = CheckoutFpxPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutFpxPaymentMethodOptions { + type Builder = CheckoutFpxPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutFpxPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutFpxPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutFpxPaymentMethodOptionsSetupFuture fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutFpxPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutFpxPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutFpxPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutFpxPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutFpxPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutFpxPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_giropay_payment_method_options.rs b/generated/stripe_checkout/src/checkout_giropay_payment_method_options.rs index be0f793b1..714e0465a 100644 --- a/generated/stripe_checkout/src/checkout_giropay_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_giropay_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutGiropayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutGiropayPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutGiropayPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutGiropayPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutGiropayPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutGiropayPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutGiropayPaymentMethodOptions>, + builder: CheckoutGiropayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutGiropayPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutGiropayPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutGiropayPaymentMethodOptionsBuilder { + type Out = CheckoutGiropayPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutGiropayPaymentMethodOptions { + type Builder = CheckoutGiropayPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutGiropayPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutGiropayPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutGiropayPaymentMethodOptionsSetupFu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutGiropayPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutGiropayPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutGiropayPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_grab_pay_payment_method_options.rs b/generated/stripe_checkout/src/checkout_grab_pay_payment_method_options.rs index 45c3689b4..83a323960 100644 --- a/generated/stripe_checkout/src/checkout_grab_pay_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_grab_pay_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutGrabPayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutGrabPayPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutGrabPayPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutGrabPayPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutGrabPayPaymentMethodOptions>, + builder: CheckoutGrabPayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutGrabPayPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutGrabPayPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutGrabPayPaymentMethodOptionsBuilder { + type Out = CheckoutGrabPayPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutGrabPayPaymentMethodOptions { + type Builder = CheckoutGrabPayPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutGrabPayPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutGrabPayPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutGrabPayPaymentMethodOptionsSetupFu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_ideal_payment_method_options.rs b/generated/stripe_checkout/src/checkout_ideal_payment_method_options.rs index e65a3ade5..a8dd43057 100644 --- a/generated/stripe_checkout/src/checkout_ideal_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_ideal_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutIdealPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutIdealPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutIdealPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutIdealPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutIdealPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutIdealPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutIdealPaymentMethodOptions>, + builder: CheckoutIdealPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutIdealPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutIdealPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutIdealPaymentMethodOptionsBuilder { + type Out = CheckoutIdealPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutIdealPaymentMethodOptions { + type Builder = CheckoutIdealPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutIdealPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutIdealPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutIdealPaymentMethodOptionsSetupFutu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutIdealPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutIdealPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutIdealPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutIdealPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutIdealPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutIdealPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_klarna_payment_method_options.rs b/generated/stripe_checkout/src/checkout_klarna_payment_method_options.rs index 9b679b237..ee31a47b8 100644 --- a/generated/stripe_checkout/src/checkout_klarna_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_klarna_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutKlarnaPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutKlarnaPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutKlarnaPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutKlarnaPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutKlarnaPaymentMethodOptions>, + builder: CheckoutKlarnaPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutKlarnaPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutKlarnaPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutKlarnaPaymentMethodOptionsBuilder { + type Out = CheckoutKlarnaPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutKlarnaPaymentMethodOptions { + type Builder = CheckoutKlarnaPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutKlarnaPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutKlarnaPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -67,10 +154,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutKlarnaPaymentMethodOptionsSetupFut fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_konbini_payment_method_options.rs b/generated/stripe_checkout/src/checkout_konbini_payment_method_options.rs index 987398a44..2c0112321 100644 --- a/generated/stripe_checkout/src/checkout_konbini_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_konbini_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutKonbiniPaymentMethodOptions { /// The number of calendar days (between 1 and 60) after which Konbini payment instructions will expire. /// For example, if a PaymentIntent is confirmed with Konbini and `expires_after_days` set to 2 on Monday JST, the instructions will expire on Wednesday 23:59:59 JST. @@ -9,9 +11,98 @@ pub struct CheckoutKonbiniPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutKonbiniPaymentMethodOptionsBuilder { + expires_after_days: Option<Option<u32>>, + setup_future_usage: Option<Option<CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutKonbiniPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutKonbiniPaymentMethodOptions>, + builder: CheckoutKonbiniPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutKonbiniPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutKonbiniPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutKonbiniPaymentMethodOptionsBuilder { + type Out = CheckoutKonbiniPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after_days" => Deserialize::begin(&mut self.expires_after_days), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_days: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after_days = self.expires_after_days.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { expires_after_days, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutKonbiniPaymentMethodOptions { + type Builder = CheckoutKonbiniPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutKonbiniPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutKonbiniPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after_days" => b.expires_after_days = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -64,10 +155,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutKonbiniPaymentMethodOptionsSetupFu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_link_payment_method_options.rs b/generated/stripe_checkout/src/checkout_link_payment_method_options.rs index f10f8db36..8984956f5 100644 --- a/generated/stripe_checkout/src/checkout_link_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_link_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutLinkPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutLinkPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutLinkPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutLinkPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutLinkPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutLinkPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutLinkPaymentMethodOptions>, + builder: CheckoutLinkPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutLinkPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutLinkPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutLinkPaymentMethodOptionsBuilder { + type Out = CheckoutLinkPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutLinkPaymentMethodOptions { + type Builder = CheckoutLinkPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutLinkPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutLinkPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -64,10 +151,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutLinkPaymentMethodOptionsSetupFutur fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutLinkPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutLinkPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutLinkPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutLinkPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutLinkPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutLinkPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_oxxo_payment_method_options.rs b/generated/stripe_checkout/src/checkout_oxxo_payment_method_options.rs index c0d72ab60..d4def25ce 100644 --- a/generated/stripe_checkout/src/checkout_oxxo_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_oxxo_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutOxxoPaymentMethodOptions { /// The number of calendar days before an OXXO invoice expires. /// For example, if you create an OXXO invoice on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time. @@ -9,9 +11,98 @@ pub struct CheckoutOxxoPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutOxxoPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutOxxoPaymentMethodOptionsBuilder { + expires_after_days: Option<u32>, + setup_future_usage: Option<Option<CheckoutOxxoPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutOxxoPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutOxxoPaymentMethodOptions>, + builder: CheckoutOxxoPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutOxxoPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutOxxoPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutOxxoPaymentMethodOptionsBuilder { + type Out = CheckoutOxxoPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after_days" => Deserialize::begin(&mut self.expires_after_days), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_days: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after_days = self.expires_after_days.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { expires_after_days, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutOxxoPaymentMethodOptions { + type Builder = CheckoutOxxoPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutOxxoPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutOxxoPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after_days" => b.expires_after_days = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -64,10 +155,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutOxxoPaymentMethodOptionsSetupFutur fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutOxxoPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutOxxoPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutOxxoPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_p24_payment_method_options.rs b/generated/stripe_checkout/src/checkout_p24_payment_method_options.rs index b981d386d..fe69aa322 100644 --- a/generated/stripe_checkout/src/checkout_p24_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_p24_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutP24PaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutP24PaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutP24PaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutP24PaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutP24PaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutP24PaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutP24PaymentMethodOptions>, + builder: CheckoutP24PaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutP24PaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutP24PaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutP24PaymentMethodOptionsBuilder { + type Out = CheckoutP24PaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutP24PaymentMethodOptions { + type Builder = CheckoutP24PaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutP24PaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutP24PaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutP24PaymentMethodOptionsSetupFuture fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutP24PaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutP24PaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutP24PaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutP24PaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutP24PaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutP24PaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_paynow_payment_method_options.rs b/generated/stripe_checkout/src/checkout_paynow_payment_method_options.rs index ec18d8378..411f2c83a 100644 --- a/generated/stripe_checkout/src/checkout_paynow_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_paynow_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutPaynowPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutPaynowPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutPaynowPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutPaynowPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutPaynowPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutPaynowPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutPaynowPaymentMethodOptions>, + builder: CheckoutPaynowPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutPaynowPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutPaynowPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutPaynowPaymentMethodOptionsBuilder { + type Out = CheckoutPaynowPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutPaynowPaymentMethodOptions { + type Builder = CheckoutPaynowPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutPaynowPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutPaynowPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutPaynowPaymentMethodOptionsSetupFut fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutPaynowPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutPaynowPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutPaynowPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_paypal_payment_method_options.rs b/generated/stripe_checkout/src/checkout_paypal_payment_method_options.rs index 38778a97b..ca2be29fb 100644 --- a/generated/stripe_checkout/src/checkout_paypal_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_paypal_payment_method_options.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutPaypalPaymentMethodOptions { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<CheckoutPaypalPaymentMethodOptionsCaptureMethod>, /// Preferred locale of the PayPal checkout page that the customer is redirected to. pub preferred_locale: Option<String>, @@ -14,9 +15,106 @@ pub struct CheckoutPaypalPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutPaypalPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutPaypalPaymentMethodOptionsBuilder { + capture_method: Option<Option<CheckoutPaypalPaymentMethodOptionsCaptureMethod>>, + preferred_locale: Option<Option<String>>, + reference: Option<Option<String>>, + setup_future_usage: Option<Option<CheckoutPaypalPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutPaypalPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutPaypalPaymentMethodOptions>, + builder: CheckoutPaypalPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutPaypalPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutPaypalPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutPaypalPaymentMethodOptionsBuilder { + type Out = CheckoutPaypalPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "preferred_locale" => Deserialize::begin(&mut self.preferred_locale), + "reference" => Deserialize::begin(&mut self.reference), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { capture_method: Deserialize::default(), preferred_locale: Deserialize::default(), reference: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let preferred_locale = self.preferred_locale.take()?; + let reference = self.reference.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { capture_method, preferred_locale, reference, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutPaypalPaymentMethodOptions { + type Builder = CheckoutPaypalPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutPaypalPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutPaypalPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "preferred_locale" => b.preferred_locale = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutPaypalPaymentMethodOptionsCaptureMethod { @@ -64,13 +162,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutPaypalPaymentMethodOptionsCaptureM fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutPaypalPaymentMethodOptionsCaptureMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutPaypalPaymentMethodOptionsCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutPaypalPaymentMethodOptionsCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutPaypalPaymentMethodOptionsCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutPaypalPaymentMethodOptionsCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutPaypalPaymentMethodOptionsCaptureMethod); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -126,10 +238,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutPaypalPaymentMethodOptionsSetupFut fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutPaypalPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutPaypalPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutPaypalPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_pix_payment_method_options.rs b/generated/stripe_checkout/src/checkout_pix_payment_method_options.rs index e36949e64..5dbbadd36 100644 --- a/generated/stripe_checkout/src/checkout_pix_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_pix_payment_method_options.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutPixPaymentMethodOptions { /// The number of seconds after which Pix payment will expire. pub expires_after_seconds: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutPixPaymentMethodOptionsBuilder { + expires_after_seconds: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutPixPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutPixPaymentMethodOptions>, + builder: CheckoutPixPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutPixPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutPixPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutPixPaymentMethodOptionsBuilder { + type Out = CheckoutPixPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after_seconds" => Deserialize::begin(&mut self.expires_after_seconds), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_seconds: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after_seconds = self.expires_after_seconds.take()?; + + Some(Self::Out { expires_after_seconds }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutPixPaymentMethodOptions { + type Builder = CheckoutPixPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutPixPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutPixPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after_seconds" => b.expires_after_seconds = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/checkout_revolut_pay_payment_method_options.rs b/generated/stripe_checkout/src/checkout_revolut_pay_payment_method_options.rs index a780a71df..60233ce60 100644 --- a/generated/stripe_checkout/src/checkout_revolut_pay_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_revolut_pay_payment_method_options.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutRevolutPayPaymentMethodOptions {} +#[cfg(feature = "min-ser")] +pub struct CheckoutRevolutPayPaymentMethodOptionsBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutRevolutPayPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutRevolutPayPaymentMethodOptions>, + builder: CheckoutRevolutPayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutRevolutPayPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutRevolutPayPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutRevolutPayPaymentMethodOptionsBuilder { + type Out = CheckoutRevolutPayPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutRevolutPayPaymentMethodOptions { + type Builder = CheckoutRevolutPayPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutRevolutPayPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutRevolutPayPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/checkout_sepa_debit_payment_method_options.rs b/generated/stripe_checkout/src/checkout_sepa_debit_payment_method_options.rs index 363e0f3a6..af9a4e21d 100644 --- a/generated/stripe_checkout/src/checkout_sepa_debit_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_sepa_debit_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutSepaDebitPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutSepaDebitPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutSepaDebitPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutSepaDebitPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutSepaDebitPaymentMethodOptions>, + builder: CheckoutSepaDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutSepaDebitPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutSepaDebitPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutSepaDebitPaymentMethodOptionsBuilder { + type Out = CheckoutSepaDebitPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutSepaDebitPaymentMethodOptions { + type Builder = CheckoutSepaDebitPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutSepaDebitPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutSepaDebitPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -67,10 +154,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutSepaDebitPaymentMethodOptionsSetup fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_session/requests.rs b/generated/stripe_checkout/src/checkout_session/requests.rs index d7bcb4a45..9ae6dffce 100644 --- a/generated/stripe_checkout/src/checkout_session/requests.rs +++ b/generated/stripe_checkout/src/checkout_session/requests.rs @@ -1,8 +1,5 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListCheckoutSession<'a> { - /// Only return the Checkout Sessions that were created during the given date interval. - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, /// Only return the Checkout Sessions for the Customer specified. #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<&'a str>, @@ -57,15 +54,10 @@ impl<'a> ListCheckoutSessionCustomerDetails<'a> { } impl<'a> ListCheckoutSession<'a> { /// Returns a list of Checkout Sessions. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_checkout::CheckoutSession>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_checkout::CheckoutSession>> { client.get_query("/checkout/sessions", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_checkout::CheckoutSession>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_checkout::CheckoutSession>> { stripe::ListPaginator::from_list_params("/checkout/sessions", self) } } @@ -82,60 +74,11 @@ impl<'a> RetrieveCheckoutSession<'a> { } impl<'a> RetrieveCheckoutSession<'a> { /// Retrieves a Session object. - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_checkout::CheckoutSessionId, - ) -> stripe::Response<stripe_checkout::CheckoutSession> { + pub fn send(&self, client: &stripe::Client, session: &stripe_checkout::CheckoutSessionId) -> stripe::Response<stripe_checkout::CheckoutSession> { client.get_query(&format!("/checkout/sessions/{session}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListLineItemsCheckoutSession<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListLineItemsCheckoutSession<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListLineItemsCheckoutSession<'a> { - /// When retrieving a Checkout Session, there is an includable **line_items** property containing the first handful of those items. - /// There is also a URL where you can retrieve the full (paginated) list of line items. - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_checkout::CheckoutSessionId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { - client.get_query(&format!("/checkout/sessions/{session}/line_items"), self) - } - pub fn paginate( - self, - session: &stripe_checkout::CheckoutSessionId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { - stripe::ListPaginator::from_list_params( - &format!("/checkout/sessions/{session}/line_items"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSession<'a> { /// Configure actions after a Checkout Session has expired. #[serde(skip_serializing_if = "Option::is_none")] @@ -145,11 +88,10 @@ pub struct CreateCheckoutSession<'a> { pub allow_promotion_codes: Option<bool>, /// Settings for automatic tax lookup for this session and resulting payments, invoices, and subscriptions. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<CreateCheckoutSessionAutomaticTax<'a>>, + pub automatic_tax: Option<CreateCheckoutSessionAutomaticTax>, /// Specify whether Checkout should collect the customer's billing address. #[serde(skip_serializing_if = "Option::is_none")] - pub billing_address_collection: - Option<stripe_checkout::CheckoutSessionBillingAddressCollection>, + pub billing_address_collection: Option<stripe_checkout::CheckoutSessionBillingAddressCollection>, /// If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website. #[serde(skip_serializing_if = "Option::is_none")] pub cancel_url: Option<&'a str>, @@ -167,7 +109,7 @@ pub struct CreateCheckoutSession<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<stripe_types::Currency>, /// Collect additional information from your customer using custom fields. - /// Up to 3 fields are supported. + /// Up to 2 fields are supported. #[serde(skip_serializing_if = "Option::is_none")] pub custom_fields: Option<&'a [CreateCheckoutSessionCustomFields<'a>]>, /// Display additional text for your customers using custom text. @@ -308,7 +250,8 @@ pub struct CreateCheckoutSession<'a> { pub shipping_options: Option<&'a [CreateCheckoutSessionShippingOptions<'a>]>, /// Describes the type of transaction being performed by Checkout in order to customize /// relevant text on the page, such as the submit button. `submit_type` can only be - /// specified on Checkout Sessions in `payment` mode. If blank or `auto`, `pay` is used. + /// specified on Checkout Sessions in `payment` mode, but not Checkout Sessions + /// in `subscription` or `setup` mode. #[serde(skip_serializing_if = "Option::is_none")] pub submit_type: Option<stripe_checkout::CheckoutSessionSubmitType>, /// A subset of parameters to be passed to subscription creation for Checkout Sessions in `subscription` mode. @@ -363,91 +306,18 @@ impl CreateCheckoutSessionAfterExpirationRecovery { } /// Settings for automatic tax lookup for this session and resulting payments, invoices, and subscriptions. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCheckoutSessionAutomaticTax<'a> { +pub struct CreateCheckoutSessionAutomaticTax { /// Set to true to enable automatic taxes. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<CreateCheckoutSessionAutomaticTaxLiability<'a>>, } -impl<'a> CreateCheckoutSessionAutomaticTax<'a> { +impl CreateCheckoutSessionAutomaticTax { pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCheckoutSessionAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateCheckoutSessionAutomaticTaxLiabilityType, -} -impl<'a> CreateCheckoutSessionAutomaticTaxLiability<'a> { - pub fn new(type_: CreateCheckoutSessionAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateCheckoutSessionAutomaticTaxLiabilityType { - Account, - Self_, -} -impl CreateCheckoutSessionAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use CreateCheckoutSessionAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateCheckoutSessionAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateCheckoutSessionAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateCheckoutSessionAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateCheckoutSessionAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateCheckoutSessionAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) + Self { enabled } } } /// Configure fields for the Checkout Session to gather active consent from customers. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionConsentCollection { - /// Determines the display of payment method reuse agreement text in the UI. - /// If set to `hidden`, it will hide legal text related to the reuse of a payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method_reuse_agreement: - Option<CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement>, /// If set to `auto`, enables the collection of customer consent for promotional communications. /// The Checkout. /// Session will determine whether to display an option to opt into promotional communication @@ -464,78 +334,6 @@ impl CreateCheckoutSessionConsentCollection { Self::default() } } -/// Determines the display of payment method reuse agreement text in the UI. -/// If set to `hidden`, it will hide legal text related to the reuse of a payment method. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement { - /// Determines the position and visibility of the payment method reuse agreement in the UI. - /// When set to `auto`, Stripe's. - /// defaults will be used. - /// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. - pub position: CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition, -} -impl CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement { - pub fn new( - position: CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition, - ) -> Self { - Self { position } - } -} -/// Determines the position and visibility of the payment method reuse agreement in the UI. -/// When set to `auto`, Stripe's. -/// defaults will be used. -/// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition { - Auto, - Hidden, -} -impl CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition { - pub fn as_str(self) -> &'static str { - use CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition::*; - match self { - Auto => "auto", - Hidden => "hidden", - } - } -} - -impl std::str::FromStr - for CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition::*; - match s { - "auto" => Ok(Auto), - "hidden" => Ok(Hidden), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If set to `auto`, enables the collection of customer consent for promotional communications. /// The Checkout. /// Session will determine whether to display an option to opt into promotional communication @@ -633,7 +431,7 @@ impl serde::Serialize for CreateCheckoutSessionConsentCollectionTermsOfService { } } /// Collect additional information from your customer using custom fields. -/// Up to 3 fields are supported. +/// Up to 2 fields are supported. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionCustomFields<'a> { /// Configuration for `type=dropdown` fields. @@ -655,15 +453,11 @@ pub struct CreateCheckoutSessionCustomFields<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub text: Option<CreateCheckoutSessionCustomFieldsText>, /// The type of the field. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateCheckoutSessionCustomFieldsType, } impl<'a> CreateCheckoutSessionCustomFields<'a> { - pub fn new( - key: &'a str, - label: CreateCheckoutSessionCustomFieldsLabel<'a>, - type_: CreateCheckoutSessionCustomFieldsType, - ) -> Self { + pub fn new(key: &'a str, label: CreateCheckoutSessionCustomFieldsLabel<'a>, type_: CreateCheckoutSessionCustomFieldsType) -> Self { Self { dropdown: None, key, label, numeric: None, optional: None, text: None, type_ } } } @@ -698,7 +492,7 @@ pub struct CreateCheckoutSessionCustomFieldsLabel<'a> { /// Custom text for the label, displayed to the customer. Up to 50 characters. pub custom: &'a str, /// The type of the label. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateCheckoutSessionCustomFieldsLabelType, } impl<'a> CreateCheckoutSessionCustomFieldsLabel<'a> { @@ -831,9 +625,6 @@ impl serde::Serialize for CreateCheckoutSessionCustomFieldsType { /// Display additional text for your customers using custom text. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionCustomText<'a> { - /// Custom text that should be displayed after the payment confirmation button. - #[serde(skip_serializing_if = "Option::is_none")] - pub after_submit: Option<CustomTextPositionParam<'a>>, /// Custom text that should be displayed alongside shipping address collection. #[serde(skip_serializing_if = "Option::is_none")] pub shipping_address: Option<CustomTextPositionParam<'a>>, @@ -1102,18 +893,13 @@ pub struct CreateCheckoutSessionInvoiceCreationInvoiceData<'a> { pub account_tax_ids: Option<&'a [&'a str]>, /// Default custom fields to be displayed on invoices for this customer. #[serde(skip_serializing_if = "Option::is_none")] - pub custom_fields: - Option<&'a [CreateCheckoutSessionInvoiceCreationInvoiceDataCustomFields<'a>]>, + pub custom_fields: Option<&'a [CreateCheckoutSessionInvoiceCreationInvoiceDataCustomFields<'a>]>, /// An arbitrary string attached to the object. Often useful for displaying to users. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<&'a str>, /// Default footer to be displayed on invoices for this customer. #[serde(skip_serializing_if = "Option::is_none")] pub footer: Option<&'a str>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreateCheckoutSessionInvoiceCreationInvoiceDataIssuer<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -1142,68 +928,6 @@ impl<'a> CreateCheckoutSessionInvoiceCreationInvoiceDataCustomFields<'a> { Self { name, value } } } -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCheckoutSessionInvoiceCreationInvoiceDataIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType, -} -impl<'a> CreateCheckoutSessionInvoiceCreationInvoiceDataIssuer<'a> { - pub fn new(type_: CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType { - Account, - Self_, -} -impl CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType { - pub fn as_str(self) -> &'static str { - use CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Default options for invoice PDF rendering for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptions { @@ -1212,8 +936,7 @@ pub struct CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptions { /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: - Option<CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay>, + pub amount_tax_display: Option<CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay>, } impl CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptions { pub fn new() -> Self { @@ -1239,9 +962,7 @@ impl CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDis } } -impl std::str::FromStr - for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::str::FromStr for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay::*; @@ -1252,24 +973,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::fmt::Display for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::fmt::Debug for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl serde::Serialize for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1369,15 +1084,7 @@ pub struct CreateCheckoutSessionLineItemsPriceData<'a> { } impl<'a> CreateCheckoutSessionLineItemsPriceData<'a> { pub fn new(currency: stripe_types::Currency) -> Self { - Self { - currency, - product: None, - product_data: None, - recurring: None, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + Self { currency, product: None, product_data: None, recurring: None, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// Data used to generate a new product object inline. One of `product` or `product_data` is required. @@ -1414,7 +1121,7 @@ pub struct CreateCheckoutSessionLineItemsPriceDataRecurring { pub interval: CreateCheckoutSessionLineItemsPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -1737,10 +1444,7 @@ pub struct CreateCheckoutSessionPaymentIntentDataShipping<'a> { pub tracking_number: Option<&'a str>, } impl<'a> CreateCheckoutSessionPaymentIntentDataShipping<'a> { - pub fn new( - address: CreateCheckoutSessionPaymentIntentDataShippingAddress<'a>, - name: &'a str, - ) -> Self { + pub fn new(address: CreateCheckoutSessionPaymentIntentDataShippingAddress<'a>, name: &'a str) -> Self { Self { address, carrier: None, name, phone: None, tracking_number: None } } } @@ -1924,9 +1628,6 @@ pub struct CreateCheckoutSessionPaymentMethodOptions<'a> { /// contains details about the Sofort payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<CreateCheckoutSessionPaymentMethodOptionsSofort>, - /// contains details about the Swish payment method options. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<CreateCheckoutSessionPaymentMethodOptionsSwish<'a>>, /// contains details about the Us Bank Account payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<CreateCheckoutSessionPaymentMethodOptionsUsBankAccount<'a>>, @@ -1949,8 +1650,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsAcssDebit<'a> { pub currency: Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitCurrency>, /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptions<'a>>, + pub mandate_options: Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptions<'a>>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -1958,12 +1658,10 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsAcssDebit<'a> { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitSetupFutureUsage>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitVerificationMethod>, } impl<'a> CreateCheckoutSessionPaymentMethodOptionsAcssDebit<'a> { pub fn new() -> Self { @@ -2029,20 +1727,17 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptions<'a> /// List of Stripe products where this mandate can be selected automatically. /// Only usable in `setup` mode. #[serde(skip_serializing_if = "Option::is_none")] - pub default_for: - Option<&'a [CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, + pub default_for: Option<&'a [CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, /// Description of the mandate interval. /// Only required if 'payment_schedule' parameter is 'interval' or 'combined'. #[serde(skip_serializing_if = "Option::is_none")] pub interval_description: Option<&'a str>, /// Payment schedule for the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_schedule: - Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, + pub payment_schedule: Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: - Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, + pub transaction_type: Option<CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl<'a> CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub fn new() -> Self { @@ -2066,9 +1761,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor::*; @@ -2079,24 +1772,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor -{ +impl std::fmt::Debug for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor -{ +impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2122,9 +1809,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSche } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule::*; @@ -2136,24 +1821,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Debug for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2177,9 +1856,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransaction } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -2190,24 +1867,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2393,8 +2064,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpay { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpay { pub fn new() -> Self { @@ -2420,9 +2090,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage { } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage::*; @@ -2432,9 +2100,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -2445,9 +2111,7 @@ impl std::fmt::Debug for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearp f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage -{ +impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2530,8 +2194,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsAuBecsDebit { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsAuBecsDebit { pub fn new() -> Self { @@ -2596,8 +2259,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsBacsDebit { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsBacsDebitSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsBacsDebitSetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsBacsDebit { pub fn new() -> Self { @@ -2668,8 +2330,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsBancontact { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsBancontactSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsBancontactSetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsBancontact { pub fn new() -> Self { @@ -2905,8 +2566,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsCashapp { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsCashappSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsCashappSetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsCashapp { pub fn new() -> Self { @@ -2972,8 +2632,7 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsCashappSetupF pub struct CreateCheckoutSessionPaymentMethodOptionsCustomerBalance<'a> { /// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. #[serde(skip_serializing_if = "Option::is_none")] - pub bank_transfer: - Option<CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, + pub bank_transfer: Option<CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. #[serde(skip_serializing_if = "Option::is_none")] @@ -2985,8 +2644,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsCustomerBalance<'a> { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, } impl<'a> CreateCheckoutSessionPaymentMethodOptionsCustomerBalance<'a> { pub fn new() -> Self { @@ -2997,23 +2655,20 @@ impl<'a> CreateCheckoutSessionPaymentMethodOptionsCustomerBalance<'a> { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { /// Configuration for eu_bank_transfer funding type. -#[serde(skip_serializing_if = "Option::is_none")] -pub eu_bank_transfer: Option<CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer<'a>>, - /// List of address types that should be returned in the financial_addresses response. + #[serde(skip_serializing_if = "Option::is_none")] + pub eu_bank_transfer: Option<CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer<'a>>, + /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. -#[serde(skip_serializing_if = "Option::is_none")] -pub requested_address_types: Option<&'a [CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, + #[serde(skip_serializing_if = "Option::is_none")] + pub requested_address_types: Option<&'a [CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, /// The list of bank transfer types that this PaymentIntent is allowed to use for funding. -#[serde(rename = "type")] -pub type_: CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType, - + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType, } impl<'a> CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { - pub fn new( - type_: CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType, - ) -> Self { + pub fn new(type_: CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType) -> Self { Self { eu_bank_transfer: None, requested_address_types: None, type_ } } } @@ -3058,9 +2713,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequest } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes::*; @@ -3076,24 +2729,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Debug for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3123,9 +2770,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType { } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType::*; @@ -3139,9 +2784,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -3223,9 +2866,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage { } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage::*; @@ -3235,9 +2876,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -3396,8 +3035,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsGiropay { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsGiropaySetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsGiropaySetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsGiropay { pub fn new() -> Self { @@ -3462,8 +3100,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsGrabpay { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsGrabpaySetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsGrabpaySetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsGrabpay { pub fn new() -> Self { @@ -3663,8 +3300,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsKonbini { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsKonbiniSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsKonbiniSetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsKonbini { pub fn new() -> Self { @@ -4247,8 +3883,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsRevolutPay { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsRevolutPaySetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsRevolutPaySetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsRevolutPay { pub fn new() -> Self { @@ -4316,8 +3951,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsSepaDebit { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsSepaDebitSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsSepaDebitSetupFutureUsage>, } impl CreateCheckoutSessionPaymentMethodOptionsSepaDebit { pub fn new() -> Self { @@ -4443,26 +4077,12 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsSofortSetupFu serializer.serialize_str(self.as_str()) } } -/// contains details about the Swish payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateCheckoutSessionPaymentMethodOptionsSwish<'a> { - /// The order reference that will be displayed to customers in the Swish application. - /// Defaults to the `id` of the Payment Intent. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference: Option<&'a str>, -} -impl<'a> CreateCheckoutSessionPaymentMethodOptionsSwish<'a> { - pub fn new() -> Self { - Self::default() - } -} /// contains details about the Us Bank Account payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, + pub financial_connections: Option<CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -4470,12 +4090,10 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsUsBankAccount<'a> { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsUsBankAccountSetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsUsBankAccountSetupFutureUsage>, /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> CreateCheckoutSessionPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -4485,15 +4103,14 @@ impl<'a> CreateCheckoutSessionPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { - /// The list of permissions to request. + /// The list of permissions to request. /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. -#[serde(skip_serializing_if = "Option::is_none")] -pub permissions: Option<&'a [CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, + #[serde(skip_serializing_if = "Option::is_none")] + pub permissions: Option<&'a [CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. -#[serde(skip_serializing_if = "Option::is_none")] -pub prefetch: Option<&'a [CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, - + #[serde(skip_serializing_if = "Option::is_none")] + pub prefetch: Option<&'a [CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, } impl<'a> CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { pub fn new() -> Self { @@ -4522,9 +4139,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsP } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; @@ -4537,24 +4152,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4566,49 +4175,38 @@ impl serde::Serialize #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } impl CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4686,9 +4284,7 @@ impl CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod { } } -impl std::str::FromStr - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::str::FromStr for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod::*; @@ -4699,9 +4295,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl std::fmt::Display for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -4735,8 +4329,7 @@ pub struct CreateCheckoutSessionPaymentMethodOptionsWechatPay<'a> { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreateCheckoutSessionPaymentMethodOptionsWechatPaySetupFutureUsage>, + pub setup_future_usage: Option<CreateCheckoutSessionPaymentMethodOptionsWechatPaySetupFutureUsage>, } impl<'a> CreateCheckoutSessionPaymentMethodOptionsWechatPay<'a> { pub fn new(client: CreateCheckoutSessionPaymentMethodOptionsWechatPayClient) -> Self { @@ -4883,7 +4476,6 @@ pub enum CreateCheckoutSessionPaymentMethodTypes { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -4923,7 +4515,6 @@ impl CreateCheckoutSessionPaymentMethodTypes { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -4966,7 +4557,6 @@ impl std::str::FromStr for CreateCheckoutSessionPaymentMethodTypes { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -5038,9 +4628,7 @@ pub struct CreateCheckoutSessionShippingAddressCollection<'a> { pub allowed_countries: &'a [CreateCheckoutSessionShippingAddressCollectionAllowedCountries], } impl<'a> CreateCheckoutSessionShippingAddressCollection<'a> { - pub fn new( - allowed_countries: &'a [CreateCheckoutSessionShippingAddressCollectionAllowedCountries], - ) -> Self { + pub fn new(allowed_countries: &'a [CreateCheckoutSessionShippingAddressCollectionAllowedCountries]) -> Self { Self { allowed_countries } } } @@ -5822,8 +5410,7 @@ pub struct CreateCheckoutSessionShippingOptionsShippingRateData<'a> { /// The estimated range for how long shipping will take, meant to be displayable to the customer. /// This will appear on CheckoutSessions. #[serde(skip_serializing_if = "Option::is_none")] - pub delivery_estimate: - Option<CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimate>, + pub delivery_estimate: Option<CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimate>, /// The name of the shipping rate, meant to be displayable to the customer. /// This will appear on CheckoutSessions. pub display_name: &'a str, @@ -5845,21 +5432,13 @@ pub struct CreateCheckoutSessionShippingOptionsShippingRateData<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub tax_code: Option<&'a str>, /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CreateCheckoutSessionShippingOptionsShippingRateDataType>, } impl<'a> CreateCheckoutSessionShippingOptionsShippingRateData<'a> { pub fn new(display_name: &'a str) -> Self { - Self { - delivery_estimate: None, - display_name, - fixed_amount: None, - metadata: None, - tax_behavior: None, - tax_code: None, - type_: None, - } + Self { delivery_estimate: None, display_name, fixed_amount: None, metadata: None, tax_behavior: None, tax_code: None, type_: None } } } /// The estimated range for how long shipping will take, meant to be displayable to the customer. @@ -5868,12 +5447,10 @@ impl<'a> CreateCheckoutSessionShippingOptionsShippingRateData<'a> { pub struct CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimate { /// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. #[serde(skip_serializing_if = "Option::is_none")] - pub maximum: - Option<CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximum>, + pub maximum: Option<CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximum>, /// The lower bound of the estimated range. If empty, represents no lower bound. #[serde(skip_serializing_if = "Option::is_none")] - pub minimum: - Option<CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimum>, + pub minimum: Option<CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimum>, } impl CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimate { pub fn new() -> Self { @@ -5889,10 +5466,7 @@ pub struct CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateM pub value: i64, } impl CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximum { - pub fn new( - unit: CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit, - value: i64, - ) -> Self { + pub fn new(unit: CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit, value: i64) -> Self { Self { unit, value } } } @@ -5918,9 +5492,7 @@ impl CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximum } } -impl std::str::FromStr - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit -{ +impl std::str::FromStr for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit::*; @@ -5934,24 +5506,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit -{ +impl std::fmt::Display for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit -{ +impl std::fmt::Debug for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit -{ +impl serde::Serialize for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5968,10 +5534,7 @@ pub struct CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateM pub value: i64, } impl CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimum { - pub fn new( - unit: CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit, - value: i64, - ) -> Self { + pub fn new(unit: CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit, value: i64) -> Self { Self { unit, value } } } @@ -5997,9 +5560,7 @@ impl CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimum } } -impl std::str::FromStr - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit -{ +impl std::str::FromStr for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit::*; @@ -6013,24 +5574,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit -{ +impl std::fmt::Display for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit -{ +impl std::fmt::Debug for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit -{ +impl serde::Serialize for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -6049,12 +5604,7 @@ pub struct CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmount<'a> { /// Shipping rates defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - &'a std::collections::HashMap< - stripe_types::Currency, - CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptions, - >, - >, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptions>>, } impl<'a> CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmount<'a> { pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { @@ -6070,9 +5620,7 @@ pub struct CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurren /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option< - CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior, - >, + pub tax_behavior: Option<CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior>, } impl CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptions { pub fn new(amount: i64) -> Self { @@ -6098,9 +5646,7 @@ impl CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOpti } } -impl std::str::FromStr - for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::str::FromStr for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior::*; @@ -6112,24 +5658,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::fmt::Display for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl std::fmt::Debug for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior -{ +impl serde::Serialize for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -6252,9 +5792,6 @@ pub struct CreateCheckoutSessionSubscriptionData<'a> { /// for rendering in the [customer portal](https://stripe.com/docs/customer-management). #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<&'a str>, - /// All invoices will be billed using the specified settings. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<CreateCheckoutSessionSubscriptionDataInvoiceSettings<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -6289,81 +5826,6 @@ impl<'a> CreateCheckoutSessionSubscriptionData<'a> { Self::default() } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateCheckoutSessionSubscriptionDataInvoiceSettings<'a> { - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuer<'a>>, -} -impl<'a> CreateCheckoutSessionSubscriptionDataInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType, -} -impl<'a> CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuer<'a> { - pub fn new(type_: CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType { - Account, - Self_, -} -impl CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Determines how to handle prorations resulting from the `billing_cycle_anchor`. /// If no value is passed, the default is `create_prorations`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -6434,9 +5896,7 @@ pub struct CreateCheckoutSessionSubscriptionDataTrialSettings { pub end_behavior: CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior, } impl CreateCheckoutSessionSubscriptionDataTrialSettings { - pub fn new( - end_behavior: CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior, - ) -> Self { + pub fn new(end_behavior: CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior) -> Self { Self { end_behavior } } } @@ -6444,13 +5904,10 @@ impl CreateCheckoutSessionSubscriptionDataTrialSettings { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior { /// Indicates how the subscription should change when the trial ends if the user did not provide a payment method. - pub missing_payment_method: - CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod, + pub missing_payment_method: CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod, } impl CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior { - pub fn new( - missing_payment_method: CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod, - ) -> Self { + pub fn new(missing_payment_method: CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod) -> Self { Self { missing_payment_method } } } @@ -6472,9 +5929,7 @@ impl CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPayment } } -impl std::str::FromStr - for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ +impl std::str::FromStr for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::*; @@ -6486,24 +5941,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ +impl std::fmt::Display for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ +impl std::fmt::Debug for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ +impl serde::Serialize for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -6524,14 +5973,46 @@ impl CreateCheckoutSessionTaxIdCollection { } impl<'a> CreateCheckoutSession<'a> { /// Creates a Session object. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_checkout::CheckoutSession> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_checkout::CheckoutSession> { client.send_form("/checkout/sessions", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListLineItemsCheckoutSession<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListLineItemsCheckoutSession<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListLineItemsCheckoutSession<'a> { + /// When retrieving a Checkout Session, there is an includable **line_items** property containing the first handful of those items. + /// There is also a URL where you can retrieve the full (paginated) list of line items. + pub fn send(&self, client: &stripe::Client, session: &stripe_checkout::CheckoutSessionId) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + client.get_query(&format!("/checkout/sessions/{session}/line_items"), self) + } + pub fn paginate(self, session: &stripe_checkout::CheckoutSessionId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + stripe::ListPaginator::from_list_params(&format!("/checkout/sessions/{session}/line_items"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ExpireCheckoutSession<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -6546,16 +6027,8 @@ impl<'a> ExpireCheckoutSession<'a> { /// A Session can be expired when it is in one of these statuses: `open` /// /// After it expires, a customer can’t complete a Session and customers loading the Session see a message saying the Session is expired. - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_checkout::CheckoutSessionId, - ) -> stripe::Response<stripe_checkout::CheckoutSession> { - client.send_form( - &format!("/checkout/sessions/{session}/expire"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, session: &stripe_checkout::CheckoutSessionId) -> stripe::Response<stripe_checkout::CheckoutSession> { + client.send_form(&format!("/checkout/sessions/{session}/expire"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] diff --git a/generated/stripe_checkout/src/checkout_session/types.rs b/generated/stripe_checkout/src/checkout_session/types.rs index c3a08e6f4..08b6e0354 100644 --- a/generated/stripe_checkout/src/checkout_session/types.rs +++ b/generated/stripe_checkout/src/checkout_session/types.rs @@ -14,7 +14,9 @@ /// Related guide: [Checkout quickstart](https://stripe.com/docs/checkout/quickstart) /// /// For more details see <<https://stripe.com/docs/api/checkout/sessions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutSession { /// When set, provides configuration for actions to take if this Checkout Session expires. pub after_expiration: Option<stripe_checkout::PaymentPagesCheckoutSessionAfterExpiration>, @@ -26,8 +28,7 @@ pub struct CheckoutSession { pub amount_total: Option<i64>, pub automatic_tax: stripe_checkout::PaymentPagesCheckoutSessionAutomaticTax, /// Describes whether Checkout should collect the customer's billing address. - pub billing_address_collection: - Option<stripe_checkout::CheckoutSessionBillingAddressCollection>, + pub billing_address_collection: Option<stripe_checkout::CheckoutSessionBillingAddressCollection>, /// If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website. pub cancel_url: Option<String>, /// A unique string to reference the Checkout Session. This can be a @@ -48,7 +49,7 @@ pub struct CheckoutSession { /// Currency conversion details for automatic currency conversion sessions pub currency_conversion: Option<stripe_checkout::PaymentPagesCheckoutSessionCurrencyConversion>, /// Collect additional information from your customer using custom fields. - /// Up to 3 fields are supported. + /// Up to 2 fields are supported. pub custom_fields: Vec<stripe_checkout::PaymentPagesCheckoutSessionCustomFields>, pub custom_text: stripe_checkout::PaymentPagesCheckoutSessionCustomText, /// The ID of the customer for this Session. @@ -77,7 +78,6 @@ pub struct CheckoutSession { /// Details on the state of invoice creation for the Checkout Session. pub invoice_creation: Option<stripe_checkout::PaymentPagesCheckoutSessionInvoiceCreation>, /// The line items purchased by the customer. - #[serde(skip_serializing_if = "Option::is_none")] pub line_items: Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, @@ -96,8 +96,7 @@ pub struct CheckoutSession { /// Configure whether a Checkout Session should collect a payment method. pub payment_method_collection: Option<CheckoutSessionPaymentMethodCollection>, /// Information about the payment method configuration used for this Checkout session if using dynamic payment methods. - pub payment_method_configuration_details: - Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>, + pub payment_method_configuration_details: Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>, /// Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession. pub payment_method_options: Option<stripe_checkout::CheckoutSessionPaymentMethodOptions>, /// A list of the types of payment methods (e.g. card) this Checkout @@ -106,25 +105,20 @@ pub struct CheckoutSession { /// The payment status of the Checkout Session, one of `paid`, `unpaid`, or `no_payment_required`. /// You can use this value to decide when to fulfill your customer's order. pub payment_status: CheckoutSessionPaymentStatus, - #[serde(skip_serializing_if = "Option::is_none")] - pub phone_number_collection: - Option<stripe_checkout::PaymentPagesCheckoutSessionPhoneNumberCollection>, + pub phone_number_collection: Option<stripe_checkout::PaymentPagesCheckoutSessionPhoneNumberCollection>, /// The ID of the original expired Checkout Session that triggered the recovery flow. pub recovered_from: Option<String>, /// Applies to Checkout Sessions with `ui_mode: embedded`. /// By default, Stripe will always redirect to your return_url after a successful confirmation. /// If you set `redirect_on_completion: 'if_required'`, then we will only redirect if your user chooses a redirect-based payment method. - #[serde(skip_serializing_if = "Option::is_none")] pub redirect_on_completion: Option<stripe_checkout::CheckoutSessionRedirectOnCompletion>, /// Applies to Checkout Sessions with `ui_mode: embedded`. /// The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site. - #[serde(skip_serializing_if = "Option::is_none")] pub return_url: Option<String>, /// The ID of the SetupIntent for Checkout Sessions in `setup` mode. pub setup_intent: Option<stripe_types::Expandable<stripe_shared::SetupIntent>>, /// When set, provides configuration for Checkout to collect a shipping address from a customer. - pub shipping_address_collection: - Option<stripe_checkout::PaymentPagesCheckoutSessionShippingAddressCollection>, + pub shipping_address_collection: Option<stripe_checkout::PaymentPagesCheckoutSessionShippingAddressCollection>, /// The details of the customer cost of shipping, including the customer chosen ShippingRate. pub shipping_cost: Option<stripe_checkout::PaymentPagesCheckoutSessionShippingCost>, /// Shipping information for this Checkout Session. @@ -135,14 +129,14 @@ pub struct CheckoutSession { pub status: Option<stripe_checkout::CheckoutSessionStatus>, /// Describes the type of transaction being performed by Checkout in order to customize /// relevant text on the page, such as the submit button. `submit_type` can only be - /// specified on Checkout Sessions in `payment` mode. If blank or `auto`, `pay` is used. + /// specified on Checkout Sessions in `payment` mode, but not Checkout Sessions + /// in `subscription` or `setup` mode. pub submit_type: Option<stripe_checkout::CheckoutSessionSubmitType>, /// The ID of the subscription for Checkout Sessions in `subscription` mode. pub subscription: Option<stripe_types::Expandable<stripe_shared::Subscription>>, /// The URL the customer will be directed to after the payment or /// subscription creation is successful. pub success_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub tax_id_collection: Option<stripe_checkout::PaymentPagesCheckoutSessionTaxIdCollection>, /// Tax and discount details for the computed total amount. pub total_details: Option<stripe_checkout::PaymentPagesCheckoutSessionTotalDetails>, @@ -155,6 +149,408 @@ pub struct CheckoutSession { /// This value is only present when the session is active. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutSessionBuilder { + after_expiration: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionAfterExpiration>>, + allow_promotion_codes: Option<Option<bool>>, + amount_subtotal: Option<Option<i64>>, + amount_total: Option<Option<i64>>, + automatic_tax: Option<stripe_checkout::PaymentPagesCheckoutSessionAutomaticTax>, + billing_address_collection: Option<Option<stripe_checkout::CheckoutSessionBillingAddressCollection>>, + cancel_url: Option<Option<String>>, + client_reference_id: Option<Option<String>>, + client_secret: Option<Option<String>>, + consent: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionConsent>>, + consent_collection: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionConsentCollection>>, + created: Option<stripe_types::Timestamp>, + currency: Option<Option<stripe_types::Currency>>, + currency_conversion: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCurrencyConversion>>, + custom_fields: Option<Vec<stripe_checkout::PaymentPagesCheckoutSessionCustomFields>>, + custom_text: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomText>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + customer_creation: Option<Option<CheckoutSessionCustomerCreation>>, + customer_details: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCustomerDetails>>, + customer_email: Option<Option<String>>, + expires_at: Option<stripe_types::Timestamp>, + id: Option<stripe_checkout::CheckoutSessionId>, + invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + invoice_creation: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionInvoiceCreation>>, + line_items: Option<Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>>, + livemode: Option<bool>, + locale: Option<Option<stripe_checkout::CheckoutSessionLocale>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + mode: Option<stripe_checkout::CheckoutSessionMode>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, + payment_link: Option<Option<stripe_types::Expandable<stripe_shared::PaymentLink>>>, + payment_method_collection: Option<Option<CheckoutSessionPaymentMethodCollection>>, + payment_method_configuration_details: Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>, + payment_method_options: Option<Option<stripe_checkout::CheckoutSessionPaymentMethodOptions>>, + payment_method_types: Option<Vec<String>>, + payment_status: Option<CheckoutSessionPaymentStatus>, + phone_number_collection: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionPhoneNumberCollection>>, + recovered_from: Option<Option<String>>, + redirect_on_completion: Option<Option<stripe_checkout::CheckoutSessionRedirectOnCompletion>>, + return_url: Option<Option<String>>, + setup_intent: Option<Option<stripe_types::Expandable<stripe_shared::SetupIntent>>>, + shipping_address_collection: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionShippingAddressCollection>>, + shipping_cost: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionShippingCost>>, + shipping_details: Option<Option<stripe_shared::Shipping>>, + shipping_options: Option<Vec<stripe_checkout::PaymentPagesCheckoutSessionShippingOption>>, + status: Option<Option<stripe_checkout::CheckoutSessionStatus>>, + submit_type: Option<Option<stripe_checkout::CheckoutSessionSubmitType>>, + subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>, + success_url: Option<Option<String>>, + tax_id_collection: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionTaxIdCollection>>, + total_details: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionTotalDetails>>, + ui_mode: Option<Option<stripe_checkout::CheckoutSessionUiMode>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutSession { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutSession>, + builder: CheckoutSessionBuilder, + } + + impl Visitor for Place<CheckoutSession> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutSessionBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutSessionBuilder { + type Out = CheckoutSession; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "after_expiration" => Deserialize::begin(&mut self.after_expiration), + "allow_promotion_codes" => Deserialize::begin(&mut self.allow_promotion_codes), + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "billing_address_collection" => Deserialize::begin(&mut self.billing_address_collection), + "cancel_url" => Deserialize::begin(&mut self.cancel_url), + "client_reference_id" => Deserialize::begin(&mut self.client_reference_id), + "client_secret" => Deserialize::begin(&mut self.client_secret), + "consent" => Deserialize::begin(&mut self.consent), + "consent_collection" => Deserialize::begin(&mut self.consent_collection), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "currency_conversion" => Deserialize::begin(&mut self.currency_conversion), + "custom_fields" => Deserialize::begin(&mut self.custom_fields), + "custom_text" => Deserialize::begin(&mut self.custom_text), + "customer" => Deserialize::begin(&mut self.customer), + "customer_creation" => Deserialize::begin(&mut self.customer_creation), + "customer_details" => Deserialize::begin(&mut self.customer_details), + "customer_email" => Deserialize::begin(&mut self.customer_email), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "invoice_creation" => Deserialize::begin(&mut self.invoice_creation), + "line_items" => Deserialize::begin(&mut self.line_items), + "livemode" => Deserialize::begin(&mut self.livemode), + "locale" => Deserialize::begin(&mut self.locale), + "metadata" => Deserialize::begin(&mut self.metadata), + "mode" => Deserialize::begin(&mut self.mode), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "payment_link" => Deserialize::begin(&mut self.payment_link), + "payment_method_collection" => Deserialize::begin(&mut self.payment_method_collection), + "payment_method_configuration_details" => Deserialize::begin(&mut self.payment_method_configuration_details), + "payment_method_options" => Deserialize::begin(&mut self.payment_method_options), + "payment_method_types" => Deserialize::begin(&mut self.payment_method_types), + "payment_status" => Deserialize::begin(&mut self.payment_status), + "phone_number_collection" => Deserialize::begin(&mut self.phone_number_collection), + "recovered_from" => Deserialize::begin(&mut self.recovered_from), + "redirect_on_completion" => Deserialize::begin(&mut self.redirect_on_completion), + "return_url" => Deserialize::begin(&mut self.return_url), + "setup_intent" => Deserialize::begin(&mut self.setup_intent), + "shipping_address_collection" => Deserialize::begin(&mut self.shipping_address_collection), + "shipping_cost" => Deserialize::begin(&mut self.shipping_cost), + "shipping_details" => Deserialize::begin(&mut self.shipping_details), + "shipping_options" => Deserialize::begin(&mut self.shipping_options), + "status" => Deserialize::begin(&mut self.status), + "submit_type" => Deserialize::begin(&mut self.submit_type), + "subscription" => Deserialize::begin(&mut self.subscription), + "success_url" => Deserialize::begin(&mut self.success_url), + "tax_id_collection" => Deserialize::begin(&mut self.tax_id_collection), + "total_details" => Deserialize::begin(&mut self.total_details), + "ui_mode" => Deserialize::begin(&mut self.ui_mode), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + after_expiration: Deserialize::default(), + allow_promotion_codes: Deserialize::default(), + amount_subtotal: Deserialize::default(), + amount_total: Deserialize::default(), + automatic_tax: Deserialize::default(), + billing_address_collection: Deserialize::default(), + cancel_url: Deserialize::default(), + client_reference_id: Deserialize::default(), + client_secret: Deserialize::default(), + consent: Deserialize::default(), + consent_collection: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + currency_conversion: Deserialize::default(), + custom_fields: Deserialize::default(), + custom_text: Deserialize::default(), + customer: Deserialize::default(), + customer_creation: Deserialize::default(), + customer_details: Deserialize::default(), + customer_email: Deserialize::default(), + expires_at: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + invoice_creation: Deserialize::default(), + line_items: Deserialize::default(), + livemode: Deserialize::default(), + locale: Deserialize::default(), + metadata: Deserialize::default(), + mode: Deserialize::default(), + payment_intent: Deserialize::default(), + payment_link: Deserialize::default(), + payment_method_collection: Deserialize::default(), + payment_method_configuration_details: Deserialize::default(), + payment_method_options: Deserialize::default(), + payment_method_types: Deserialize::default(), + payment_status: Deserialize::default(), + phone_number_collection: Deserialize::default(), + recovered_from: Deserialize::default(), + redirect_on_completion: Deserialize::default(), + return_url: Deserialize::default(), + setup_intent: Deserialize::default(), + shipping_address_collection: Deserialize::default(), + shipping_cost: Deserialize::default(), + shipping_details: Deserialize::default(), + shipping_options: Deserialize::default(), + status: Deserialize::default(), + submit_type: Deserialize::default(), + subscription: Deserialize::default(), + success_url: Deserialize::default(), + tax_id_collection: Deserialize::default(), + total_details: Deserialize::default(), + ui_mode: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let after_expiration = self.after_expiration.take()?; + let allow_promotion_codes = self.allow_promotion_codes.take()?; + let amount_subtotal = self.amount_subtotal.take()?; + let amount_total = self.amount_total.take()?; + let automatic_tax = self.automatic_tax.take()?; + let billing_address_collection = self.billing_address_collection.take()?; + let cancel_url = self.cancel_url.take()?; + let client_reference_id = self.client_reference_id.take()?; + let client_secret = self.client_secret.take()?; + let consent = self.consent.take()?; + let consent_collection = self.consent_collection.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let currency_conversion = self.currency_conversion.take()?; + let custom_fields = self.custom_fields.take()?; + let custom_text = self.custom_text.take()?; + let customer = self.customer.take()?; + let customer_creation = self.customer_creation.take()?; + let customer_details = self.customer_details.take()?; + let customer_email = self.customer_email.take()?; + let expires_at = self.expires_at.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let invoice_creation = self.invoice_creation.take()?; + let line_items = self.line_items.take()?; + let livemode = self.livemode.take()?; + let locale = self.locale.take()?; + let metadata = self.metadata.take()?; + let mode = self.mode.take()?; + let payment_intent = self.payment_intent.take()?; + let payment_link = self.payment_link.take()?; + let payment_method_collection = self.payment_method_collection.take()?; + let payment_method_configuration_details = self.payment_method_configuration_details.take()?; + let payment_method_options = self.payment_method_options.take()?; + let payment_method_types = self.payment_method_types.take()?; + let payment_status = self.payment_status.take()?; + let phone_number_collection = self.phone_number_collection.take()?; + let recovered_from = self.recovered_from.take()?; + let redirect_on_completion = self.redirect_on_completion.take()?; + let return_url = self.return_url.take()?; + let setup_intent = self.setup_intent.take()?; + let shipping_address_collection = self.shipping_address_collection.take()?; + let shipping_cost = self.shipping_cost.take()?; + let shipping_details = self.shipping_details.take()?; + let shipping_options = self.shipping_options.take()?; + let status = self.status.take()?; + let submit_type = self.submit_type.take()?; + let subscription = self.subscription.take()?; + let success_url = self.success_url.take()?; + let tax_id_collection = self.tax_id_collection.take()?; + let total_details = self.total_details.take()?; + let ui_mode = self.ui_mode.take()?; + let url = self.url.take()?; + + Some(Self::Out { + after_expiration, + allow_promotion_codes, + amount_subtotal, + amount_total, + automatic_tax, + billing_address_collection, + cancel_url, + client_reference_id, + client_secret, + consent, + consent_collection, + created, + currency, + currency_conversion, + custom_fields, + custom_text, + customer, + customer_creation, + customer_details, + customer_email, + expires_at, + id, + invoice, + invoice_creation, + line_items, + livemode, + locale, + metadata, + mode, + payment_intent, + payment_link, + payment_method_collection, + payment_method_configuration_details, + payment_method_options, + payment_method_types, + payment_status, + phone_number_collection, + recovered_from, + redirect_on_completion, + return_url, + setup_intent, + shipping_address_collection, + shipping_cost, + shipping_details, + shipping_options, + status, + submit_type, + subscription, + success_url, + tax_id_collection, + total_details, + ui_mode, + url, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutSession { + type Builder = CheckoutSessionBuilder; + } + + impl FromValueOpt for CheckoutSession { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutSessionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "after_expiration" => b.after_expiration = Some(FromValueOpt::from_value(v)?), + "allow_promotion_codes" => b.allow_promotion_codes = Some(FromValueOpt::from_value(v)?), + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "billing_address_collection" => b.billing_address_collection = Some(FromValueOpt::from_value(v)?), + "cancel_url" => b.cancel_url = Some(FromValueOpt::from_value(v)?), + "client_reference_id" => b.client_reference_id = Some(FromValueOpt::from_value(v)?), + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "consent" => b.consent = Some(FromValueOpt::from_value(v)?), + "consent_collection" => b.consent_collection = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "currency_conversion" => b.currency_conversion = Some(FromValueOpt::from_value(v)?), + "custom_fields" => b.custom_fields = Some(FromValueOpt::from_value(v)?), + "custom_text" => b.custom_text = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "customer_creation" => b.customer_creation = Some(FromValueOpt::from_value(v)?), + "customer_details" => b.customer_details = Some(FromValueOpt::from_value(v)?), + "customer_email" => b.customer_email = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "invoice_creation" => b.invoice_creation = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "locale" => b.locale = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "mode" => b.mode = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "payment_link" => b.payment_link = Some(FromValueOpt::from_value(v)?), + "payment_method_collection" => b.payment_method_collection = Some(FromValueOpt::from_value(v)?), + "payment_method_configuration_details" => b.payment_method_configuration_details = Some(FromValueOpt::from_value(v)?), + "payment_method_options" => b.payment_method_options = Some(FromValueOpt::from_value(v)?), + "payment_method_types" => b.payment_method_types = Some(FromValueOpt::from_value(v)?), + "payment_status" => b.payment_status = Some(FromValueOpt::from_value(v)?), + "phone_number_collection" => b.phone_number_collection = Some(FromValueOpt::from_value(v)?), + "recovered_from" => b.recovered_from = Some(FromValueOpt::from_value(v)?), + "redirect_on_completion" => b.redirect_on_completion = Some(FromValueOpt::from_value(v)?), + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + "setup_intent" => b.setup_intent = Some(FromValueOpt::from_value(v)?), + "shipping_address_collection" => b.shipping_address_collection = Some(FromValueOpt::from_value(v)?), + "shipping_cost" => b.shipping_cost = Some(FromValueOpt::from_value(v)?), + "shipping_details" => b.shipping_details = Some(FromValueOpt::from_value(v)?), + "shipping_options" => b.shipping_options = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "submit_type" => b.submit_type = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + "success_url" => b.success_url = Some(FromValueOpt::from_value(v)?), + "tax_id_collection" => b.tax_id_collection = Some(FromValueOpt::from_value(v)?), + "total_details" => b.total_details = Some(FromValueOpt::from_value(v)?), + "ui_mode" => b.ui_mode = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Configure whether a Checkout Session creates a Customer when the Checkout Session completes. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionCustomerCreation { @@ -205,11 +601,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionCustomerCreation { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for CheckoutSessionCustomerCreation") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionCustomerCreation")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionCustomerCreation { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionCustomerCreation> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionCustomerCreation::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionCustomerCreation); /// Configure whether a Checkout Session should collect a payment method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionPaymentMethodCollection { @@ -260,11 +672,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentMethodCollection { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for CheckoutSessionPaymentMethodCollection") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionPaymentMethodCollection")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionPaymentMethodCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionPaymentMethodCollection> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionPaymentMethodCollection::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentMethodCollection); /// The payment status of the Checkout Session, one of `paid`, `unpaid`, or `no_payment_required`. /// You can use this value to decide when to fulfill your customer's order. #[derive(Copy, Clone, Eq, PartialEq)] @@ -319,10 +747,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionPaymentStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionPaymentStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionPaymentStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionPaymentStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionPaymentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentStatus); impl stripe_types::Object for CheckoutSession { type Id = stripe_checkout::CheckoutSessionId; fn id(&self) -> &Self::Id { @@ -379,11 +824,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionBillingAddressCollection { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for CheckoutSessionBillingAddressCollection") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionBillingAddressCollection")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionBillingAddressCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionBillingAddressCollection> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionBillingAddressCollection::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionBillingAddressCollection); #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum CheckoutSessionLocale { @@ -554,9 +1015,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionLocale { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(CheckoutSessionLocale::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionLocale { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionLocale> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionLocale::from_str(s).unwrap_or(CheckoutSessionLocale::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionLocale); #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionMode { Payment, @@ -609,10 +1088,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionMode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionMode")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionMode")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionMode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionMode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionMode); #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionRedirectOnCompletion { Always, @@ -665,11 +1161,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionRedirectOnCompletion { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for CheckoutSessionRedirectOnCompletion") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionRedirectOnCompletion")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionRedirectOnCompletion { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionRedirectOnCompletion> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionRedirectOnCompletion::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionRedirectOnCompletion); #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionStatus { Complete, @@ -722,10 +1234,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionStatus); #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionSubmitType { Auto, @@ -781,10 +1310,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionSubmitType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionSubmitType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionSubmitType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionSubmitType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionSubmitType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionSubmitType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionSubmitType); #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionUiMode { Embedded, @@ -834,7 +1380,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionUiMode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionUiMode")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionUiMode")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSessionUiMode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSessionUiMode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionUiMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSessionUiMode); diff --git a/generated/stripe_checkout/src/checkout_session_payment_method_options.rs b/generated/stripe_checkout/src/checkout_session_payment_method_options.rs index 60296debe..73a90874c 100644 --- a/generated/stripe_checkout/src/checkout_session_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_session_payment_method_options.rs @@ -1,61 +1,285 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutSessionPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_checkout::CheckoutAcssDebitPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option<stripe_checkout::CheckoutAffirmPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option<stripe_checkout::CheckoutAfterpayClearpayPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option<stripe_checkout::CheckoutAlipayPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_checkout::CheckoutAuBecsDebitPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_checkout::CheckoutBacsDebitPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option<stripe_checkout::CheckoutBancontactPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<stripe_checkout::CheckoutBoletoPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_checkout::CheckoutCardPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option<stripe_checkout::CheckoutCashappPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option<stripe_checkout::CheckoutCustomerBalancePaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option<stripe_checkout::CheckoutEpsPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option<stripe_checkout::CheckoutFpxPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option<stripe_checkout::CheckoutGiropayPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option<stripe_checkout::CheckoutGrabPayPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option<stripe_checkout::CheckoutIdealPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option<stripe_checkout::CheckoutKlarnaPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option<stripe_checkout::CheckoutKonbiniPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_checkout::CheckoutLinkPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo: Option<stripe_checkout::CheckoutOxxoPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option<stripe_checkout::CheckoutP24PaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option<stripe_checkout::CheckoutPaynowPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_checkout::CheckoutPaypalPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option<stripe_checkout::CheckoutPixPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option<stripe_checkout::CheckoutRevolutPayPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_checkout::CheckoutSepaDebitPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<stripe_checkout::CheckoutSofortPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<stripe_checkout::CheckoutSwishPaymentMethodOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_checkout::CheckoutUsBankAccountPaymentMethodOptions>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutSessionPaymentMethodOptionsBuilder { + acss_debit: Option<Option<stripe_checkout::CheckoutAcssDebitPaymentMethodOptions>>, + affirm: Option<Option<stripe_checkout::CheckoutAffirmPaymentMethodOptions>>, + afterpay_clearpay: Option<Option<stripe_checkout::CheckoutAfterpayClearpayPaymentMethodOptions>>, + alipay: Option<Option<stripe_checkout::CheckoutAlipayPaymentMethodOptions>>, + au_becs_debit: Option<Option<stripe_checkout::CheckoutAuBecsDebitPaymentMethodOptions>>, + bacs_debit: Option<Option<stripe_checkout::CheckoutBacsDebitPaymentMethodOptions>>, + bancontact: Option<Option<stripe_checkout::CheckoutBancontactPaymentMethodOptions>>, + boleto: Option<Option<stripe_checkout::CheckoutBoletoPaymentMethodOptions>>, + card: Option<Option<stripe_checkout::CheckoutCardPaymentMethodOptions>>, + cashapp: Option<Option<stripe_checkout::CheckoutCashappPaymentMethodOptions>>, + customer_balance: Option<Option<stripe_checkout::CheckoutCustomerBalancePaymentMethodOptions>>, + eps: Option<Option<stripe_checkout::CheckoutEpsPaymentMethodOptions>>, + fpx: Option<Option<stripe_checkout::CheckoutFpxPaymentMethodOptions>>, + giropay: Option<Option<stripe_checkout::CheckoutGiropayPaymentMethodOptions>>, + grabpay: Option<Option<stripe_checkout::CheckoutGrabPayPaymentMethodOptions>>, + ideal: Option<Option<stripe_checkout::CheckoutIdealPaymentMethodOptions>>, + klarna: Option<Option<stripe_checkout::CheckoutKlarnaPaymentMethodOptions>>, + konbini: Option<Option<stripe_checkout::CheckoutKonbiniPaymentMethodOptions>>, + link: Option<Option<stripe_checkout::CheckoutLinkPaymentMethodOptions>>, + oxxo: Option<Option<stripe_checkout::CheckoutOxxoPaymentMethodOptions>>, + p24: Option<Option<stripe_checkout::CheckoutP24PaymentMethodOptions>>, + paynow: Option<Option<stripe_checkout::CheckoutPaynowPaymentMethodOptions>>, + paypal: Option<Option<stripe_checkout::CheckoutPaypalPaymentMethodOptions>>, + pix: Option<Option<stripe_checkout::CheckoutPixPaymentMethodOptions>>, + revolut_pay: Option<Option<stripe_checkout::CheckoutRevolutPayPaymentMethodOptions>>, + sepa_debit: Option<Option<stripe_checkout::CheckoutSepaDebitPaymentMethodOptions>>, + sofort: Option<Option<stripe_checkout::CheckoutSofortPaymentMethodOptions>>, + us_bank_account: Option<Option<stripe_checkout::CheckoutUsBankAccountPaymentMethodOptions>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutSessionPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutSessionPaymentMethodOptions>, + builder: CheckoutSessionPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutSessionPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutSessionPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutSessionPaymentMethodOptionsBuilder { + type Out = CheckoutSessionPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "affirm" => Deserialize::begin(&mut self.affirm), + "afterpay_clearpay" => Deserialize::begin(&mut self.afterpay_clearpay), + "alipay" => Deserialize::begin(&mut self.alipay), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "boleto" => Deserialize::begin(&mut self.boleto), + "card" => Deserialize::begin(&mut self.card), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "customer_balance" => Deserialize::begin(&mut self.customer_balance), + "eps" => Deserialize::begin(&mut self.eps), + "fpx" => Deserialize::begin(&mut self.fpx), + "giropay" => Deserialize::begin(&mut self.giropay), + "grabpay" => Deserialize::begin(&mut self.grabpay), + "ideal" => Deserialize::begin(&mut self.ideal), + "klarna" => Deserialize::begin(&mut self.klarna), + "konbini" => Deserialize::begin(&mut self.konbini), + "link" => Deserialize::begin(&mut self.link), + "oxxo" => Deserialize::begin(&mut self.oxxo), + "p24" => Deserialize::begin(&mut self.p24), + "paynow" => Deserialize::begin(&mut self.paynow), + "paypal" => Deserialize::begin(&mut self.paypal), + "pix" => Deserialize::begin(&mut self.pix), + "revolut_pay" => Deserialize::begin(&mut self.revolut_pay), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "sofort" => Deserialize::begin(&mut self.sofort), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + affirm: Deserialize::default(), + afterpay_clearpay: Deserialize::default(), + alipay: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bacs_debit: Deserialize::default(), + bancontact: Deserialize::default(), + boleto: Deserialize::default(), + card: Deserialize::default(), + cashapp: Deserialize::default(), + customer_balance: Deserialize::default(), + eps: Deserialize::default(), + fpx: Deserialize::default(), + giropay: Deserialize::default(), + grabpay: Deserialize::default(), + ideal: Deserialize::default(), + klarna: Deserialize::default(), + konbini: Deserialize::default(), + link: Deserialize::default(), + oxxo: Deserialize::default(), + p24: Deserialize::default(), + paynow: Deserialize::default(), + paypal: Deserialize::default(), + pix: Deserialize::default(), + revolut_pay: Deserialize::default(), + sepa_debit: Deserialize::default(), + sofort: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let affirm = self.affirm.take()?; + let afterpay_clearpay = self.afterpay_clearpay.take()?; + let alipay = self.alipay.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bacs_debit = self.bacs_debit.take()?; + let bancontact = self.bancontact.take()?; + let boleto = self.boleto.take()?; + let card = self.card.take()?; + let cashapp = self.cashapp.take()?; + let customer_balance = self.customer_balance.take()?; + let eps = self.eps.take()?; + let fpx = self.fpx.take()?; + let giropay = self.giropay.take()?; + let grabpay = self.grabpay.take()?; + let ideal = self.ideal.take()?; + let klarna = self.klarna.take()?; + let konbini = self.konbini.take()?; + let link = self.link.take()?; + let oxxo = self.oxxo.take()?; + let p24 = self.p24.take()?; + let paynow = self.paynow.take()?; + let paypal = self.paypal.take()?; + let pix = self.pix.take()?; + let revolut_pay = self.revolut_pay.take()?; + let sepa_debit = self.sepa_debit.take()?; + let sofort = self.sofort.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { + acss_debit, + affirm, + afterpay_clearpay, + alipay, + au_becs_debit, + bacs_debit, + bancontact, + boleto, + card, + cashapp, + customer_balance, + eps, + fpx, + giropay, + grabpay, + ideal, + klarna, + konbini, + link, + oxxo, + p24, + paynow, + paypal, + pix, + revolut_pay, + sepa_debit, + sofort, + us_bank_account, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutSessionPaymentMethodOptions { + type Builder = CheckoutSessionPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutSessionPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutSessionPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "affirm" => b.affirm = Some(FromValueOpt::from_value(v)?), + "afterpay_clearpay" => b.afterpay_clearpay = Some(FromValueOpt::from_value(v)?), + "alipay" => b.alipay = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "boleto" => b.boleto = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "customer_balance" => b.customer_balance = Some(FromValueOpt::from_value(v)?), + "eps" => b.eps = Some(FromValueOpt::from_value(v)?), + "fpx" => b.fpx = Some(FromValueOpt::from_value(v)?), + "giropay" => b.giropay = Some(FromValueOpt::from_value(v)?), + "grabpay" => b.grabpay = Some(FromValueOpt::from_value(v)?), + "ideal" => b.ideal = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "konbini" => b.konbini = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "oxxo" => b.oxxo = Some(FromValueOpt::from_value(v)?), + "p24" => b.p24 = Some(FromValueOpt::from_value(v)?), + "paynow" => b.paynow = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "pix" => b.pix = Some(FromValueOpt::from_value(v)?), + "revolut_pay" => b.revolut_pay = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/checkout_sofort_payment_method_options.rs b/generated/stripe_checkout/src/checkout_sofort_payment_method_options.rs index c8a6453f7..e49581d76 100644 --- a/generated/stripe_checkout/src/checkout_sofort_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_sofort_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutSofortPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct CheckoutSofortPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutSofortPaymentMethodOptionsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutSofortPaymentMethodOptionsBuilder { + setup_future_usage: Option<Option<CheckoutSofortPaymentMethodOptionsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutSofortPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutSofortPaymentMethodOptions>, + builder: CheckoutSofortPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutSofortPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutSofortPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutSofortPaymentMethodOptionsBuilder { + type Out = CheckoutSofortPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutSofortPaymentMethodOptions { + type Builder = CheckoutSofortPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutSofortPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutSofortPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutSofortPaymentMethodOptionsSetupFut fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutSofortPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSofortPaymentMethodOptionsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutSofortPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutSofortPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSofortPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutSofortPaymentMethodOptionsSetupFutureUsage); diff --git a/generated/stripe_checkout/src/checkout_swish_payment_method_options.rs b/generated/stripe_checkout/src/checkout_swish_payment_method_options.rs deleted file mode 100644 index 8e5b54650..000000000 --- a/generated/stripe_checkout/src/checkout_swish_payment_method_options.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct CheckoutSwishPaymentMethodOptions { - /// The order reference that will be displayed to customers in the Swish application. - /// Defaults to the `id` of the Payment Intent. - pub reference: Option<String>, -} diff --git a/generated/stripe_checkout/src/checkout_us_bank_account_payment_method_options.rs b/generated/stripe_checkout/src/checkout_us_bank_account_payment_method_options.rs index 8c7dec25b..013b95b1e 100644 --- a/generated/stripe_checkout/src/checkout_us_bank_account_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_us_bank_account_payment_method_options.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutUsBankAccountPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections: Option<stripe_shared::LinkedAccountOptionsUsBankAccount>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -8,12 +9,104 @@ pub struct CheckoutUsBankAccountPaymentMethodOptions { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option<CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutUsBankAccountPaymentMethodOptionsBuilder { + financial_connections: Option<Option<stripe_shared::LinkedAccountOptionsUsBankAccount>>, + setup_future_usage: Option<Option<CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage>>, + verification_method: Option<Option<CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutUsBankAccountPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutUsBankAccountPaymentMethodOptions>, + builder: CheckoutUsBankAccountPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<CheckoutUsBankAccountPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutUsBankAccountPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutUsBankAccountPaymentMethodOptionsBuilder { + type Out = CheckoutUsBankAccountPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "financial_connections" => Deserialize::begin(&mut self.financial_connections), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { financial_connections: Deserialize::default(), setup_future_usage: Deserialize::default(), verification_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let financial_connections = self.financial_connections.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { financial_connections, setup_future_usage, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutUsBankAccountPaymentMethodOptions { + type Builder = CheckoutUsBankAccountPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutUsBankAccountPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutUsBankAccountPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "financial_connections" => b.financial_connections = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -72,13 +165,27 @@ impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsS fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage); /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod { @@ -129,10 +236,24 @@ impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsV fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod); diff --git a/generated/stripe_checkout/src/mod.rs b/generated/stripe_checkout/src/mod.rs index 4c6859829..3620f9221 100644 --- a/generated/stripe_checkout/src/mod.rs +++ b/generated/stripe_checkout/src/mod.rs @@ -7,6 +7,9 @@ //! centered around [Checkout Sessions](https://stripe.com/docs/api/checkout/sessions). extern crate self as stripe_checkout; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub use checkout_session::types::*; #[doc(hidden)] pub mod checkout_acss_debit_mandate_options; @@ -134,10 +137,6 @@ pub mod checkout_sofort_payment_method_options; #[doc(inline)] pub use checkout_sofort_payment_method_options::*; #[doc(hidden)] -pub mod checkout_swish_payment_method_options; -#[doc(inline)] -pub use checkout_swish_payment_method_options::*; -#[doc(hidden)] pub mod checkout_us_bank_account_payment_method_options; #[doc(inline)] pub use checkout_us_bank_account_payment_method_options::*; @@ -210,10 +209,6 @@ pub mod payment_pages_checkout_session_invoice_settings; #[doc(inline)] pub use payment_pages_checkout_session_invoice_settings::*; #[doc(hidden)] -pub mod payment_pages_checkout_session_payment_method_reuse_agreement; -#[doc(inline)] -pub use payment_pages_checkout_session_payment_method_reuse_agreement::*; -#[doc(hidden)] pub mod payment_pages_checkout_session_phone_number_collection; #[doc(inline)] pub use payment_pages_checkout_session_phone_number_collection::*; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration.rs index 8556d7c03..348409247 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionAfterExpiration { /// When set, configuration used to recover the Checkout Session on expiry. pub recovery: Option<stripe_checkout::PaymentPagesCheckoutSessionAfterExpirationRecovery>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionAfterExpirationBuilder { + recovery: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionAfterExpirationRecovery>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionAfterExpiration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionAfterExpiration>, + builder: PaymentPagesCheckoutSessionAfterExpirationBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionAfterExpiration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionAfterExpirationBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionAfterExpirationBuilder { + type Out = PaymentPagesCheckoutSessionAfterExpiration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "recovery" => Deserialize::begin(&mut self.recovery), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { recovery: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let recovery = self.recovery.take()?; + + Some(Self::Out { recovery }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionAfterExpiration { + type Builder = PaymentPagesCheckoutSessionAfterExpirationBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionAfterExpiration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionAfterExpirationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "recovery" => b.recovery = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration_recovery.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration_recovery.rs index 383eac4a6..949e85970 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration_recovery.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_after_expiration_recovery.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionAfterExpirationRecovery { /// Enables user redeemable promotion codes on the recovered Checkout Sessions. Defaults to `false` pub allow_promotion_codes: bool, @@ -11,3 +13,101 @@ pub struct PaymentPagesCheckoutSessionAfterExpirationRecovery { /// URL that creates a new Checkout Session when clicked that is a copy of this expired Checkout Session. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder { + allow_promotion_codes: Option<bool>, + enabled: Option<bool>, + expires_at: Option<Option<stripe_types::Timestamp>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionAfterExpirationRecovery { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionAfterExpirationRecovery>, + builder: PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionAfterExpirationRecovery> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder { + type Out = PaymentPagesCheckoutSessionAfterExpirationRecovery; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allow_promotion_codes" => Deserialize::begin(&mut self.allow_promotion_codes), + "enabled" => Deserialize::begin(&mut self.enabled), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allow_promotion_codes: Deserialize::default(), enabled: Deserialize::default(), expires_at: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allow_promotion_codes = self.allow_promotion_codes.take()?; + let enabled = self.enabled.take()?; + let expires_at = self.expires_at.take()?; + let url = self.url.take()?; + + Some(Self::Out { allow_promotion_codes, enabled, expires_at, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionAfterExpirationRecovery { + type Builder = PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionAfterExpirationRecovery { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allow_promotion_codes" => b.allow_promotion_codes = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_automatic_tax.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_automatic_tax.rs index ca13dfeb7..c8420f6e1 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_automatic_tax.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_automatic_tax.rs @@ -1,14 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionAutomaticTax { /// Indicates whether automatic tax is enabled for the session pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - pub liability: Option<stripe_shared::ConnectAccountReference>, /// The status of the most recent automated tax calculation for this session. pub status: Option<PaymentPagesCheckoutSessionAutomaticTaxStatus>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionAutomaticTaxBuilder { + enabled: Option<bool>, + status: Option<Option<PaymentPagesCheckoutSessionAutomaticTaxStatus>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionAutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionAutomaticTax>, + builder: PaymentPagesCheckoutSessionAutomaticTaxBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionAutomaticTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionAutomaticTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionAutomaticTaxBuilder { + type Out = PaymentPagesCheckoutSessionAutomaticTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + let status = self.status.take()?; + + Some(Self::Out { enabled, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionAutomaticTax { + type Builder = PaymentPagesCheckoutSessionAutomaticTaxBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionAutomaticTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionAutomaticTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the most recent automated tax calculation for this session. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentPagesCheckoutSessionAutomaticTaxStatus { @@ -62,10 +150,24 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionAutomaticTaxSta fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionAutomaticTaxStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionAutomaticTaxStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionAutomaticTaxStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionAutomaticTaxStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionAutomaticTaxStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionAutomaticTaxStatus); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_consent.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_consent.rs index 2f784f268..cad91e3ec 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_consent.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_consent.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionConsent { /// If `opt_in`, the customer consents to receiving promotional communications /// from the merchant about this Checkout Session. @@ -6,6 +8,96 @@ pub struct PaymentPagesCheckoutSessionConsent { /// If `accepted`, the customer in this Checkout Session has agreed to the merchant's terms of service. pub terms_of_service: Option<PaymentPagesCheckoutSessionConsentTermsOfService>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionConsentBuilder { + promotions: Option<Option<PaymentPagesCheckoutSessionConsentPromotions>>, + terms_of_service: Option<Option<PaymentPagesCheckoutSessionConsentTermsOfService>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionConsent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionConsent>, + builder: PaymentPagesCheckoutSessionConsentBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionConsent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionConsentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionConsentBuilder { + type Out = PaymentPagesCheckoutSessionConsent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "promotions" => Deserialize::begin(&mut self.promotions), + "terms_of_service" => Deserialize::begin(&mut self.terms_of_service), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { promotions: Deserialize::default(), terms_of_service: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let promotions = self.promotions.take()?; + let terms_of_service = self.terms_of_service.take()?; + + Some(Self::Out { promotions, terms_of_service }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionConsent { + type Builder = PaymentPagesCheckoutSessionConsentBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionConsent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionConsentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "promotions" => b.promotions = Some(FromValueOpt::from_value(v)?), + "terms_of_service" => b.terms_of_service = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// If `opt_in`, the customer consents to receiving promotional communications /// from the merchant about this Checkout Session. #[derive(Copy, Clone, Eq, PartialEq)] @@ -57,13 +149,27 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentPromotio fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionConsentPromotions", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionConsentPromotions")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentPromotions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionConsentPromotions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionConsentPromotions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionConsentPromotions); /// If `accepted`, the customer in this Checkout Session has agreed to the merchant's terms of service. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentPagesCheckoutSessionConsentTermsOfService { @@ -111,10 +217,24 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentTermsOfS fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionConsentTermsOfService", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionConsentTermsOfService")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentTermsOfService { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionConsentTermsOfService> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionConsentTermsOfService::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionConsentTermsOfService); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_consent_collection.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_consent_collection.rs index 74b3cb0ff..3baab89a5 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_consent_collection.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_consent_collection.rs @@ -1,8 +1,7 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionConsentCollection { - /// If set to `hidden`, it will hide legal text related to the reuse of a payment method. - pub payment_method_reuse_agreement: - Option<stripe_checkout::PaymentPagesCheckoutSessionPaymentMethodReuseAgreement>, /// If set to `auto`, enables the collection of customer consent for promotional communications. /// The Checkout. /// Session will determine whether to display an option to opt into promotional communication @@ -11,6 +10,96 @@ pub struct PaymentPagesCheckoutSessionConsentCollection { /// If set to `required`, it requires customers to accept the terms of service before being able to pay. pub terms_of_service: Option<PaymentPagesCheckoutSessionConsentCollectionTermsOfService>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionConsentCollectionBuilder { + promotions: Option<Option<PaymentPagesCheckoutSessionConsentCollectionPromotions>>, + terms_of_service: Option<Option<PaymentPagesCheckoutSessionConsentCollectionTermsOfService>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionConsentCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionConsentCollection>, + builder: PaymentPagesCheckoutSessionConsentCollectionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionConsentCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionConsentCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionConsentCollectionBuilder { + type Out = PaymentPagesCheckoutSessionConsentCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "promotions" => Deserialize::begin(&mut self.promotions), + "terms_of_service" => Deserialize::begin(&mut self.terms_of_service), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { promotions: Deserialize::default(), terms_of_service: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let promotions = self.promotions.take()?; + let terms_of_service = self.terms_of_service.take()?; + + Some(Self::Out { promotions, terms_of_service }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionConsentCollection { + type Builder = PaymentPagesCheckoutSessionConsentCollectionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionConsentCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionConsentCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "promotions" => b.promotions = Some(FromValueOpt::from_value(v)?), + "terms_of_service" => b.terms_of_service = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// If set to `auto`, enables the collection of customer consent for promotional communications. /// The Checkout. /// Session will determine whether to display an option to opt into promotional communication @@ -64,13 +153,27 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentCollecti fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionConsentCollectionPromotions", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionConsentCollectionPromotions")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentCollectionPromotions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionConsentCollectionPromotions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionConsentCollectionPromotions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionConsentCollectionPromotions); /// If set to `required`, it requires customers to accept the terms of service before being able to pay. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentPagesCheckoutSessionConsentCollectionTermsOfService { @@ -121,10 +224,24 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentCollecti fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionConsentCollectionTermsOfService", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionConsentCollectionTermsOfService")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentCollectionTermsOfService { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionConsentCollectionTermsOfService> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionConsentCollectionTermsOfService::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionConsentCollectionTermsOfService); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_currency_conversion.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_currency_conversion.rs index 9e2c3fee0..7debfbfdf 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_currency_conversion.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_currency_conversion.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCurrencyConversion { /// Total of all items in source currency before discounts or taxes are applied. pub amount_subtotal: i64, @@ -9,3 +11,101 @@ pub struct PaymentPagesCheckoutSessionCurrencyConversion { /// Creation currency of the CheckoutSession before localization pub source_currency: stripe_types::Currency, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCurrencyConversionBuilder { + amount_subtotal: Option<i64>, + amount_total: Option<i64>, + fx_rate: Option<String>, + source_currency: Option<stripe_types::Currency>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCurrencyConversion { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCurrencyConversion>, + builder: PaymentPagesCheckoutSessionCurrencyConversionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCurrencyConversion> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCurrencyConversionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCurrencyConversionBuilder { + type Out = PaymentPagesCheckoutSessionCurrencyConversion; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "fx_rate" => Deserialize::begin(&mut self.fx_rate), + "source_currency" => Deserialize::begin(&mut self.source_currency), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_subtotal: Deserialize::default(), amount_total: Deserialize::default(), fx_rate: Deserialize::default(), source_currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_subtotal = self.amount_subtotal.take()?; + let amount_total = self.amount_total.take()?; + let fx_rate = self.fx_rate.take()?; + let source_currency = self.source_currency.take()?; + + Some(Self::Out { amount_subtotal, amount_total, fx_rate, source_currency }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCurrencyConversion { + type Builder = PaymentPagesCheckoutSessionCurrencyConversionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCurrencyConversion { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCurrencyConversionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "fx_rate" => b.fx_rate = Some(FromValueOpt::from_value(v)?), + "source_currency" => b.source_currency = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields.rs index c801270df..76044fdb0 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields.rs @@ -1,22 +1,139 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomFields { - #[serde(skip_serializing_if = "Option::is_none")] pub dropdown: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsDropdown>, /// String of your choice that your integration can use to reconcile this field. /// Must be unique to this field, alphanumeric, and up to 200 characters. pub key: String, pub label: stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsLabel, - #[serde(skip_serializing_if = "Option::is_none")] pub numeric: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsNumeric>, /// Whether the customer is required to complete the field before completing the Checkout Session. /// Defaults to `false`. pub optional: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub text: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsText>, /// The type of the field. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentPagesCheckoutSessionCustomFieldsType, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomFieldsBuilder { + dropdown: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsDropdown>>, + key: Option<String>, + label: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsLabel>, + numeric: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsNumeric>>, + optional: Option<bool>, + text: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsText>>, + type_: Option<PaymentPagesCheckoutSessionCustomFieldsType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomFields { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomFields>, + builder: PaymentPagesCheckoutSessionCustomFieldsBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomFields> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomFieldsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomFieldsBuilder { + type Out = PaymentPagesCheckoutSessionCustomFields; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "dropdown" => Deserialize::begin(&mut self.dropdown), + "key" => Deserialize::begin(&mut self.key), + "label" => Deserialize::begin(&mut self.label), + "numeric" => Deserialize::begin(&mut self.numeric), + "optional" => Deserialize::begin(&mut self.optional), + "text" => Deserialize::begin(&mut self.text), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + dropdown: Deserialize::default(), + key: Deserialize::default(), + label: Deserialize::default(), + numeric: Deserialize::default(), + optional: Deserialize::default(), + text: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let dropdown = self.dropdown.take()?; + let key = self.key.take()?; + let label = self.label.take()?; + let numeric = self.numeric.take()?; + let optional = self.optional.take()?; + let text = self.text.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { dropdown, key, label, numeric, optional, text, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomFields { + type Builder = PaymentPagesCheckoutSessionCustomFieldsBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomFields { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomFieldsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "dropdown" => b.dropdown = Some(FromValueOpt::from_value(v)?), + "key" => b.key = Some(FromValueOpt::from_value(v)?), + "label" => b.label = Some(FromValueOpt::from_value(v)?), + "numeric" => b.numeric = Some(FromValueOpt::from_value(v)?), + "optional" => b.optional = Some(FromValueOpt::from_value(v)?), + "text" => b.text = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the field. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentPagesCheckoutSessionCustomFieldsType { @@ -70,10 +187,24 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionCustomFieldsTyp fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionCustomFieldsType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionCustomFieldsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionCustomFieldsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionCustomFieldsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionCustomFieldsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionCustomFieldsType); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_dropdown.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_dropdown.rs index 696c54d6a..7d8438deb 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_dropdown.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_dropdown.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsDropdown { /// The options available for the customer to select. Up to 200 options allowed. pub options: Vec<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsOption>, /// The option selected by the customer. This will be the `value` for the option. pub value: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder { + options: Option<Vec<stripe_checkout::PaymentPagesCheckoutSessionCustomFieldsOption>>, + value: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomFieldsDropdown { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomFieldsDropdown>, + builder: PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomFieldsDropdown> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder { + type Out = PaymentPagesCheckoutSessionCustomFieldsDropdown; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "options" => Deserialize::begin(&mut self.options), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { options: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let options = self.options.take()?; + let value = self.value.take()?; + + Some(Self::Out { options, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomFieldsDropdown { + type Builder = PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomFieldsDropdown { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "options" => b.options = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_label.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_label.rs index 0b1f20bf6..36fcd457d 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_label.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_label.rs @@ -1,11 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsLabel { /// Custom text for the label, displayed to the customer. Up to 50 characters. pub custom: Option<String>, /// The type of the label. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentPagesCheckoutSessionCustomFieldsLabelType, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomFieldsLabelBuilder { + custom: Option<Option<String>>, + type_: Option<PaymentPagesCheckoutSessionCustomFieldsLabelType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomFieldsLabel { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomFieldsLabel>, + builder: PaymentPagesCheckoutSessionCustomFieldsLabelBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomFieldsLabel> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomFieldsLabelBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomFieldsLabelBuilder { + type Out = PaymentPagesCheckoutSessionCustomFieldsLabel; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom" => Deserialize::begin(&mut self.custom), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom = self.custom.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { custom, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomFieldsLabel { + type Builder = PaymentPagesCheckoutSessionCustomFieldsLabelBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomFieldsLabel { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomFieldsLabelBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom" => b.custom = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the label. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentPagesCheckoutSessionCustomFieldsLabelType { @@ -53,10 +145,24 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionCustomFieldsLab fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionCustomFieldsLabelType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionCustomFieldsLabelType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionCustomFieldsLabelType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionCustomFieldsLabelType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionCustomFieldsLabelType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionCustomFieldsLabelType); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_numeric.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_numeric.rs index 74e41bf6e..fb5a5e69b 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_numeric.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_numeric.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsNumeric { /// The maximum character length constraint for the customer's input. pub maximum_length: Option<i64>, @@ -7,3 +9,97 @@ pub struct PaymentPagesCheckoutSessionCustomFieldsNumeric { /// The value entered by the customer, containing only digits. pub value: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomFieldsNumericBuilder { + maximum_length: Option<Option<i64>>, + minimum_length: Option<Option<i64>>, + value: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomFieldsNumeric { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomFieldsNumeric>, + builder: PaymentPagesCheckoutSessionCustomFieldsNumericBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomFieldsNumeric> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomFieldsNumericBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomFieldsNumericBuilder { + type Out = PaymentPagesCheckoutSessionCustomFieldsNumeric; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "maximum_length" => Deserialize::begin(&mut self.maximum_length), + "minimum_length" => Deserialize::begin(&mut self.minimum_length), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum_length: Deserialize::default(), minimum_length: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let maximum_length = self.maximum_length.take()?; + let minimum_length = self.minimum_length.take()?; + let value = self.value.take()?; + + Some(Self::Out { maximum_length, minimum_length, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomFieldsNumeric { + type Builder = PaymentPagesCheckoutSessionCustomFieldsNumericBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomFieldsNumeric { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomFieldsNumericBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "maximum_length" => b.maximum_length = Some(FromValueOpt::from_value(v)?), + "minimum_length" => b.minimum_length = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_option.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_option.rs index 86c9c3a0d..ff459b52a 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_option.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_option.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsOption { /// The label for the option, displayed to the customer. Up to 100 characters. pub label: String, @@ -6,3 +8,93 @@ pub struct PaymentPagesCheckoutSessionCustomFieldsOption { /// Must be unique to this option, alphanumeric, and up to 100 characters. pub value: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomFieldsOptionBuilder { + label: Option<String>, + value: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomFieldsOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomFieldsOption>, + builder: PaymentPagesCheckoutSessionCustomFieldsOptionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomFieldsOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomFieldsOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomFieldsOptionBuilder { + type Out = PaymentPagesCheckoutSessionCustomFieldsOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "label" => Deserialize::begin(&mut self.label), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { label: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let label = self.label.take()?; + let value = self.value.take()?; + + Some(Self::Out { label, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomFieldsOption { + type Builder = PaymentPagesCheckoutSessionCustomFieldsOptionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomFieldsOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomFieldsOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "label" => b.label = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_text.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_text.rs index 48f5a6e6c..311ba81ab 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_text.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_fields_text.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsText { /// The maximum character length constraint for the customer's input. pub maximum_length: Option<i64>, @@ -7,3 +9,97 @@ pub struct PaymentPagesCheckoutSessionCustomFieldsText { /// The value entered by the customer. pub value: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomFieldsTextBuilder { + maximum_length: Option<Option<i64>>, + minimum_length: Option<Option<i64>>, + value: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomFieldsText { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomFieldsText>, + builder: PaymentPagesCheckoutSessionCustomFieldsTextBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomFieldsText> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomFieldsTextBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomFieldsTextBuilder { + type Out = PaymentPagesCheckoutSessionCustomFieldsText; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "maximum_length" => Deserialize::begin(&mut self.maximum_length), + "minimum_length" => Deserialize::begin(&mut self.minimum_length), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum_length: Deserialize::default(), minimum_length: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let maximum_length = self.maximum_length.take()?; + let minimum_length = self.minimum_length.take()?; + let value = self.value.take()?; + + Some(Self::Out { maximum_length, minimum_length, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomFieldsText { + type Builder = PaymentPagesCheckoutSessionCustomFieldsTextBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomFieldsText { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomFieldsTextBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "maximum_length" => b.maximum_length = Some(FromValueOpt::from_value(v)?), + "minimum_length" => b.minimum_length = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text.rs index 7f0ccbfe8..e8e8f4868 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text.rs @@ -1,12 +1,105 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomText { - /// Custom text that should be displayed after the payment confirmation button. - pub after_submit: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>, /// Custom text that should be displayed alongside shipping address collection. pub shipping_address: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>, /// Custom text that should be displayed alongside the payment confirmation button. pub submit: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>, /// Custom text that should be displayed in place of the default terms of service agreement text. - pub terms_of_service_acceptance: - Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>, + pub terms_of_service_acceptance: Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomTextBuilder { + shipping_address: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>>, + submit: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>>, + terms_of_service_acceptance: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionCustomTextPosition>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomText { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomText>, + builder: PaymentPagesCheckoutSessionCustomTextBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomText> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomTextBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomTextBuilder { + type Out = PaymentPagesCheckoutSessionCustomText; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "shipping_address" => Deserialize::begin(&mut self.shipping_address), + "submit" => Deserialize::begin(&mut self.submit), + "terms_of_service_acceptance" => Deserialize::begin(&mut self.terms_of_service_acceptance), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { shipping_address: Deserialize::default(), submit: Deserialize::default(), terms_of_service_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let shipping_address = self.shipping_address.take()?; + let submit = self.submit.take()?; + let terms_of_service_acceptance = self.terms_of_service_acceptance.take()?; + + Some(Self::Out { shipping_address, submit, terms_of_service_acceptance }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomText { + type Builder = PaymentPagesCheckoutSessionCustomTextBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomText { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomTextBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "shipping_address" => b.shipping_address = Some(FromValueOpt::from_value(v)?), + "submit" => b.submit = Some(FromValueOpt::from_value(v)?), + "terms_of_service_acceptance" => b.terms_of_service_acceptance = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text_position.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text_position.rs index 513e59422..2d9a51d05 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text_position.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_custom_text_position.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomTextPosition { /// Text may be up to 1200 characters in length. pub message: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomTextPositionBuilder { + message: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomTextPosition { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomTextPosition>, + builder: PaymentPagesCheckoutSessionCustomTextPositionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomTextPosition> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomTextPositionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomTextPositionBuilder { + type Out = PaymentPagesCheckoutSessionCustomTextPosition; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "message" => Deserialize::begin(&mut self.message), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let message = self.message.take()?; + + Some(Self::Out { message }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomTextPosition { + type Builder = PaymentPagesCheckoutSessionCustomTextPositionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomTextPosition { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomTextPositionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "message" => b.message = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_customer_details.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_customer_details.rs index de0be4e3c..0319febe9 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_customer_details.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_customer_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionCustomerDetails { /// The customer's address after a completed Checkout Session. /// Note: This property is populated only for sessions on or after March 30, 2022. @@ -16,6 +18,119 @@ pub struct PaymentPagesCheckoutSessionCustomerDetails { /// The customer’s tax IDs after a completed Checkout Session. pub tax_ids: Option<Vec<stripe_checkout::PaymentPagesCheckoutSessionTaxId>>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionCustomerDetailsBuilder { + address: Option<Option<stripe_shared::Address>>, + email: Option<Option<String>>, + name: Option<Option<String>>, + phone: Option<Option<String>>, + tax_exempt: Option<Option<PaymentPagesCheckoutSessionCustomerDetailsTaxExempt>>, + tax_ids: Option<Option<Vec<stripe_checkout::PaymentPagesCheckoutSessionTaxId>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionCustomerDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionCustomerDetails>, + builder: PaymentPagesCheckoutSessionCustomerDetailsBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionCustomerDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionCustomerDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionCustomerDetailsBuilder { + type Out = PaymentPagesCheckoutSessionCustomerDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + "phone" => Deserialize::begin(&mut self.phone), + "tax_exempt" => Deserialize::begin(&mut self.tax_exempt), + "tax_ids" => Deserialize::begin(&mut self.tax_ids), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + email: Deserialize::default(), + name: Deserialize::default(), + phone: Deserialize::default(), + tax_exempt: Deserialize::default(), + tax_ids: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + let phone = self.phone.take()?; + let tax_exempt = self.tax_exempt.take()?; + let tax_ids = self.tax_ids.take()?; + + Some(Self::Out { address, email, name, phone, tax_exempt, tax_ids }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionCustomerDetails { + type Builder = PaymentPagesCheckoutSessionCustomerDetailsBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionCustomerDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomerDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + "tax_exempt" => b.tax_exempt = Some(FromValueOpt::from_value(v)?), + "tax_ids" => b.tax_ids = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer’s tax exempt status after a completed Checkout Session. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentPagesCheckoutSessionCustomerDetailsTaxExempt { @@ -69,10 +184,24 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionCustomerDetails fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionCustomerDetailsTaxExempt> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionCustomerDetailsTaxExempt::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionCustomerDetailsTaxExempt); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_creation.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_creation.rs index 4fe0bf5be..cc21cf3fc 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_creation.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_creation.rs @@ -1,6 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionInvoiceCreation { /// Indicates whether invoice creation is enabled for the Checkout Session. pub enabled: bool, pub invoice_data: stripe_checkout::PaymentPagesCheckoutSessionInvoiceSettings, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionInvoiceCreationBuilder { + enabled: Option<bool>, + invoice_data: Option<stripe_checkout::PaymentPagesCheckoutSessionInvoiceSettings>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionInvoiceCreation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionInvoiceCreation>, + builder: PaymentPagesCheckoutSessionInvoiceCreationBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionInvoiceCreation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionInvoiceCreationBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionInvoiceCreationBuilder { + type Out = PaymentPagesCheckoutSessionInvoiceCreation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "invoice_data" => Deserialize::begin(&mut self.invoice_data), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), invoice_data: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + let invoice_data = self.invoice_data.take()?; + + Some(Self::Out { enabled, invoice_data }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionInvoiceCreation { + type Builder = PaymentPagesCheckoutSessionInvoiceCreationBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionInvoiceCreation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionInvoiceCreationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "invoice_data" => b.invoice_data = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_settings.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_settings.rs index 677233882..85283951a 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_settings.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_invoice_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionInvoiceSettings { /// The account tax IDs associated with the invoice. pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>, @@ -8,12 +10,122 @@ pub struct PaymentPagesCheckoutSessionInvoiceSettings { pub description: Option<String>, /// Footer displayed on the invoice. pub footer: Option<String>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - pub issuer: Option<stripe_shared::ConnectAccountReference>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. pub metadata: Option<std::collections::HashMap<String, String>>, /// Options for invoice PDF rendering. pub rendering_options: Option<stripe_shared::InvoiceSettingRenderingOptions>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionInvoiceSettingsBuilder { + account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>, + custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>, + description: Option<Option<String>>, + footer: Option<Option<String>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + rendering_options: Option<Option<stripe_shared::InvoiceSettingRenderingOptions>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionInvoiceSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionInvoiceSettings>, + builder: PaymentPagesCheckoutSessionInvoiceSettingsBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionInvoiceSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionInvoiceSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionInvoiceSettingsBuilder { + type Out = PaymentPagesCheckoutSessionInvoiceSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids), + "custom_fields" => Deserialize::begin(&mut self.custom_fields), + "description" => Deserialize::begin(&mut self.description), + "footer" => Deserialize::begin(&mut self.footer), + "metadata" => Deserialize::begin(&mut self.metadata), + "rendering_options" => Deserialize::begin(&mut self.rendering_options), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_tax_ids: Deserialize::default(), + custom_fields: Deserialize::default(), + description: Deserialize::default(), + footer: Deserialize::default(), + metadata: Deserialize::default(), + rendering_options: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_tax_ids = self.account_tax_ids.take()?; + let custom_fields = self.custom_fields.take()?; + let description = self.description.take()?; + let footer = self.footer.take()?; + let metadata = self.metadata.take()?; + let rendering_options = self.rendering_options.take()?; + + Some(Self::Out { account_tax_ids, custom_fields, description, footer, metadata, rendering_options }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionInvoiceSettings { + type Builder = PaymentPagesCheckoutSessionInvoiceSettingsBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionInvoiceSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionInvoiceSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_tax_ids" => b.account_tax_ids = Some(FromValueOpt::from_value(v)?), + "custom_fields" => b.custom_fields = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "footer" => b.footer = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "rendering_options" => b.rendering_options = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_payment_method_reuse_agreement.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_payment_method_reuse_agreement.rs deleted file mode 100644 index 67c8b855a..000000000 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_payment_method_reuse_agreement.rs +++ /dev/null @@ -1,70 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct PaymentPagesCheckoutSessionPaymentMethodReuseAgreement { - /// Determines the position and visibility of the payment method reuse agreement in the UI. - /// When set to `auto`, Stripe's defaults will be used. - /// - /// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. - pub position: PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition, -} -/// Determines the position and visibility of the payment method reuse agreement in the UI. -/// When set to `auto`, Stripe's defaults will be used. -/// -/// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { - Auto, - Hidden, -} -impl PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { - pub fn as_str(self) -> &'static str { - use PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition::*; - match self { - Auto => "auto", - Hidden => "hidden", - } - } -} - -impl std::str::FromStr for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition::*; - match s { - "auto" => Ok(Auto), - "hidden" => Ok(Hidden), - _ => Err(()), - } - } -} -impl std::fmt::Display for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> - for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition -{ - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition", - ) - }) - } -} diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_phone_number_collection.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_phone_number_collection.rs index 956b63542..6a2166647 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_phone_number_collection.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_phone_number_collection.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionPhoneNumberCollection { /// Indicates whether phone number collection is enabled for the session pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionPhoneNumberCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionPhoneNumberCollection>, + builder: PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionPhoneNumberCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder { + type Out = PaymentPagesCheckoutSessionPhoneNumberCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionPhoneNumberCollection { + type Builder = PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionPhoneNumberCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_address_collection.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_address_collection.rs index 29133a8ad..1e1ca022a 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_address_collection.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_address_collection.rs @@ -1,11 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionShippingAddressCollection { /// An array of two-letter ISO country codes representing which countries Checkout should provide as options for. /// shipping locations. /// Unsupported country codes: `AS, CX, CC, CU, HM, IR, KP, MH, FM, NF, MP, PW, SD, SY, UM, VI`. - pub allowed_countries: - Vec<PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries>, + pub allowed_countries: Vec<PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionShippingAddressCollectionBuilder { + allowed_countries: Option<Vec<PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionShippingAddressCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionShippingAddressCollection>, + builder: PaymentPagesCheckoutSessionShippingAddressCollectionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionShippingAddressCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionShippingAddressCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionShippingAddressCollectionBuilder { + type Out = PaymentPagesCheckoutSessionShippingAddressCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allowed_countries" => Deserialize::begin(&mut self.allowed_countries), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_countries: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allowed_countries = self.allowed_countries.take()?; + + Some(Self::Out { allowed_countries }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionShippingAddressCollection { + type Builder = PaymentPagesCheckoutSessionShippingAddressCollectionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionShippingAddressCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionShippingAddressCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allowed_countries" => b.allowed_countries = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// An array of two-letter ISO country codes representing which countries Checkout should provide as options for. /// shipping locations. /// Unsupported country codes: `AS, CX, CC, CU, HM, IR, KP, MH, FM, NF, MP, PW, SD, SY, UM, VI`. @@ -763,14 +850,28 @@ impl serde::Serialize for PaymentPagesCheckoutSessionShippingAddressCollectionAl serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries -{ +impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or( - PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries::Unknown, - )) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries::from_str(s).unwrap_or(PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_cost.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_cost.rs index 4ad97b8b7..a129399ac 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_cost.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_cost.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionShippingCost { /// Total shipping cost before any discounts or taxes are applied. pub amount_subtotal: i64, @@ -9,6 +11,113 @@ pub struct PaymentPagesCheckoutSessionShippingCost { /// The ID of the ShippingRate for this order. pub shipping_rate: Option<stripe_types::Expandable<stripe_shared::ShippingRate>>, /// The taxes applied to the shipping rate. - #[serde(skip_serializing_if = "Option::is_none")] pub taxes: Option<Vec<stripe_shared::LineItemsTaxAmount>>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionShippingCostBuilder { + amount_subtotal: Option<i64>, + amount_tax: Option<i64>, + amount_total: Option<i64>, + shipping_rate: Option<Option<stripe_types::Expandable<stripe_shared::ShippingRate>>>, + taxes: Option<Option<Vec<stripe_shared::LineItemsTaxAmount>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionShippingCost { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionShippingCost>, + builder: PaymentPagesCheckoutSessionShippingCostBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionShippingCost> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionShippingCostBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionShippingCostBuilder { + type Out = PaymentPagesCheckoutSessionShippingCost; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "shipping_rate" => Deserialize::begin(&mut self.shipping_rate), + "taxes" => Deserialize::begin(&mut self.taxes), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_subtotal: Deserialize::default(), + amount_tax: Deserialize::default(), + amount_total: Deserialize::default(), + shipping_rate: Deserialize::default(), + taxes: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_subtotal = self.amount_subtotal.take()?; + let amount_tax = self.amount_tax.take()?; + let amount_total = self.amount_total.take()?; + let shipping_rate = self.shipping_rate.take()?; + let taxes = self.taxes.take()?; + + Some(Self::Out { amount_subtotal, amount_tax, amount_total, shipping_rate, taxes }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionShippingCost { + type Builder = PaymentPagesCheckoutSessionShippingCostBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionShippingCost { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionShippingCostBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "shipping_rate" => b.shipping_rate = Some(FromValueOpt::from_value(v)?), + "taxes" => b.taxes = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_option.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_option.rs index c7147247d..0dea28aca 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_option.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_shipping_option.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionShippingOption { /// A non-negative integer in cents representing how much to charge. pub shipping_amount: i64, /// The shipping rate. pub shipping_rate: stripe_types::Expandable<stripe_shared::ShippingRate>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionShippingOptionBuilder { + shipping_amount: Option<i64>, + shipping_rate: Option<stripe_types::Expandable<stripe_shared::ShippingRate>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionShippingOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionShippingOption>, + builder: PaymentPagesCheckoutSessionShippingOptionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionShippingOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionShippingOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionShippingOptionBuilder { + type Out = PaymentPagesCheckoutSessionShippingOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "shipping_amount" => Deserialize::begin(&mut self.shipping_amount), + "shipping_rate" => Deserialize::begin(&mut self.shipping_rate), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { shipping_amount: Deserialize::default(), shipping_rate: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let shipping_amount = self.shipping_amount.take()?; + let shipping_rate = self.shipping_rate.take()?; + + Some(Self::Out { shipping_amount, shipping_rate }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionShippingOption { + type Builder = PaymentPagesCheckoutSessionShippingOptionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionShippingOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionShippingOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "shipping_amount" => b.shipping_amount = Some(FromValueOpt::from_value(v)?), + "shipping_rate" => b.shipping_rate = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id.rs index 9baf50795..8faf4ab87 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id.rs @@ -1,11 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionTaxId { /// The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentPagesCheckoutSessionTaxIdType, /// The value of the tax ID. pub value: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionTaxIdBuilder { + type_: Option<PaymentPagesCheckoutSessionTaxIdType>, + value: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionTaxId { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionTaxId>, + builder: PaymentPagesCheckoutSessionTaxIdBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionTaxId> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionTaxIdBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionTaxIdBuilder { + type Out = PaymentPagesCheckoutSessionTaxId; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "type" => Deserialize::begin(&mut self.type_), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let type_ = self.type_.take()?; + let value = self.value.take()?; + + Some(Self::Out { type_, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionTaxId { + type Builder = PaymentPagesCheckoutSessionTaxIdBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionTaxId { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionTaxIdBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentPagesCheckoutSessionTaxIdType { @@ -251,8 +343,24 @@ impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionTaxIdType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionTaxIdType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentPagesCheckoutSessionTaxIdType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentPagesCheckoutSessionTaxIdType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentPagesCheckoutSessionTaxIdType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentPagesCheckoutSessionTaxIdType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionTaxIdType); diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id_collection.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id_collection.rs index 8049e91fb..0397e285d 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id_collection.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_tax_id_collection.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionTaxIdCollection { /// Indicates whether tax ID collection is enabled for the session pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionTaxIdCollectionBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionTaxIdCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionTaxIdCollection>, + builder: PaymentPagesCheckoutSessionTaxIdCollectionBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionTaxIdCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionTaxIdCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionTaxIdCollectionBuilder { + type Out = PaymentPagesCheckoutSessionTaxIdCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionTaxIdCollection { + type Builder = PaymentPagesCheckoutSessionTaxIdCollectionBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionTaxIdCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionTaxIdCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_total_details.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_total_details.rs index 14888f396..b3c5f7d08 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_total_details.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_total_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionTotalDetails { /// This is the sum of all the discounts. pub amount_discount: i64, @@ -6,7 +8,103 @@ pub struct PaymentPagesCheckoutSessionTotalDetails { pub amount_shipping: Option<i64>, /// This is the sum of all the tax amounts. pub amount_tax: i64, - #[serde(skip_serializing_if = "Option::is_none")] - pub breakdown: - Option<stripe_checkout::PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown>, + pub breakdown: Option<stripe_checkout::PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionTotalDetailsBuilder { + amount_discount: Option<i64>, + amount_shipping: Option<Option<i64>>, + amount_tax: Option<i64>, + breakdown: Option<Option<stripe_checkout::PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionTotalDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionTotalDetails>, + builder: PaymentPagesCheckoutSessionTotalDetailsBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionTotalDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionTotalDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionTotalDetailsBuilder { + type Out = PaymentPagesCheckoutSessionTotalDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_discount" => Deserialize::begin(&mut self.amount_discount), + "amount_shipping" => Deserialize::begin(&mut self.amount_shipping), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "breakdown" => Deserialize::begin(&mut self.breakdown), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_discount: Deserialize::default(), amount_shipping: Deserialize::default(), amount_tax: Deserialize::default(), breakdown: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_discount = self.amount_discount.take()?; + let amount_shipping = self.amount_shipping.take()?; + let amount_tax = self.amount_tax.take()?; + let breakdown = self.breakdown.take()?; + + Some(Self::Out { amount_discount, amount_shipping, amount_tax, breakdown }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionTotalDetails { + type Builder = PaymentPagesCheckoutSessionTotalDetailsBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionTotalDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionTotalDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_discount" => b.amount_discount = Some(FromValueOpt::from_value(v)?), + "amount_shipping" => b.amount_shipping = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "breakdown" => b.breakdown = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_checkout/src/payment_pages_checkout_session_total_details_resource_breakdown.rs b/generated/stripe_checkout/src/payment_pages_checkout_session_total_details_resource_breakdown.rs index ff1083411..24e5118dc 100644 --- a/generated/stripe_checkout/src/payment_pages_checkout_session_total_details_resource_breakdown.rs +++ b/generated/stripe_checkout/src/payment_pages_checkout_session_total_details_resource_breakdown.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown { /// The aggregated discounts. pub discounts: Vec<stripe_shared::LineItemsDiscountAmount>, /// The aggregated tax amounts by rate. pub taxes: Vec<stripe_shared::LineItemsTaxAmount>, } +#[cfg(feature = "min-ser")] +pub struct PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder { + discounts: Option<Vec<stripe_shared::LineItemsDiscountAmount>>, + taxes: Option<Vec<stripe_shared::LineItemsTaxAmount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown>, + builder: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder, + } + + impl Visitor for Place<PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder { + type Out = PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "discounts" => Deserialize::begin(&mut self.discounts), + "taxes" => Deserialize::begin(&mut self.taxes), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { discounts: Deserialize::default(), taxes: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let discounts = self.discounts.take()?; + let taxes = self.taxes.take()?; + + Some(Self::Out { discounts, taxes }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown { + type Builder = PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "taxes" => b.taxes = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/.rustfmt.toml b/generated/stripe_connect/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_connect/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_connect/Cargo.toml b/generated/stripe_connect/Cargo.toml index 095e49cd5..4b6e62af7 100644 --- a/generated/stripe_connect/Cargo.toml +++ b/generated/stripe_connect/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_connect/src/account/requests.rs b/generated/stripe_connect/src/account/requests.rs index 728713933..8209e5b0d 100644 --- a/generated/stripe_connect/src/account/requests.rs +++ b/generated/stripe_connect/src/account/requests.rs @@ -1,27 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteAccount {} -impl DeleteAccount { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteAccount { - /// With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. - /// - /// Accounts created using test-mode keys can be deleted at any time. - /// Standard accounts created using live-mode keys cannot be deleted. - /// Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. - /// - /// If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_shared::DeletedAccount> { - client.send_form(&format!("/accounts/{account}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveForMyAccountAccount<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -39,46 +16,6 @@ impl<'a> RetrieveForMyAccountAccount<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListAccount<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListAccount<'a> { - /// Returns a list of accounts connected to your platform via [Connect](https://stripe.com/docs/connect). - /// If you’re not a platform, the list is empty. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Account>> { - client.get_query("/accounts", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Account>> { - stripe::ListPaginator::from_list_params("/accounts", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveAccount<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -91,113 +28,12 @@ impl<'a> RetrieveAccount<'a> { } impl<'a> RetrieveAccount<'a> { /// Retrieves the details of an account. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_shared::Account> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_shared::Account> { client.get_query(&format!("/accounts/{account}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CapabilitiesAccount<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CapabilitiesAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CapabilitiesAccount<'a> { - /// Returns a list of capabilities associated with the account. - /// The capabilities are returned sorted by creation date, with the most recent capability appearing first. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_types::List<stripe_shared::Capability>> { - client.get_query(&format!("/accounts/{account}/capabilities"), self) - } - pub fn paginate( - self, - account: &stripe_shared::AccountId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Capability>> { - stripe::ListPaginator::from_list_params(&format!("/accounts/{account}/capabilities"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct PersonsAccount<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// Filters on the list of people returned based on the person's relationship to the account's company. - #[serde(skip_serializing_if = "Option::is_none")] - pub relationship: Option<PersonsAccountRelationship>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> PersonsAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Filters on the list of people returned based on the person's relationship to the account's company. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct PersonsAccountRelationship { - /// A filter on the list of people returned based on whether these people are directors of the account's company. - #[serde(skip_serializing_if = "Option::is_none")] - pub director: Option<bool>, - /// A filter on the list of people returned based on whether these people are executives of the account's company. - #[serde(skip_serializing_if = "Option::is_none")] - pub executive: Option<bool>, - /// A filter on the list of people returned based on whether these people are legal guardians of the account's representative. - #[serde(skip_serializing_if = "Option::is_none")] - pub legal_guardian: Option<bool>, - /// A filter on the list of people returned based on whether these people are owners of the account's company. - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<bool>, - /// A filter on the list of people returned based on whether these people are the representative of the account's company. - #[serde(skip_serializing_if = "Option::is_none")] - pub representative: Option<bool>, -} -impl PersonsAccountRelationship { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> PersonsAccount<'a> { - /// Returns a list of people associated with the account’s legal entity. - /// The people are returned sorted by creation date, with the most recent people appearing first. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_types::List<stripe_shared::Person>> { - client.get_query(&format!("/accounts/{account}/persons"), self) - } - pub fn paginate( - self, - account: &stripe_shared::AccountId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Person>> { - stripe::ListPaginator::from_list_params(&format!("/accounts/{account}/persons"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccount<'a> { +pub struct UpdateAccount<'a> { /// An [account token](https://stripe.com/docs/api#create_account_token), used to securely provide details to the account. #[serde(skip_serializing_if = "Option::is_none")] pub account_token: Option<&'a str>, @@ -205,7 +41,6 @@ pub struct CreateAccount<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub business_profile: Option<BusinessProfileSpecs<'a>>, /// The business type. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[serde(skip_serializing_if = "Option::is_none")] pub business_type: Option<stripe_shared::AccountBusinessType>, /// Each key of the dictionary represents a capability, and each capability maps to its settings (e.g. @@ -214,17 +49,9 @@ pub struct CreateAccount<'a> { /// An account may have some of its requested capabilities be active and some be inactive. #[serde(skip_serializing_if = "Option::is_none")] pub capabilities: Option<CapabilitiesParam>, - /// Information about the company or business. - /// This field is available for any `business_type`. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. - #[serde(skip_serializing_if = "Option::is_none")] - pub company: Option<CreateAccountCompany<'a>>, - /// The country in which the account holder resides, or in which the business is legally established. - /// This should be an ISO 3166-1 alpha-2 country code. - /// For example, if you are in the United States and the business for which you're creating an account is legally represented in Canada, you would use `CA` as the country for the account being created. - /// Available countries include [Stripe's global markets](https://stripe.com/global) as well as countries where [cross-border payouts](https://stripe.com/docs/connect/cross-border-payouts) are supported. + /// Information about the company or business. This field is available for any `business_type`. #[serde(skip_serializing_if = "Option::is_none")] - pub country: Option<&'a str>, + pub company: Option<UpdateAccountCompany<'a>>, /// Three-letter ISO currency code representing the default currency for the account. /// This must be a currency that [Stripe supports in the account's country](https://stripe.com/docs/payouts). #[serde(skip_serializing_if = "Option::is_none")] @@ -246,14 +73,12 @@ pub struct CreateAccount<'a> { /// /// By default, providing an external account sets it as the new default external account for its currency, and deletes the old default if one exists. /// To add additional external accounts without replacing the existing default for the currency, use the [bank account](https://stripe.com/docs/api#account_create_bank_account) or [card creation](https://stripe.com/docs/api#account_create_card) APIs. - /// After you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[serde(skip_serializing_if = "Option::is_none")] pub external_account: Option<&'a str>, /// Information about the person represented by the account. /// This field is null unless `business_type` is set to `individual`. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[serde(skip_serializing_if = "Option::is_none")] - pub individual: Option<CreateAccountIndividual<'a>>, + pub individual: Option<UpdateAccountIndividual<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -262,34 +87,28 @@ pub struct CreateAccount<'a> { pub metadata: Option<&'a std::collections::HashMap<String, String>>, /// Options for customizing how the account functions within Stripe. #[serde(skip_serializing_if = "Option::is_none")] - pub settings: Option<CreateAccountSettings<'a>>, - /// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance) This property can only be updated for Custom accounts. + pub settings: Option<UpdateAccountSettings<'a>>, + /// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance). #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option<TosAcceptanceSpecs<'a>>, - /// The type of Stripe account to create. May be one of `custom`, `express` or `standard`. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub type_: Option<stripe_shared::AccountType>, } -impl<'a> CreateAccount<'a> { +impl<'a> UpdateAccount<'a> { pub fn new() -> Self { Self::default() } } -/// Information about the company or business. -/// This field is available for any `business_type`. -/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. +/// Information about the company or business. This field is available for any `business_type`. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountCompany<'a> { +pub struct UpdateAccountCompany<'a> { /// The company's primary address. #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<AddressSpecs<'a>>, /// The Kana variation of the company's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kana: Option<CreateAccountCompanyAddressKana<'a>>, + pub address_kana: Option<UpdateAccountCompanyAddressKana<'a>>, /// The Kanji variation of the company's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kanji: Option<CreateAccountCompanyAddressKanji<'a>>, + pub address_kanji: Option<UpdateAccountCompanyAddressKanji<'a>>, /// Whether the company's directors have been provided. /// Set this Boolean to `true` after creating all the company's directors with [the Persons API](https://stripe.com/docs/api/persons) for accounts with a `relationship.director` requirement. /// This value is not automatically set to `true` after creating directors, so it needs to be updated to indicate all directors have been provided. @@ -330,9 +149,8 @@ pub struct CreateAccountCompany<'a> { pub registration_number: Option<&'a str>, /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. - /// Pass an empty string to unset this value. #[serde(skip_serializing_if = "Option::is_none")] - pub structure: Option<CreateAccountCompanyStructure>, + pub structure: Option<UpdateAccountCompanyStructure>, /// The business ID number of the company, as appropriate for the company’s country. /// (Examples are an Employer ID Number in the U.S., a Business Number in Canada, or a Company Number in the UK.). #[serde(skip_serializing_if = "Option::is_none")] @@ -347,14 +165,14 @@ pub struct CreateAccountCompany<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option<VerificationSpecs<'a>>, } -impl<'a> CreateAccountCompany<'a> { +impl<'a> UpdateAccountCompany<'a> { pub fn new() -> Self { Self::default() } } /// The Kana variation of the company's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountCompanyAddressKana<'a> { +pub struct UpdateAccountCompanyAddressKana<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -377,14 +195,14 @@ pub struct CreateAccountCompanyAddressKana<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> CreateAccountCompanyAddressKana<'a> { +impl<'a> UpdateAccountCompanyAddressKana<'a> { pub fn new() -> Self { Self::default() } } /// The Kanji variation of the company's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountCompanyAddressKanji<'a> { +pub struct UpdateAccountCompanyAddressKanji<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -407,17 +225,16 @@ pub struct CreateAccountCompanyAddressKanji<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> CreateAccountCompanyAddressKanji<'a> { +impl<'a> UpdateAccountCompanyAddressKanji<'a> { pub fn new() -> Self { Self::default() } } /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. -/// Pass an empty string to unset this value. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] -pub enum CreateAccountCompanyStructure { +pub enum UpdateAccountCompanyStructure { FreeZoneEstablishment, FreeZoneLlc, GovernmentInstrumentality, @@ -433,7 +250,6 @@ pub enum CreateAccountCompanyStructure { PublicCompany, PublicCorporation, PublicPartnership, - RegisteredCharity, SingleMemberLlc, SoleEstablishment, SoleProprietorship, @@ -444,9 +260,9 @@ pub enum CreateAccountCompanyStructure { /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, } -impl CreateAccountCompanyStructure { +impl UpdateAccountCompanyStructure { pub fn as_str(self) -> &'static str { - use CreateAccountCompanyStructure::*; + use UpdateAccountCompanyStructure::*; match self { FreeZoneEstablishment => "free_zone_establishment", FreeZoneLlc => "free_zone_llc", @@ -463,7 +279,6 @@ impl CreateAccountCompanyStructure { PublicCompany => "public_company", PublicCorporation => "public_corporation", PublicPartnership => "public_partnership", - RegisteredCharity => "registered_charity", SingleMemberLlc => "single_member_llc", SoleEstablishment => "sole_establishment", SoleProprietorship => "sole_proprietorship", @@ -476,10 +291,10 @@ impl CreateAccountCompanyStructure { } } -impl std::str::FromStr for CreateAccountCompanyStructure { +impl std::str::FromStr for UpdateAccountCompanyStructure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateAccountCompanyStructure::*; + use UpdateAccountCompanyStructure::*; match s { "free_zone_establishment" => Ok(FreeZoneEstablishment), "free_zone_llc" => Ok(FreeZoneLlc), @@ -496,7 +311,6 @@ impl std::str::FromStr for CreateAccountCompanyStructure { "public_company" => Ok(PublicCompany), "public_corporation" => Ok(PublicCorporation), "public_partnership" => Ok(PublicPartnership), - "registered_charity" => Ok(RegisteredCharity), "single_member_llc" => Ok(SingleMemberLlc), "sole_establishment" => Ok(SoleEstablishment), "sole_proprietorship" => Ok(SoleProprietorship), @@ -508,18 +322,18 @@ impl std::str::FromStr for CreateAccountCompanyStructure { } } } -impl std::fmt::Display for CreateAccountCompanyStructure { +impl std::fmt::Display for UpdateAccountCompanyStructure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateAccountCompanyStructure { +impl std::fmt::Debug for UpdateAccountCompanyStructure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateAccountCompanyStructure { +impl serde::Serialize for UpdateAccountCompanyStructure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -529,18 +343,17 @@ impl serde::Serialize for CreateAccountCompanyStructure { } /// Information about the person represented by the account. /// This field is null unless `business_type` is set to `individual`. -/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountIndividual<'a> { +pub struct UpdateAccountIndividual<'a> { /// The individual's primary address. #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<AddressSpecs<'a>>, /// The Kana variation of the the individual's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kana: Option<CreateAccountIndividualAddressKana<'a>>, + pub address_kana: Option<UpdateAccountIndividualAddressKana<'a>>, /// The Kanji variation of the the individual's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kanji: Option<CreateAccountIndividualAddressKanji<'a>>, + pub address_kanji: Option<UpdateAccountIndividualAddressKanji<'a>>, /// The individual's date of birth. #[serde(skip_serializing_if = "Option::is_none")] pub dob: Option<DateOfBirthSpecs>, @@ -595,13 +408,10 @@ pub struct CreateAccountIndividual<'a> { pub phone: Option<&'a str>, /// Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction. #[serde(skip_serializing_if = "Option::is_none")] - pub political_exposure: Option<CreateAccountIndividualPoliticalExposure>, + pub political_exposure: Option<UpdateAccountIndividualPoliticalExposure>, /// The individual's registered address. #[serde(skip_serializing_if = "Option::is_none")] pub registered_address: Option<AddressSpecs<'a>>, - /// Describes the person’s relationship to the account. - #[serde(skip_serializing_if = "Option::is_none")] - pub relationship: Option<IndividualRelationshipSpecs<'a>>, /// The last four digits of the individual's Social Security Number (U.S. only). #[serde(skip_serializing_if = "Option::is_none")] pub ssn_last_4: Option<&'a str>, @@ -609,14 +419,14 @@ pub struct CreateAccountIndividual<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option<PersonVerificationSpecs<'a>>, } -impl<'a> CreateAccountIndividual<'a> { +impl<'a> UpdateAccountIndividual<'a> { pub fn new() -> Self { Self::default() } } /// The Kana variation of the the individual's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountIndividualAddressKana<'a> { +pub struct UpdateAccountIndividualAddressKana<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -639,14 +449,14 @@ pub struct CreateAccountIndividualAddressKana<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> CreateAccountIndividualAddressKana<'a> { +impl<'a> UpdateAccountIndividualAddressKana<'a> { pub fn new() -> Self { Self::default() } } /// The Kanji variation of the the individual's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountIndividualAddressKanji<'a> { +pub struct UpdateAccountIndividualAddressKanji<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -669,20 +479,20 @@ pub struct CreateAccountIndividualAddressKanji<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> CreateAccountIndividualAddressKanji<'a> { +impl<'a> UpdateAccountIndividualAddressKanji<'a> { pub fn new() -> Self { Self::default() } } /// Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateAccountIndividualPoliticalExposure { +pub enum UpdateAccountIndividualPoliticalExposure { Existing, None, } -impl CreateAccountIndividualPoliticalExposure { +impl UpdateAccountIndividualPoliticalExposure { pub fn as_str(self) -> &'static str { - use CreateAccountIndividualPoliticalExposure::*; + use UpdateAccountIndividualPoliticalExposure::*; match self { Existing => "existing", None => "none", @@ -690,10 +500,10 @@ impl CreateAccountIndividualPoliticalExposure { } } -impl std::str::FromStr for CreateAccountIndividualPoliticalExposure { +impl std::str::FromStr for UpdateAccountIndividualPoliticalExposure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateAccountIndividualPoliticalExposure::*; + use UpdateAccountIndividualPoliticalExposure::*; match s { "existing" => Ok(Existing), "none" => Ok(None), @@ -701,18 +511,18 @@ impl std::str::FromStr for CreateAccountIndividualPoliticalExposure { } } } -impl std::fmt::Display for CreateAccountIndividualPoliticalExposure { +impl std::fmt::Display for UpdateAccountIndividualPoliticalExposure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateAccountIndividualPoliticalExposure { +impl std::fmt::Debug for UpdateAccountIndividualPoliticalExposure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateAccountIndividualPoliticalExposure { +impl serde::Serialize for UpdateAccountIndividualPoliticalExposure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -722,8 +532,8 @@ impl serde::Serialize for CreateAccountIndividualPoliticalExposure { } /// Options for customizing how the account functions within Stripe. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountSettings<'a> { - /// Settings specific to Bacs Direct Debit. +pub struct UpdateAccountSettings<'a> { + /// Settings specific to Bacs Direct Debit payments. #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit_payments: Option<BacsDebitPaymentsSpecs<'a>>, /// Settings used to apply the account's branding to email receipts, invoices, Checkout, and other products. @@ -740,19 +550,19 @@ pub struct CreateAccountSettings<'a> { pub payments: Option<PaymentsSettingsSpecs<'a>>, /// Settings specific to the account's payouts. #[serde(skip_serializing_if = "Option::is_none")] - pub payouts: Option<CreateAccountSettingsPayouts<'a>>, + pub payouts: Option<UpdateAccountSettingsPayouts<'a>>, /// Settings specific to the account's Treasury FinancialAccounts. #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option<TreasurySettingsSpecs<'a>>, } -impl<'a> CreateAccountSettings<'a> { +impl<'a> UpdateAccountSettings<'a> { pub fn new() -> Self { Self::default() } } /// Settings specific to the account's payouts. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountSettingsPayouts<'a> { +pub struct UpdateAccountSettingsPayouts<'a> { /// A Boolean indicating whether Stripe should try to reclaim negative balances from an attached bank account. /// For details, see [Understanding Connect Account Balances](https://stripe.com/docs/connect/account-balances). #[serde(skip_serializing_if = "Option::is_none")] @@ -760,13 +570,13 @@ pub struct CreateAccountSettingsPayouts<'a> { /// Details on when funds from charges are available, and when they are paid out to an external account. /// For details, see our [Setting Bank and Debit Card Payouts](https://stripe.com/docs/connect/bank-transfers#payout-information) documentation. #[serde(skip_serializing_if = "Option::is_none")] - pub schedule: Option<CreateAccountSettingsPayoutsSchedule>, + pub schedule: Option<UpdateAccountSettingsPayoutsSchedule>, /// The text that appears on the bank account statement for payouts. /// If not set, this defaults to the platform's bank descriptor as set in the Dashboard. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, } -impl<'a> CreateAccountSettingsPayouts<'a> { +impl<'a> UpdateAccountSettingsPayouts<'a> { pub fn new() -> Self { Self::default() } @@ -774,19 +584,19 @@ impl<'a> CreateAccountSettingsPayouts<'a> { /// Details on when funds from charges are available, and when they are paid out to an external account. /// For details, see our [Setting Bank and Debit Card Payouts](https://stripe.com/docs/connect/bank-transfers#payout-information) documentation. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountSettingsPayoutsSchedule { +pub struct UpdateAccountSettingsPayoutsSchedule { /// The number of days charge funds are held before being paid out. /// May also be set to `minimum`, representing the lowest available value for the account country. /// Default is `minimum`. /// The `delay_days` parameter remains at the last configured value if `interval` is `manual`. /// [Learn more about controlling payout delay days](https://stripe.com/docs/connect/manage-payout-schedule). #[serde(skip_serializing_if = "Option::is_none")] - pub delay_days: Option<CreateAccountSettingsPayoutsScheduleDelayDays>, + pub delay_days: Option<UpdateAccountSettingsPayoutsScheduleDelayDays>, /// How frequently available funds are paid out. /// One of: `daily`, `manual`, `weekly`, or `monthly`. /// Default is `daily`. #[serde(skip_serializing_if = "Option::is_none")] - pub interval: Option<CreateAccountSettingsPayoutsScheduleInterval>, + pub interval: Option<UpdateAccountSettingsPayoutsScheduleInterval>, /// The day of the month when available funds are paid out, specified as a number between 1--31. /// Payouts nominally scheduled between the 29th and 31st of the month are instead sent on the last day of a shorter month. /// Required and applicable only if `interval` is `monthly`. @@ -795,9 +605,9 @@ pub struct CreateAccountSettingsPayoutsSchedule { /// The day of the week when available funds are paid out, specified as `monday`, `tuesday`, etc. /// (required and applicable only if `interval` is `weekly`.). #[serde(skip_serializing_if = "Option::is_none")] - pub weekly_anchor: Option<CreateAccountSettingsPayoutsScheduleWeeklyAnchor>, + pub weekly_anchor: Option<UpdateAccountSettingsPayoutsScheduleWeeklyAnchor>, } -impl CreateAccountSettingsPayoutsSchedule { +impl UpdateAccountSettingsPayoutsSchedule { pub fn new() -> Self { Self::default() } @@ -809,7 +619,7 @@ impl CreateAccountSettingsPayoutsSchedule { /// [Learn more about controlling payout delay days](https://stripe.com/docs/connect/manage-payout-schedule). #[derive(Copy, Clone, Debug, serde::Serialize)] #[serde(untagged)] -pub enum CreateAccountSettingsPayoutsScheduleDelayDays { +pub enum UpdateAccountSettingsPayoutsScheduleDelayDays { Minimum, U32(u32), } @@ -817,15 +627,15 @@ pub enum CreateAccountSettingsPayoutsScheduleDelayDays { /// One of: `daily`, `manual`, `weekly`, or `monthly`. /// Default is `daily`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateAccountSettingsPayoutsScheduleInterval { +pub enum UpdateAccountSettingsPayoutsScheduleInterval { Daily, Manual, Monthly, Weekly, } -impl CreateAccountSettingsPayoutsScheduleInterval { +impl UpdateAccountSettingsPayoutsScheduleInterval { pub fn as_str(self) -> &'static str { - use CreateAccountSettingsPayoutsScheduleInterval::*; + use UpdateAccountSettingsPayoutsScheduleInterval::*; match self { Daily => "daily", Manual => "manual", @@ -835,10 +645,10 @@ impl CreateAccountSettingsPayoutsScheduleInterval { } } -impl std::str::FromStr for CreateAccountSettingsPayoutsScheduleInterval { +impl std::str::FromStr for UpdateAccountSettingsPayoutsScheduleInterval { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateAccountSettingsPayoutsScheduleInterval::*; + use UpdateAccountSettingsPayoutsScheduleInterval::*; match s { "daily" => Ok(Daily), "manual" => Ok(Manual), @@ -848,18 +658,18 @@ impl std::str::FromStr for CreateAccountSettingsPayoutsScheduleInterval { } } } -impl std::fmt::Display for CreateAccountSettingsPayoutsScheduleInterval { +impl std::fmt::Display for UpdateAccountSettingsPayoutsScheduleInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateAccountSettingsPayoutsScheduleInterval { +impl std::fmt::Debug for UpdateAccountSettingsPayoutsScheduleInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateAccountSettingsPayoutsScheduleInterval { +impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleInterval { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -870,7 +680,7 @@ impl serde::Serialize for CreateAccountSettingsPayoutsScheduleInterval { /// The day of the week when available funds are paid out, specified as `monday`, `tuesday`, etc. /// (required and applicable only if `interval` is `weekly`.). #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateAccountSettingsPayoutsScheduleWeeklyAnchor { +pub enum UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { Friday, Monday, Saturday, @@ -879,9 +689,9 @@ pub enum CreateAccountSettingsPayoutsScheduleWeeklyAnchor { Tuesday, Wednesday, } -impl CreateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { pub fn as_str(self) -> &'static str { - use CreateAccountSettingsPayoutsScheduleWeeklyAnchor::*; + use UpdateAccountSettingsPayoutsScheduleWeeklyAnchor::*; match self { Friday => "friday", Monday => "monday", @@ -894,10 +704,10 @@ impl CreateAccountSettingsPayoutsScheduleWeeklyAnchor { } } -impl std::str::FromStr for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl std::str::FromStr for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateAccountSettingsPayoutsScheduleWeeklyAnchor::*; + use UpdateAccountSettingsPayoutsScheduleWeeklyAnchor::*; match s { "friday" => Ok(Friday), "monday" => Ok(Monday), @@ -910,18 +720,18 @@ impl std::str::FromStr for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { } } } -impl std::fmt::Display for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl std::fmt::Display for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl std::fmt::Debug for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -929,20 +739,65 @@ impl serde::Serialize for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { serializer.serialize_str(self.as_str()) } } -impl<'a> CreateAccount<'a> { - /// With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users. - /// To do this, you’ll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings). +impl<'a> UpdateAccount<'a> { + /// Updates a [connected account](https://stripe.com/docs/connect/accounts) by setting the values of the parameters passed. + /// Any parameters not provided are. + /// left unchanged. /// - /// If you’ve already collected information for your connected accounts, you [can prefill that information](https://stripe.com/docs/connect/best-practices#onboarding) when. - /// creating the account. - /// Connect Onboarding won’t ask for the prefilled information during account onboarding. - /// You can prefill any information on the account. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Account> { - client.send_form("/accounts", self, http_types::Method::Post) + /// For Custom accounts, you can update any information on the account. + /// For other accounts, you can update all information until that. + /// account has started to go through Connect Onboarding. + /// Once you create an [Account Link](https://stripe.com/docs/api/account_links). + /// for a Standard or Express account, some parameters can no longer be changed. + /// These are marked as **Custom Only** or **Custom and Express**. + /// below. + /// + /// To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account). + /// Refer to our. + /// [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_shared::Account> { + client.send_form(&format!("/accounts/{account}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccount<'a> { +pub struct ListAccount<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListAccount<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListAccount<'a> { + /// Returns a list of accounts connected to your platform via [Connect](https://stripe.com/docs/connect). + /// If you’re not a platform, the list is empty. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Account>> { + client.get_query("/accounts", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Account>> { + stripe::ListPaginator::from_list_params("/accounts", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreateAccount<'a> { /// An [account token](https://stripe.com/docs/api#create_account_token), used to securely provide details to the account. #[serde(skip_serializing_if = "Option::is_none")] pub account_token: Option<&'a str>, @@ -950,7 +805,6 @@ pub struct UpdateAccount<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub business_profile: Option<BusinessProfileSpecs<'a>>, /// The business type. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[serde(skip_serializing_if = "Option::is_none")] pub business_type: Option<stripe_shared::AccountBusinessType>, /// Each key of the dictionary represents a capability, and each capability maps to its settings (e.g. @@ -959,11 +813,15 @@ pub struct UpdateAccount<'a> { /// An account may have some of its requested capabilities be active and some be inactive. #[serde(skip_serializing_if = "Option::is_none")] pub capabilities: Option<CapabilitiesParam>, - /// Information about the company or business. - /// This field is available for any `business_type`. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. + /// Information about the company or business. This field is available for any `business_type`. #[serde(skip_serializing_if = "Option::is_none")] - pub company: Option<UpdateAccountCompany<'a>>, + pub company: Option<CreateAccountCompany<'a>>, + /// The country in which the account holder resides, or in which the business is legally established. + /// This should be an ISO 3166-1 alpha-2 country code. + /// For example, if you are in the United States and the business for which you're creating an account is legally represented in Canada, you would use `CA` as the country for the account being created. + /// Available countries include [Stripe's global markets](https://stripe.com/global) as well as countries where [cross-border payouts](https://stripe.com/docs/connect/cross-border-payouts) are supported. + #[serde(skip_serializing_if = "Option::is_none")] + pub country: Option<&'a str>, /// Three-letter ISO currency code representing the default currency for the account. /// This must be a currency that [Stripe supports in the account's country](https://stripe.com/docs/payouts). #[serde(skip_serializing_if = "Option::is_none")] @@ -985,14 +843,12 @@ pub struct UpdateAccount<'a> { /// /// By default, providing an external account sets it as the new default external account for its currency, and deletes the old default if one exists. /// To add additional external accounts without replacing the existing default for the currency, use the [bank account](https://stripe.com/docs/api#account_create_bank_account) or [card creation](https://stripe.com/docs/api#account_create_card) APIs. - /// After you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[serde(skip_serializing_if = "Option::is_none")] pub external_account: Option<&'a str>, /// Information about the person represented by the account. /// This field is null unless `business_type` is set to `individual`. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[serde(skip_serializing_if = "Option::is_none")] - pub individual: Option<UpdateAccountIndividual<'a>>, + pub individual: Option<CreateAccountIndividual<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -1001,30 +857,32 @@ pub struct UpdateAccount<'a> { pub metadata: Option<&'a std::collections::HashMap<String, String>>, /// Options for customizing how the account functions within Stripe. #[serde(skip_serializing_if = "Option::is_none")] - pub settings: Option<UpdateAccountSettings<'a>>, - /// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance) This property can only be updated for Custom accounts. + pub settings: Option<CreateAccountSettings<'a>>, + /// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance). #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option<TosAcceptanceSpecs<'a>>, + /// The type of Stripe account to create. May be one of `custom`, `express` or `standard`. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + #[serde(skip_serializing_if = "Option::is_none")] + pub type_: Option<stripe_shared::AccountType>, } -impl<'a> UpdateAccount<'a> { +impl<'a> CreateAccount<'a> { pub fn new() -> Self { Self::default() } } -/// Information about the company or business. -/// This field is available for any `business_type`. -/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. +/// Information about the company or business. This field is available for any `business_type`. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountCompany<'a> { +pub struct CreateAccountCompany<'a> { /// The company's primary address. #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<AddressSpecs<'a>>, /// The Kana variation of the company's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kana: Option<UpdateAccountCompanyAddressKana<'a>>, + pub address_kana: Option<CreateAccountCompanyAddressKana<'a>>, /// The Kanji variation of the company's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kanji: Option<UpdateAccountCompanyAddressKanji<'a>>, + pub address_kanji: Option<CreateAccountCompanyAddressKanji<'a>>, /// Whether the company's directors have been provided. /// Set this Boolean to `true` after creating all the company's directors with [the Persons API](https://stripe.com/docs/api/persons) for accounts with a `relationship.director` requirement. /// This value is not automatically set to `true` after creating directors, so it needs to be updated to indicate all directors have been provided. @@ -1065,9 +923,8 @@ pub struct UpdateAccountCompany<'a> { pub registration_number: Option<&'a str>, /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. - /// Pass an empty string to unset this value. #[serde(skip_serializing_if = "Option::is_none")] - pub structure: Option<UpdateAccountCompanyStructure>, + pub structure: Option<CreateAccountCompanyStructure>, /// The business ID number of the company, as appropriate for the company’s country. /// (Examples are an Employer ID Number in the U.S., a Business Number in Canada, or a Company Number in the UK.). #[serde(skip_serializing_if = "Option::is_none")] @@ -1082,14 +939,14 @@ pub struct UpdateAccountCompany<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option<VerificationSpecs<'a>>, } -impl<'a> UpdateAccountCompany<'a> { +impl<'a> CreateAccountCompany<'a> { pub fn new() -> Self { Self::default() } } /// The Kana variation of the company's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountCompanyAddressKana<'a> { +pub struct CreateAccountCompanyAddressKana<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -1112,14 +969,14 @@ pub struct UpdateAccountCompanyAddressKana<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> UpdateAccountCompanyAddressKana<'a> { +impl<'a> CreateAccountCompanyAddressKana<'a> { pub fn new() -> Self { Self::default() } } /// The Kanji variation of the company's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountCompanyAddressKanji<'a> { +pub struct CreateAccountCompanyAddressKanji<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -1142,17 +999,16 @@ pub struct UpdateAccountCompanyAddressKanji<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> UpdateAccountCompanyAddressKanji<'a> { +impl<'a> CreateAccountCompanyAddressKanji<'a> { pub fn new() -> Self { Self::default() } } /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. -/// Pass an empty string to unset this value. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] -pub enum UpdateAccountCompanyStructure { +pub enum CreateAccountCompanyStructure { FreeZoneEstablishment, FreeZoneLlc, GovernmentInstrumentality, @@ -1168,7 +1024,6 @@ pub enum UpdateAccountCompanyStructure { PublicCompany, PublicCorporation, PublicPartnership, - RegisteredCharity, SingleMemberLlc, SoleEstablishment, SoleProprietorship, @@ -1179,9 +1034,9 @@ pub enum UpdateAccountCompanyStructure { /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, } -impl UpdateAccountCompanyStructure { +impl CreateAccountCompanyStructure { pub fn as_str(self) -> &'static str { - use UpdateAccountCompanyStructure::*; + use CreateAccountCompanyStructure::*; match self { FreeZoneEstablishment => "free_zone_establishment", FreeZoneLlc => "free_zone_llc", @@ -1198,7 +1053,6 @@ impl UpdateAccountCompanyStructure { PublicCompany => "public_company", PublicCorporation => "public_corporation", PublicPartnership => "public_partnership", - RegisteredCharity => "registered_charity", SingleMemberLlc => "single_member_llc", SoleEstablishment => "sole_establishment", SoleProprietorship => "sole_proprietorship", @@ -1211,10 +1065,10 @@ impl UpdateAccountCompanyStructure { } } -impl std::str::FromStr for UpdateAccountCompanyStructure { +impl std::str::FromStr for CreateAccountCompanyStructure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateAccountCompanyStructure::*; + use CreateAccountCompanyStructure::*; match s { "free_zone_establishment" => Ok(FreeZoneEstablishment), "free_zone_llc" => Ok(FreeZoneLlc), @@ -1231,7 +1085,6 @@ impl std::str::FromStr for UpdateAccountCompanyStructure { "public_company" => Ok(PublicCompany), "public_corporation" => Ok(PublicCorporation), "public_partnership" => Ok(PublicPartnership), - "registered_charity" => Ok(RegisteredCharity), "single_member_llc" => Ok(SingleMemberLlc), "sole_establishment" => Ok(SoleEstablishment), "sole_proprietorship" => Ok(SoleProprietorship), @@ -1243,18 +1096,18 @@ impl std::str::FromStr for UpdateAccountCompanyStructure { } } } -impl std::fmt::Display for UpdateAccountCompanyStructure { +impl std::fmt::Display for CreateAccountCompanyStructure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateAccountCompanyStructure { +impl std::fmt::Debug for CreateAccountCompanyStructure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateAccountCompanyStructure { +impl serde::Serialize for CreateAccountCompanyStructure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1264,18 +1117,17 @@ impl serde::Serialize for UpdateAccountCompanyStructure { } /// Information about the person represented by the account. /// This field is null unless `business_type` is set to `individual`. -/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountIndividual<'a> { +pub struct CreateAccountIndividual<'a> { /// The individual's primary address. #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<AddressSpecs<'a>>, /// The Kana variation of the the individual's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kana: Option<UpdateAccountIndividualAddressKana<'a>>, + pub address_kana: Option<CreateAccountIndividualAddressKana<'a>>, /// The Kanji variation of the the individual's primary address (Japan only). #[serde(skip_serializing_if = "Option::is_none")] - pub address_kanji: Option<UpdateAccountIndividualAddressKanji<'a>>, + pub address_kanji: Option<CreateAccountIndividualAddressKanji<'a>>, /// The individual's date of birth. #[serde(skip_serializing_if = "Option::is_none")] pub dob: Option<DateOfBirthSpecs>, @@ -1330,13 +1182,10 @@ pub struct UpdateAccountIndividual<'a> { pub phone: Option<&'a str>, /// Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction. #[serde(skip_serializing_if = "Option::is_none")] - pub political_exposure: Option<UpdateAccountIndividualPoliticalExposure>, + pub political_exposure: Option<CreateAccountIndividualPoliticalExposure>, /// The individual's registered address. #[serde(skip_serializing_if = "Option::is_none")] pub registered_address: Option<AddressSpecs<'a>>, - /// Describes the person’s relationship to the account. - #[serde(skip_serializing_if = "Option::is_none")] - pub relationship: Option<IndividualRelationshipSpecs<'a>>, /// The last four digits of the individual's Social Security Number (U.S. only). #[serde(skip_serializing_if = "Option::is_none")] pub ssn_last_4: Option<&'a str>, @@ -1344,14 +1193,14 @@ pub struct UpdateAccountIndividual<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option<PersonVerificationSpecs<'a>>, } -impl<'a> UpdateAccountIndividual<'a> { +impl<'a> CreateAccountIndividual<'a> { pub fn new() -> Self { Self::default() } } /// The Kana variation of the the individual's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountIndividualAddressKana<'a> { +pub struct CreateAccountIndividualAddressKana<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -1374,14 +1223,14 @@ pub struct UpdateAccountIndividualAddressKana<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> UpdateAccountIndividualAddressKana<'a> { +impl<'a> CreateAccountIndividualAddressKana<'a> { pub fn new() -> Self { Self::default() } } /// The Kanji variation of the the individual's primary address (Japan only). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountIndividualAddressKanji<'a> { +pub struct CreateAccountIndividualAddressKanji<'a> { /// City or ward. #[serde(skip_serializing_if = "Option::is_none")] pub city: Option<&'a str>, @@ -1404,20 +1253,20 @@ pub struct UpdateAccountIndividualAddressKanji<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub town: Option<&'a str>, } -impl<'a> UpdateAccountIndividualAddressKanji<'a> { +impl<'a> CreateAccountIndividualAddressKanji<'a> { pub fn new() -> Self { Self::default() } } /// Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateAccountIndividualPoliticalExposure { +pub enum CreateAccountIndividualPoliticalExposure { Existing, None, } -impl UpdateAccountIndividualPoliticalExposure { +impl CreateAccountIndividualPoliticalExposure { pub fn as_str(self) -> &'static str { - use UpdateAccountIndividualPoliticalExposure::*; + use CreateAccountIndividualPoliticalExposure::*; match self { Existing => "existing", None => "none", @@ -1425,10 +1274,10 @@ impl UpdateAccountIndividualPoliticalExposure { } } -impl std::str::FromStr for UpdateAccountIndividualPoliticalExposure { +impl std::str::FromStr for CreateAccountIndividualPoliticalExposure { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateAccountIndividualPoliticalExposure::*; + use CreateAccountIndividualPoliticalExposure::*; match s { "existing" => Ok(Existing), "none" => Ok(None), @@ -1436,18 +1285,18 @@ impl std::str::FromStr for UpdateAccountIndividualPoliticalExposure { } } } -impl std::fmt::Display for UpdateAccountIndividualPoliticalExposure { +impl std::fmt::Display for CreateAccountIndividualPoliticalExposure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateAccountIndividualPoliticalExposure { +impl std::fmt::Debug for CreateAccountIndividualPoliticalExposure { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateAccountIndividualPoliticalExposure { +impl serde::Serialize for CreateAccountIndividualPoliticalExposure { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1457,8 +1306,8 @@ impl serde::Serialize for UpdateAccountIndividualPoliticalExposure { } /// Options for customizing how the account functions within Stripe. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountSettings<'a> { - /// Settings specific to Bacs Direct Debit payments. +pub struct CreateAccountSettings<'a> { + /// Settings specific to Bacs Direct Debit. #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit_payments: Option<BacsDebitPaymentsSpecs<'a>>, /// Settings used to apply the account's branding to email receipts, invoices, Checkout, and other products. @@ -1470,40 +1319,24 @@ pub struct UpdateAccountSettings<'a> { /// Settings specific to card charging on the account. #[serde(skip_serializing_if = "Option::is_none")] pub card_payments: Option<CardPaymentsSettingsSpecs<'a>>, - /// Settings specific to the account's use of Invoices. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoices: Option<UpdateAccountSettingsInvoices<'a>>, /// Settings that apply across payment methods for charging on the account. #[serde(skip_serializing_if = "Option::is_none")] pub payments: Option<PaymentsSettingsSpecs<'a>>, /// Settings specific to the account's payouts. #[serde(skip_serializing_if = "Option::is_none")] - pub payouts: Option<UpdateAccountSettingsPayouts<'a>>, + pub payouts: Option<CreateAccountSettingsPayouts<'a>>, /// Settings specific to the account's Treasury FinancialAccounts. #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option<TreasurySettingsSpecs<'a>>, } -impl<'a> UpdateAccountSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Settings specific to the account's use of Invoices. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountSettingsInvoices<'a> { - /// The list of default Account Tax IDs to automatically include on invoices. - /// Account Tax IDs get added when an invoice is finalized. - #[serde(skip_serializing_if = "Option::is_none")] - pub default_account_tax_ids: Option<&'a [&'a str]>, -} -impl<'a> UpdateAccountSettingsInvoices<'a> { +impl<'a> CreateAccountSettings<'a> { pub fn new() -> Self { Self::default() } } /// Settings specific to the account's payouts. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountSettingsPayouts<'a> { +pub struct CreateAccountSettingsPayouts<'a> { /// A Boolean indicating whether Stripe should try to reclaim negative balances from an attached bank account. /// For details, see [Understanding Connect Account Balances](https://stripe.com/docs/connect/account-balances). #[serde(skip_serializing_if = "Option::is_none")] @@ -1511,13 +1344,13 @@ pub struct UpdateAccountSettingsPayouts<'a> { /// Details on when funds from charges are available, and when they are paid out to an external account. /// For details, see our [Setting Bank and Debit Card Payouts](https://stripe.com/docs/connect/bank-transfers#payout-information) documentation. #[serde(skip_serializing_if = "Option::is_none")] - pub schedule: Option<UpdateAccountSettingsPayoutsSchedule>, + pub schedule: Option<CreateAccountSettingsPayoutsSchedule>, /// The text that appears on the bank account statement for payouts. /// If not set, this defaults to the platform's bank descriptor as set in the Dashboard. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, } -impl<'a> UpdateAccountSettingsPayouts<'a> { +impl<'a> CreateAccountSettingsPayouts<'a> { pub fn new() -> Self { Self::default() } @@ -1525,19 +1358,19 @@ impl<'a> UpdateAccountSettingsPayouts<'a> { /// Details on when funds from charges are available, and when they are paid out to an external account. /// For details, see our [Setting Bank and Debit Card Payouts](https://stripe.com/docs/connect/bank-transfers#payout-information) documentation. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateAccountSettingsPayoutsSchedule { +pub struct CreateAccountSettingsPayoutsSchedule { /// The number of days charge funds are held before being paid out. /// May also be set to `minimum`, representing the lowest available value for the account country. /// Default is `minimum`. /// The `delay_days` parameter remains at the last configured value if `interval` is `manual`. /// [Learn more about controlling payout delay days](https://stripe.com/docs/connect/manage-payout-schedule). #[serde(skip_serializing_if = "Option::is_none")] - pub delay_days: Option<UpdateAccountSettingsPayoutsScheduleDelayDays>, + pub delay_days: Option<CreateAccountSettingsPayoutsScheduleDelayDays>, /// How frequently available funds are paid out. /// One of: `daily`, `manual`, `weekly`, or `monthly`. /// Default is `daily`. #[serde(skip_serializing_if = "Option::is_none")] - pub interval: Option<UpdateAccountSettingsPayoutsScheduleInterval>, + pub interval: Option<CreateAccountSettingsPayoutsScheduleInterval>, /// The day of the month when available funds are paid out, specified as a number between 1--31. /// Payouts nominally scheduled between the 29th and 31st of the month are instead sent on the last day of a shorter month. /// Required and applicable only if `interval` is `monthly`. @@ -1546,9 +1379,9 @@ pub struct UpdateAccountSettingsPayoutsSchedule { /// The day of the week when available funds are paid out, specified as `monday`, `tuesday`, etc. /// (required and applicable only if `interval` is `weekly`.). #[serde(skip_serializing_if = "Option::is_none")] - pub weekly_anchor: Option<UpdateAccountSettingsPayoutsScheduleWeeklyAnchor>, + pub weekly_anchor: Option<CreateAccountSettingsPayoutsScheduleWeeklyAnchor>, } -impl UpdateAccountSettingsPayoutsSchedule { +impl CreateAccountSettingsPayoutsSchedule { pub fn new() -> Self { Self::default() } @@ -1560,7 +1393,7 @@ impl UpdateAccountSettingsPayoutsSchedule { /// [Learn more about controlling payout delay days](https://stripe.com/docs/connect/manage-payout-schedule). #[derive(Copy, Clone, Debug, serde::Serialize)] #[serde(untagged)] -pub enum UpdateAccountSettingsPayoutsScheduleDelayDays { +pub enum CreateAccountSettingsPayoutsScheduleDelayDays { Minimum, U32(u32), } @@ -1568,15 +1401,15 @@ pub enum UpdateAccountSettingsPayoutsScheduleDelayDays { /// One of: `daily`, `manual`, `weekly`, or `monthly`. /// Default is `daily`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateAccountSettingsPayoutsScheduleInterval { +pub enum CreateAccountSettingsPayoutsScheduleInterval { Daily, Manual, Monthly, Weekly, } -impl UpdateAccountSettingsPayoutsScheduleInterval { +impl CreateAccountSettingsPayoutsScheduleInterval { pub fn as_str(self) -> &'static str { - use UpdateAccountSettingsPayoutsScheduleInterval::*; + use CreateAccountSettingsPayoutsScheduleInterval::*; match self { Daily => "daily", Manual => "manual", @@ -1586,10 +1419,10 @@ impl UpdateAccountSettingsPayoutsScheduleInterval { } } -impl std::str::FromStr for UpdateAccountSettingsPayoutsScheduleInterval { +impl std::str::FromStr for CreateAccountSettingsPayoutsScheduleInterval { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateAccountSettingsPayoutsScheduleInterval::*; + use CreateAccountSettingsPayoutsScheduleInterval::*; match s { "daily" => Ok(Daily), "manual" => Ok(Manual), @@ -1599,18 +1432,18 @@ impl std::str::FromStr for UpdateAccountSettingsPayoutsScheduleInterval { } } } -impl std::fmt::Display for UpdateAccountSettingsPayoutsScheduleInterval { +impl std::fmt::Display for CreateAccountSettingsPayoutsScheduleInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateAccountSettingsPayoutsScheduleInterval { +impl std::fmt::Debug for CreateAccountSettingsPayoutsScheduleInterval { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleInterval { +impl serde::Serialize for CreateAccountSettingsPayoutsScheduleInterval { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1621,7 +1454,7 @@ impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleInterval { /// The day of the week when available funds are paid out, specified as `monday`, `tuesday`, etc. /// (required and applicable only if `interval` is `weekly`.). #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { +pub enum CreateAccountSettingsPayoutsScheduleWeeklyAnchor { Friday, Monday, Saturday, @@ -1630,9 +1463,9 @@ pub enum UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { Tuesday, Wednesday, } -impl UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl CreateAccountSettingsPayoutsScheduleWeeklyAnchor { pub fn as_str(self) -> &'static str { - use UpdateAccountSettingsPayoutsScheduleWeeklyAnchor::*; + use CreateAccountSettingsPayoutsScheduleWeeklyAnchor::*; match self { Friday => "friday", Monday => "monday", @@ -1645,10 +1478,10 @@ impl UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { } } -impl std::str::FromStr for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl std::str::FromStr for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateAccountSettingsPayoutsScheduleWeeklyAnchor::*; + use CreateAccountSettingsPayoutsScheduleWeeklyAnchor::*; match s { "friday" => Ok(Friday), "monday" => Ok(Monday), @@ -1661,18 +1494,18 @@ impl std::str::FromStr for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { } } } -impl std::fmt::Display for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl std::fmt::Display for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl std::fmt::Debug for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { +impl serde::Serialize for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1680,26 +1513,35 @@ impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { serializer.serialize_str(self.as_str()) } } -impl<'a> UpdateAccount<'a> { - /// Updates a [connected account](https://stripe.com/docs/connect/accounts) by setting the values of the parameters passed. - /// Any parameters not provided are. - /// left unchanged. +impl<'a> CreateAccount<'a> { + /// With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users. + /// To do this, you’ll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings). /// - /// For Custom accounts, you can update any information on the account. - /// For other accounts, you can update all information until that. - /// account has started to go through Connect Onboarding. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions),. - /// some properties can only be changed or updated for Custom accounts. + /// If you’ve already collected information for your connected accounts, you [can prefill that information](https://stripe.com/docs/connect/best-practices#onboarding) when. + /// creating the account. + /// Connect Onboarding won’t ask for the prefilled information during account onboarding. + /// You can prefill any information on the account. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Account> { + client.send_form("/accounts", self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteAccount {} +impl DeleteAccount { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteAccount { + /// With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage. /// - /// To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account). - /// Refer to our. - /// [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_shared::Account> { - client.send_form(&format!("/accounts/{account}"), self, http_types::Method::Post) + /// Accounts created using test-mode keys can be deleted at any time. + /// Standard accounts created using live-mode keys cannot be deleted. + /// Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero. + /// + /// If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_shared::DeletedAccount> { + client.send_form(&format!("/accounts/{account}"), self, http_types::Method::Delete) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -1720,29 +1562,91 @@ impl<'a> RejectAccount<'a> { /// /// Test-mode Custom and Express accounts can be rejected at any time. /// Accounts created using live-mode keys may only be rejected once all balances are zero. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_shared::Account> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_shared::Account> { client.send_form(&format!("/accounts/{account}/reject"), self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct AnnualRevenueSpecs<'a> { - /// A non-negative integer representing the amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). - pub amount: i64, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// The close-out date of the preceding fiscal year in ISO 8601 format. - /// E.g. - /// 2023-12-31 for the 31st of December, 2023. - pub fiscal_year_end: &'a str, +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct PersonsAccount<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// Filters on the list of people returned based on the person's relationship to the account's company. + #[serde(skip_serializing_if = "Option::is_none")] + pub relationship: Option<PersonsAccountRelationship>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> PersonsAccount<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Filters on the list of people returned based on the person's relationship to the account's company. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct PersonsAccountRelationship { + /// A filter on the list of people returned based on whether these people are directors of the account's company. + #[serde(skip_serializing_if = "Option::is_none")] + pub director: Option<bool>, + /// A filter on the list of people returned based on whether these people are executives of the account's company. + #[serde(skip_serializing_if = "Option::is_none")] + pub executive: Option<bool>, + /// A filter on the list of people returned based on whether these people are legal guardians of the account's representative. + #[serde(skip_serializing_if = "Option::is_none")] + pub legal_guardian: Option<bool>, + /// A filter on the list of people returned based on whether these people are owners of the account's company. + #[serde(skip_serializing_if = "Option::is_none")] + pub owner: Option<bool>, + /// A filter on the list of people returned based on whether these people are the representative of the account's company. + #[serde(skip_serializing_if = "Option::is_none")] + pub representative: Option<bool>, +} +impl PersonsAccountRelationship { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> PersonsAccount<'a> { + /// Returns a list of people associated with the account’s legal entity. + /// The people are returned sorted by creation date, with the most recent people appearing first. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_types::List<stripe_shared::Person>> { + client.get_query(&format!("/accounts/{account}/persons"), self) + } + pub fn paginate(self, account: &stripe_shared::AccountId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Person>> { + stripe::ListPaginator::from_list_params(&format!("/accounts/{account}/persons"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CapabilitiesAccount<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> CapabilitiesAccount<'a> { + pub fn new() -> Self { + Self::default() + } } -impl<'a> AnnualRevenueSpecs<'a> { - pub fn new(amount: i64, currency: stripe_types::Currency, fiscal_year_end: &'a str) -> Self { - Self { amount, currency, fiscal_year_end } +impl<'a> CapabilitiesAccount<'a> { + /// Returns a list of capabilities associated with the account. + /// The capabilities are returned sorted by creation date, with the most recent capability appearing first. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_types::List<stripe_shared::Capability>> { + client.get_query(&format!("/accounts/{account}/capabilities"), self) + } + pub fn paginate(self, account: &stripe_shared::AccountId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Capability>> { + stripe::ListPaginator::from_list_params(&format!("/accounts/{account}/capabilities"), self) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -1856,30 +1760,6 @@ impl DateOfBirthSpecs { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct IndividualRelationshipSpecs<'a> { - /// Whether the person is a director of the account's legal entity. - /// Directors are typically members of the governing board of the company, or responsible for ensuring the company meets its regulatory obligations. - #[serde(skip_serializing_if = "Option::is_none")] - pub director: Option<bool>, - /// Whether the person has significant responsibility to control, manage, or direct the organization. - #[serde(skip_serializing_if = "Option::is_none")] - pub executive: Option<bool>, - /// Whether the person is an owner of the account’s legal entity. - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<bool>, - /// The percent owned by the person of the account's legal entity. - #[serde(skip_serializing_if = "Option::is_none")] - pub percent_ownership: Option<f64>, - /// The person's title (e.g., CEO, Support Engineer). - #[serde(skip_serializing_if = "Option::is_none")] - pub title: Option<&'a str>, -} -impl<'a> IndividualRelationshipSpecs<'a> { - pub fn new() -> Self { - Self::default() - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct PersonVerificationDocumentSpecs<'a> { /// The back of an ID returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `identity_document`. /// The uploaded file needs to be a color image (smaller than 8,000px by 8,000px), in JPG, PNG, or PDF format, and less than 10 MB in size. @@ -2006,13 +1886,6 @@ impl<'a> TosAcceptanceSpecs<'a> { } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct BusinessProfileSpecs<'a> { - /// The applicant's gross annual revenue for its preceding fiscal year. - #[serde(skip_serializing_if = "Option::is_none")] - pub annual_revenue: Option<AnnualRevenueSpecs<'a>>, - /// An estimated upper bound of employees, contractors, vendors, etc. - /// currently working for the business. - #[serde(skip_serializing_if = "Option::is_none")] - pub estimated_worker_count: Option<u64>, /// [The merchant category code for the account](https://stripe.com/docs/connect/setting-mcc). /// MCCs are used to classify businesses based on the goods or services they provide. #[serde(skip_serializing_if = "Option::is_none")] @@ -2143,9 +2016,6 @@ pub struct CapabilitiesParam { /// The sofort_payments capability. #[serde(skip_serializing_if = "Option::is_none")] pub sofort_payments: Option<CapabilityParam>, - /// The swish_payments capability. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish_payments: Option<CapabilityParam>, /// The tax_reporting_us_1099_k capability. #[serde(skip_serializing_if = "Option::is_none")] pub tax_reporting_us_1099_k: Option<CapabilityParam>, diff --git a/generated/stripe_connect/src/account_link/requests.rs b/generated/stripe_connect/src/account_link/requests.rs index 3491c04a2..325aa8b20 100644 --- a/generated/stripe_connect/src/account_link/requests.rs +++ b/generated/stripe_connect/src/account_link/requests.rs @@ -2,12 +2,11 @@ pub struct CreateAccountLink<'a> { /// The identifier of the account to create an account link for. pub account: &'a str, - /// The collect parameter is deprecated. Use `collection_options` instead. + /// Which information the platform needs to collect from the user. + /// One of `currently_due` or `eventually_due`. + /// Default is `currently_due`. #[serde(skip_serializing_if = "Option::is_none")] pub collect: Option<CreateAccountLinkCollect>, - /// Specifies the requirements that Stripe collects from connected accounts in the Connect Onboarding flow. - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_options: Option<CreateAccountLinkCollectionOptions>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -21,23 +20,17 @@ pub struct CreateAccountLink<'a> { pub return_url: Option<&'a str>, /// The type of account link the user is requesting. /// Possible values are `account_onboarding` or `account_update`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateAccountLinkType, } impl<'a> CreateAccountLink<'a> { pub fn new(account: &'a str, type_: CreateAccountLinkType) -> Self { - Self { - account, - collect: None, - collection_options: None, - expand: None, - refresh_url: None, - return_url: None, - type_, - } + Self { account, collect: None, expand: None, refresh_url: None, return_url: None, type_ } } } -/// The collect parameter is deprecated. Use `collection_options` instead. +/// Which information the platform needs to collect from the user. +/// One of `currently_due` or `eventually_due`. +/// Default is `currently_due`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateAccountLinkCollect { CurrentlyDue, @@ -83,116 +76,6 @@ impl serde::Serialize for CreateAccountLinkCollect { serializer.serialize_str(self.as_str()) } } -/// Specifies the requirements that Stripe collects from connected accounts in the Connect Onboarding flow. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateAccountLinkCollectionOptions { - /// Specifies whether the platform collects only currently_due requirements (`currently_due`) or both currently_due and eventually_due requirements (`eventually_due`). - /// If you don't specify `collection_options`, the default value is `currently_due`. - pub fields: CreateAccountLinkCollectionOptionsFields, - /// Specifies whether the platform collects future_requirements in addition to requirements in Connect Onboarding. - /// The default value is `omit`. - #[serde(skip_serializing_if = "Option::is_none")] - pub future_requirements: Option<CreateAccountLinkCollectionOptionsFutureRequirements>, -} -impl CreateAccountLinkCollectionOptions { - pub fn new(fields: CreateAccountLinkCollectionOptionsFields) -> Self { - Self { fields, future_requirements: None } - } -} -/// Specifies whether the platform collects only currently_due requirements (`currently_due`) or both currently_due and eventually_due requirements (`eventually_due`). -/// If you don't specify `collection_options`, the default value is `currently_due`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateAccountLinkCollectionOptionsFields { - CurrentlyDue, - EventuallyDue, -} -impl CreateAccountLinkCollectionOptionsFields { - pub fn as_str(self) -> &'static str { - use CreateAccountLinkCollectionOptionsFields::*; - match self { - CurrentlyDue => "currently_due", - EventuallyDue => "eventually_due", - } - } -} - -impl std::str::FromStr for CreateAccountLinkCollectionOptionsFields { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateAccountLinkCollectionOptionsFields::*; - match s { - "currently_due" => Ok(CurrentlyDue), - "eventually_due" => Ok(EventuallyDue), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateAccountLinkCollectionOptionsFields { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateAccountLinkCollectionOptionsFields { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateAccountLinkCollectionOptionsFields { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Specifies whether the platform collects future_requirements in addition to requirements in Connect Onboarding. -/// The default value is `omit`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateAccountLinkCollectionOptionsFutureRequirements { - Include, - Omit, -} -impl CreateAccountLinkCollectionOptionsFutureRequirements { - pub fn as_str(self) -> &'static str { - use CreateAccountLinkCollectionOptionsFutureRequirements::*; - match self { - Include => "include", - Omit => "omit", - } - } -} - -impl std::str::FromStr for CreateAccountLinkCollectionOptionsFutureRequirements { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateAccountLinkCollectionOptionsFutureRequirements::*; - match s { - "include" => Ok(Include), - "omit" => Ok(Omit), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateAccountLinkCollectionOptionsFutureRequirements { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateAccountLinkCollectionOptionsFutureRequirements { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateAccountLinkCollectionOptionsFutureRequirements { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// The type of account link the user is requesting. /// Possible values are `account_onboarding` or `account_update`. #[derive(Copy, Clone, Eq, PartialEq)] diff --git a/generated/stripe_connect/src/account_link/types.rs b/generated/stripe_connect/src/account_link/types.rs index 1ffdeab70..9e3e5c868 100644 --- a/generated/stripe_connect/src/account_link/types.rs +++ b/generated/stripe_connect/src/account_link/types.rs @@ -4,7 +4,9 @@ /// Related guide: [Connect Onboarding](https://stripe.com/docs/connect/custom/hosted-onboarding) /// /// For more details see <<https://stripe.com/docs/api/account_links/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountLink { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -13,3 +15,97 @@ pub struct AccountLink { /// The URL for the account link. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct AccountLinkBuilder { + created: Option<stripe_types::Timestamp>, + expires_at: Option<stripe_types::Timestamp>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountLink>, + builder: AccountLinkBuilder, + } + + impl Visitor for Place<AccountLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountLinkBuilder { + type Out = AccountLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { created: Deserialize::default(), expires_at: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let expires_at = self.expires_at.take()?; + let url = self.url.take()?; + + Some(Self::Out { created, expires_at, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountLink { + type Builder = AccountLinkBuilder; + } + + impl FromValueOpt for AccountLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/account_session/requests.rs b/generated/stripe_connect/src/account_session/requests.rs index 1cee91316..2cf3c5986 100644 --- a/generated/stripe_connect/src/account_session/requests.rs +++ b/generated/stripe_connect/src/account_session/requests.rs @@ -4,124 +4,43 @@ pub struct CreateAccountSession<'a> { pub account: &'a str, /// Each key of the dictionary represents an embedded component, and each embedded component maps to its configuration (e.g. /// whether it has been enabled or not). - pub components: CreateAccountSessionComponents<'a>, + pub components: CreateAccountSessionComponents, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } impl<'a> CreateAccountSession<'a> { - pub fn new(account: &'a str, components: CreateAccountSessionComponents<'a>) -> Self { + pub fn new(account: &'a str, components: CreateAccountSessionComponents) -> Self { Self { account, components, expand: None } } } /// Each key of the dictionary represents an embedded component, and each embedded component maps to its configuration (e.g. /// whether it has been enabled or not). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountSessionComponents<'a> { +pub struct CreateAccountSessionComponents { /// Configuration for the account onboarding embedded component. #[serde(skip_serializing_if = "Option::is_none")] - pub account_onboarding: Option<CreateAccountSessionComponentsAccountOnboarding<'a>>, - /// Configuration for the payment details embedded component. - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_details: Option<PaymentsConfigParam>, - /// Configuration for the payments embedded component. - #[serde(skip_serializing_if = "Option::is_none")] - pub payments: Option<PaymentsConfigParam>, - /// Configuration for the payouts embedded component. - #[serde(skip_serializing_if = "Option::is_none")] - pub payouts: Option<CreateAccountSessionComponentsPayouts>, + pub account_onboarding: Option<CreateAccountSessionComponentsAccountOnboarding>, } -impl<'a> CreateAccountSessionComponents<'a> { +impl CreateAccountSessionComponents { pub fn new() -> Self { Self::default() } } /// Configuration for the account onboarding embedded component. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateAccountSessionComponentsAccountOnboarding<'a> { +pub struct CreateAccountSessionComponentsAccountOnboarding { /// Whether the embedded component is enabled. pub enabled: bool, - /// The list of features enabled in the embedded component. - #[serde(skip_serializing_if = "Option::is_none")] - pub features: Option<&'a serde_json::Value>, } -impl<'a> CreateAccountSessionComponentsAccountOnboarding<'a> { +impl CreateAccountSessionComponentsAccountOnboarding { pub fn new(enabled: bool) -> Self { - Self { enabled, features: None } - } -} -/// Configuration for the payouts embedded component. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateAccountSessionComponentsPayouts { - /// Whether the embedded component is enabled. - pub enabled: bool, - /// The list of features enabled in the embedded component. - #[serde(skip_serializing_if = "Option::is_none")] - pub features: Option<CreateAccountSessionComponentsPayoutsFeatures>, -} -impl CreateAccountSessionComponentsPayouts { - pub fn new(enabled: bool) -> Self { - Self { enabled, features: None } - } -} -/// The list of features enabled in the embedded component. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateAccountSessionComponentsPayoutsFeatures { - /// Whether to allow payout schedule to be changed. - /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. - #[serde(skip_serializing_if = "Option::is_none")] - pub edit_payout_schedule: Option<bool>, - /// Whether to allow creation of instant payouts. - /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. - #[serde(skip_serializing_if = "Option::is_none")] - pub instant_payouts: Option<bool>, - /// Whether to allow creation of standard payouts. - /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. - #[serde(skip_serializing_if = "Option::is_none")] - pub standard_payouts: Option<bool>, -} -impl CreateAccountSessionComponentsPayoutsFeatures { - pub fn new() -> Self { - Self::default() + Self { enabled } } } impl<'a> CreateAccountSession<'a> { /// Creates a AccountSession object that includes a single-use token that the platform can use on their front-end to grant client-side API access. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_connect::AccountSession> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_connect::AccountSession> { client.send_form("/account_sessions", self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct PaymentsFeaturesParam { - /// Whether to allow capturing and cancelling payment intents. This is `true` by default. - #[serde(skip_serializing_if = "Option::is_none")] - pub capture_payments: Option<bool>, - /// Whether to allow responding to disputes, including submitting evidence and accepting disputes. - /// This is `true` by default. - #[serde(skip_serializing_if = "Option::is_none")] - pub dispute_management: Option<bool>, - /// Whether to allow sending refunds. This is `true` by default. - #[serde(skip_serializing_if = "Option::is_none")] - pub refund_management: Option<bool>, -} -impl PaymentsFeaturesParam { - pub fn new() -> Self { - Self::default() - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct PaymentsConfigParam { - /// Whether the embedded component is enabled. - pub enabled: bool, - /// The list of features enabled in the embedded component. - #[serde(skip_serializing_if = "Option::is_none")] - pub features: Option<PaymentsFeaturesParam>, -} -impl PaymentsConfigParam { - pub fn new(enabled: bool) -> Self { - Self { enabled, features: None } - } -} diff --git a/generated/stripe_connect/src/account_session/types.rs b/generated/stripe_connect/src/account_session/types.rs index d52d57633..3ebd02454 100644 --- a/generated/stripe_connect/src/account_session/types.rs +++ b/generated/stripe_connect/src/account_session/types.rs @@ -7,7 +7,9 @@ /// Related guide: [Connect embedded components](https://stripe.com/docs/connect/get-started-connect-embedded-components). /// /// For more details see <<https://stripe.com/docs/api/account_sessions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountSession { /// The ID of the account the AccountSession was created for pub account: String, @@ -26,3 +28,105 @@ pub struct AccountSession { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, } +#[cfg(feature = "min-ser")] +pub struct AccountSessionBuilder { + account: Option<String>, + client_secret: Option<String>, + components: Option<stripe_connect::ConnectEmbeddedAccountSessionCreateComponents>, + expires_at: Option<stripe_types::Timestamp>, + livemode: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountSession { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountSession>, + builder: AccountSessionBuilder, + } + + impl Visitor for Place<AccountSession> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountSessionBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountSessionBuilder { + type Out = AccountSession; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "client_secret" => Deserialize::begin(&mut self.client_secret), + "components" => Deserialize::begin(&mut self.components), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "livemode" => Deserialize::begin(&mut self.livemode), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account: Deserialize::default(), client_secret: Deserialize::default(), components: Deserialize::default(), expires_at: Deserialize::default(), livemode: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let client_secret = self.client_secret.take()?; + let components = self.components.take()?; + let expires_at = self.expires_at.take()?; + let livemode = self.livemode.take()?; + + Some(Self::Out { account, client_secret, components, expires_at, livemode }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountSession { + type Builder = AccountSessionBuilder; + } + + impl FromValueOpt for AccountSession { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountSessionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "components" => b.components = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/application_fee/requests.rs b/generated/stripe_connect/src/application_fee/requests.rs index fd0430123..9a16d3ef0 100644 --- a/generated/stripe_connect/src/application_fee/requests.rs +++ b/generated/stripe_connect/src/application_fee/requests.rs @@ -31,15 +31,10 @@ impl<'a> ListApplicationFee<'a> { impl<'a> ListApplicationFee<'a> { /// Returns a list of application fees you’ve previously collected. /// The application fees are returned in sorted order, with the most recent fees appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::ApplicationFee>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::ApplicationFee>> { client.get_query("/application_fees", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ApplicationFee>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ApplicationFee>> { stripe::ListPaginator::from_list_params("/application_fees", self) } } @@ -57,11 +52,7 @@ impl<'a> RetrieveApplicationFee<'a> { impl<'a> RetrieveApplicationFee<'a> { /// Retrieves the details of an application fee that your account has collected. /// The same information is returned when refunding the application fee. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::ApplicationFeeId, - ) -> stripe::Response<stripe_shared::ApplicationFee> { + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::ApplicationFeeId) -> stripe::Response<stripe_shared::ApplicationFee> { client.get_query(&format!("/application_fees/{id}"), self) } } diff --git a/generated/stripe_connect/src/application_fee_refund/requests.rs b/generated/stripe_connect/src/application_fee_refund/requests.rs index 116188b58..9147c6b4e 100644 --- a/generated/stripe_connect/src/application_fee_refund/requests.rs +++ b/generated/stripe_connect/src/application_fee_refund/requests.rs @@ -1,23 +1,36 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveApplicationFeeRefund<'a> { +pub struct CreateIdApplicationFeeRefund<'a> { + /// A positive integer, in _cents (or local equivalent)_, representing how much of this fee to refund. + /// Can refund only up to the remaining unrefunded amount of the fee. + #[serde(skip_serializing_if = "Option::is_none")] + pub amount: Option<i64>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, } -impl<'a> RetrieveApplicationFeeRefund<'a> { +impl<'a> CreateIdApplicationFeeRefund<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> RetrieveApplicationFeeRefund<'a> { - /// By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee. - pub fn send( - &self, - client: &stripe::Client, - fee: &stripe_shared::ApplicationFeeId, - id: &str, - ) -> stripe::Response<stripe_shared::ApplicationFeeRefund> { - client.get_query(&format!("/application_fees/{fee}/refunds/{id}"), self) +impl<'a> CreateIdApplicationFeeRefund<'a> { + /// Refunds an application fee that has previously been collected but not yet refunded. + /// Funds will be refunded to the Stripe account from which the fee was originally collected. + /// + /// You can optionally refund only part of an application fee. + /// You can do so multiple times, until the entire fee has been refunded. + /// + /// Once entirely refunded, an application fee can’t be refunded again. + /// This method will raise an error when called on an already-refunded application fee, + /// or when trying to refund more money than is left on an application fee. + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::ApplicationFeeId) -> stripe::Response<stripe_shared::ApplicationFeeRefund> { + client.send_form(&format!("/application_fees/{id}/refunds"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -49,61 +62,32 @@ impl<'a> ListIdApplicationFeeRefund<'a> { /// You can see a list of the refunds belonging to a specific application fee. /// Note that the 10 most recent refunds are always available by default on the application fee object. /// If you need more than those 10, you can use this API method and the `limit` and `starting_after` parameters to page through additional refunds. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::ApplicationFeeId, - ) -> stripe::Response<stripe_types::List<stripe_shared::ApplicationFeeRefund>> { + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::ApplicationFeeId) -> stripe::Response<stripe_types::List<stripe_shared::ApplicationFeeRefund>> { client.get_query(&format!("/application_fees/{id}/refunds"), self) } - pub fn paginate( - self, - id: &stripe_shared::ApplicationFeeId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ApplicationFeeRefund>> { + pub fn paginate(self, id: &stripe_shared::ApplicationFeeId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ApplicationFeeRefund>> { stripe::ListPaginator::from_list_params(&format!("/application_fees/{id}/refunds"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateApplicationFeeRefund<'a> { +pub struct RetrieveApplicationFeeRefund<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, } -impl<'a> UpdateApplicationFeeRefund<'a> { +impl<'a> RetrieveApplicationFeeRefund<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> UpdateApplicationFeeRefund<'a> { - /// Updates the specified application fee refund by setting the values of the parameters passed. - /// Any parameters not provided will be left unchanged. - /// - /// This request only accepts metadata as an argument. - pub fn send( - &self, - client: &stripe::Client, - fee: &stripe_shared::ApplicationFeeId, - id: &str, - ) -> stripe::Response<stripe_shared::ApplicationFeeRefund> { - client.send_form( - &format!("/application_fees/{fee}/refunds/{id}"), - self, - http_types::Method::Post, - ) +impl<'a> RetrieveApplicationFeeRefund<'a> { + /// By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee. + pub fn send(&self, client: &stripe::Client, fee: &stripe_shared::ApplicationFeeId, id: &str) -> stripe::Response<stripe_shared::ApplicationFeeRefund> { + client.get_query(&format!("/application_fees/{fee}/refunds/{id}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateIdApplicationFeeRefund<'a> { - /// A positive integer, in _cents (or local equivalent)_, representing how much of this fee to refund. - /// Can refund only up to the remaining unrefunded amount of the fee. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option<i64>, +pub struct UpdateApplicationFeeRefund<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -114,26 +98,17 @@ pub struct CreateIdApplicationFeeRefund<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap<String, String>>, } -impl<'a> CreateIdApplicationFeeRefund<'a> { +impl<'a> UpdateApplicationFeeRefund<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> CreateIdApplicationFeeRefund<'a> { - /// Refunds an application fee that has previously been collected but not yet refunded. - /// Funds will be refunded to the Stripe account from which the fee was originally collected. - /// - /// You can optionally refund only part of an application fee. - /// You can do so multiple times, until the entire fee has been refunded. +impl<'a> UpdateApplicationFeeRefund<'a> { + /// Updates the specified application fee refund by setting the values of the parameters passed. + /// Any parameters not provided will be left unchanged. /// - /// Once entirely refunded, an application fee can’t be refunded again. - /// This method will raise an error when called on an already-refunded application fee, - /// or when trying to refund more money than is left on an application fee. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::ApplicationFeeId, - ) -> stripe::Response<stripe_shared::ApplicationFeeRefund> { - client.send_form(&format!("/application_fees/{id}/refunds"), self, http_types::Method::Post) + /// This request only accepts metadata as an argument. + pub fn send(&self, client: &stripe::Client, fee: &stripe_shared::ApplicationFeeId, id: &str) -> stripe::Response<stripe_shared::ApplicationFeeRefund> { + client.send_form(&format!("/application_fees/{fee}/refunds/{id}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_connect/src/apps_secret/requests.rs b/generated/stripe_connect/src/apps_secret/requests.rs index b07f8cc58..49fc05384 100644 --- a/generated/stripe_connect/src/apps_secret/requests.rs +++ b/generated/stripe_connect/src/apps_secret/requests.rs @@ -1,107 +1,4 @@ #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ListAppsSecret<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// Specifies the scoping of the secret. - /// Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user. - pub scope: ListAppsSecretScope<'a>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListAppsSecret<'a> { - pub fn new(scope: ListAppsSecretScope<'a>) -> Self { - Self { ending_before: None, expand: None, limit: None, scope, starting_after: None } - } -} -/// Specifies the scoping of the secret. -/// Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ListAppsSecretScope<'a> { - /// The secret scope type. - #[serde(rename = "type")] - pub type_: ListAppsSecretScopeType, - /// The user ID. - /// This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub user: Option<&'a str>, -} -impl<'a> ListAppsSecretScope<'a> { - pub fn new(type_: ListAppsSecretScopeType) -> Self { - Self { type_, user: None } - } -} -/// The secret scope type. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ListAppsSecretScopeType { - Account, - User, -} -impl ListAppsSecretScopeType { - pub fn as_str(self) -> &'static str { - use ListAppsSecretScopeType::*; - match self { - Account => "account", - User => "user", - } - } -} - -impl std::str::FromStr for ListAppsSecretScopeType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ListAppsSecretScopeType::*; - match s { - "account" => Ok(Account), - "user" => Ok(User), - _ => Err(()), - } - } -} -impl std::fmt::Display for ListAppsSecretScopeType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ListAppsSecretScopeType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ListAppsSecretScopeType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> ListAppsSecret<'a> { - /// List all secrets stored on the given scope. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_connect::AppsSecret>> { - client.get_query("/apps/secrets", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_connect::AppsSecret>> { - stripe::ListPaginator::from_list_params("/apps/secrets", self) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] pub struct FindAppsSecret<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -122,7 +19,7 @@ impl<'a> FindAppsSecret<'a> { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct FindAppsSecretScope<'a> { /// The secret scope type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: FindAppsSecretScopeType, /// The user ID. /// This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`. @@ -212,7 +109,7 @@ impl<'a> CreateAppsSecret<'a> { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateAppsSecretScope<'a> { /// The secret scope type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateAppsSecretScopeType, /// The user ID. /// This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`. @@ -297,7 +194,7 @@ impl<'a> DeleteWhereAppsSecret<'a> { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct DeleteWhereAppsSecretScope<'a> { /// The secret scope type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: DeleteWhereAppsSecretScopeType, /// The user ID. /// This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`. @@ -361,3 +258,103 @@ impl<'a> DeleteWhereAppsSecret<'a> { client.send_form("/apps/secrets/delete", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct ListAppsSecret<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// Specifies the scoping of the secret. + /// Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user. + pub scope: ListAppsSecretScope<'a>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListAppsSecret<'a> { + pub fn new(scope: ListAppsSecretScope<'a>) -> Self { + Self { ending_before: None, expand: None, limit: None, scope, starting_after: None } + } +} +/// Specifies the scoping of the secret. +/// Requests originating from UI extensions can only access account-scoped secrets or secrets scoped to their own user. +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct ListAppsSecretScope<'a> { + /// The secret scope type. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: ListAppsSecretScopeType, + /// The user ID. + /// This field is required if `type` is set to `user`, and should not be provided if `type` is set to `account`. + #[serde(skip_serializing_if = "Option::is_none")] + pub user: Option<&'a str>, +} +impl<'a> ListAppsSecretScope<'a> { + pub fn new(type_: ListAppsSecretScopeType) -> Self { + Self { type_, user: None } + } +} +/// The secret scope type. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ListAppsSecretScopeType { + Account, + User, +} +impl ListAppsSecretScopeType { + pub fn as_str(self) -> &'static str { + use ListAppsSecretScopeType::*; + match self { + Account => "account", + User => "user", + } + } +} + +impl std::str::FromStr for ListAppsSecretScopeType { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use ListAppsSecretScopeType::*; + match s { + "account" => Ok(Account), + "user" => Ok(User), + _ => Err(()), + } + } +} +impl std::fmt::Display for ListAppsSecretScopeType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ListAppsSecretScopeType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for ListAppsSecretScopeType { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> ListAppsSecret<'a> { + /// List all secrets stored on the given scope. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_connect::AppsSecret>> { + client.get_query("/apps/secrets", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_connect::AppsSecret>> { + stripe::ListPaginator::from_list_params("/apps/secrets", self) + } +} diff --git a/generated/stripe_connect/src/apps_secret/types.rs b/generated/stripe_connect/src/apps_secret/types.rs index 968c90e49..fae6cebdf 100644 --- a/generated/stripe_connect/src/apps_secret/types.rs +++ b/generated/stripe_connect/src/apps_secret/types.rs @@ -11,12 +11,13 @@ /// Use the `user` scope for per-user secrets like per-user OAuth tokens, where different users might have different permissions. /// /// Related guide: [Store data between page reloads](https://stripe.com/docs/stripe-apps/store-auth-data-custom-objects). -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AppsSecret { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// If true, indicates that this secret has been deleted - #[serde(skip_serializing_if = "Option::is_none")] pub deleted: Option<bool>, /// The Unix timestamp for the expiry time of the secret, after which the secret deletes. pub expires_at: Option<stripe_types::Timestamp>, @@ -30,6 +31,129 @@ pub struct AppsSecret { pub payload: Option<String>, pub scope: stripe_connect::SecretServiceResourceScope, } +#[cfg(feature = "min-ser")] +pub struct AppsSecretBuilder { + created: Option<stripe_types::Timestamp>, + deleted: Option<Option<bool>>, + expires_at: Option<Option<stripe_types::Timestamp>>, + id: Option<stripe_connect::AppsSecretId>, + livemode: Option<bool>, + name: Option<String>, + payload: Option<Option<String>>, + scope: Option<stripe_connect::SecretServiceResourceScope>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AppsSecret { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AppsSecret>, + builder: AppsSecretBuilder, + } + + impl Visitor for Place<AppsSecret> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AppsSecretBuilder::deser_default() })) + } + } + + impl MapBuilder for AppsSecretBuilder { + type Out = AppsSecret; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "deleted" => Deserialize::begin(&mut self.deleted), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "name" => Deserialize::begin(&mut self.name), + "payload" => Deserialize::begin(&mut self.payload), + "scope" => Deserialize::begin(&mut self.scope), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + deleted: Deserialize::default(), + expires_at: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + name: Deserialize::default(), + payload: Deserialize::default(), + scope: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let deleted = self.deleted.take()?; + let expires_at = self.expires_at.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let name = self.name.take()?; + let payload = self.payload.take()?; + let scope = self.scope.take()?; + + Some(Self::Out { created, deleted, expires_at, id, livemode, name, payload, scope }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AppsSecret { + type Builder = AppsSecretBuilder; + } + + impl FromValueOpt for AppsSecret { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AppsSecretBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "payload" => b.payload = Some(FromValueOpt::from_value(v)?), + "scope" => b.scope = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for AppsSecret { type Id = stripe_connect::AppsSecretId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_connect/src/capability/requests.rs b/generated/stripe_connect/src/capability/requests.rs index f7e1496d2..1a1861fbb 100644 --- a/generated/stripe_connect/src/capability/requests.rs +++ b/generated/stripe_connect/src/capability/requests.rs @@ -12,17 +12,10 @@ impl<'a> ListAccountCapability<'a> { impl<'a> ListAccountCapability<'a> { /// Returns a list of capabilities associated with the account. /// The capabilities are returned sorted by creation date, with the most recent capability appearing first. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_types::List<stripe_shared::Capability>> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_types::List<stripe_shared::Capability>> { client.get_query(&format!("/accounts/{account}/capabilities"), self) } - pub fn paginate( - self, - account: &stripe_shared::AccountId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Capability>> { + pub fn paginate(self, account: &stripe_shared::AccountId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Capability>> { stripe::ListPaginator::from_list_params(&format!("/accounts/{account}/capabilities"), self) } } @@ -39,12 +32,7 @@ impl<'a> RetrieveCapability<'a> { } impl<'a> RetrieveCapability<'a> { /// Retrieves information about the specified Account Capability. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - capability: &str, - ) -> stripe::Response<stripe_shared::Capability> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, capability: &str) -> stripe::Response<stripe_shared::Capability> { client.get_query(&format!("/accounts/{account}/capabilities/{capability}"), self) } } @@ -71,16 +59,7 @@ impl<'a> UpdateCapability<'a> { impl<'a> UpdateCapability<'a> { /// Updates an existing Account Capability. /// Request or remove a capability by updating its `requested` parameter. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - capability: &str, - ) -> stripe::Response<stripe_shared::Capability> { - client.send_form( - &format!("/accounts/{account}/capabilities/{capability}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, capability: &str) -> stripe::Response<stripe_shared::Capability> { + client.send_form(&format!("/accounts/{account}/capabilities/{capability}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_connect/src/connect_embedded_account_session_create_components.rs b/generated/stripe_connect/src/connect_embedded_account_session_create_components.rs index ff3f3181d..b07e62055 100644 --- a/generated/stripe_connect/src/connect_embedded_account_session_create_components.rs +++ b/generated/stripe_connect/src/connect_embedded_account_session_create_components.rs @@ -1,7 +1,92 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ConnectEmbeddedAccountSessionCreateComponents { pub account_onboarding: stripe_connect::ConnectEmbeddedBaseConfigClaim, - pub payment_details: stripe_connect::ConnectEmbeddedPaymentsConfig, - pub payments: stripe_connect::ConnectEmbeddedPaymentsConfig, - pub payouts: stripe_connect::ConnectEmbeddedPayoutsConfig, } +#[cfg(feature = "min-ser")] +pub struct ConnectEmbeddedAccountSessionCreateComponentsBuilder { + account_onboarding: Option<stripe_connect::ConnectEmbeddedBaseConfigClaim>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectEmbeddedAccountSessionCreateComponents { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ConnectEmbeddedAccountSessionCreateComponents>, + builder: ConnectEmbeddedAccountSessionCreateComponentsBuilder, + } + + impl Visitor for Place<ConnectEmbeddedAccountSessionCreateComponents> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ConnectEmbeddedAccountSessionCreateComponentsBuilder::deser_default() })) + } + } + + impl MapBuilder for ConnectEmbeddedAccountSessionCreateComponentsBuilder { + type Out = ConnectEmbeddedAccountSessionCreateComponents; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_onboarding" => Deserialize::begin(&mut self.account_onboarding), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_onboarding: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_onboarding = self.account_onboarding.take()?; + + Some(Self::Out { account_onboarding }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ConnectEmbeddedAccountSessionCreateComponents { + type Builder = ConnectEmbeddedAccountSessionCreateComponentsBuilder; + } + + impl FromValueOpt for ConnectEmbeddedAccountSessionCreateComponents { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectEmbeddedAccountSessionCreateComponentsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_onboarding" => b.account_onboarding = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/connect_embedded_base_config_claim.rs b/generated/stripe_connect/src/connect_embedded_base_config_claim.rs index 19818fc01..6b286f499 100644 --- a/generated/stripe_connect/src/connect_embedded_base_config_claim.rs +++ b/generated/stripe_connect/src/connect_embedded_base_config_claim.rs @@ -1,6 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ConnectEmbeddedBaseConfigClaim { /// Whether the embedded component is enabled. pub enabled: bool, - pub features: stripe_connect::ConnectEmbeddedBaseFeatures, } +#[cfg(feature = "min-ser")] +pub struct ConnectEmbeddedBaseConfigClaimBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectEmbeddedBaseConfigClaim { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ConnectEmbeddedBaseConfigClaim>, + builder: ConnectEmbeddedBaseConfigClaimBuilder, + } + + impl Visitor for Place<ConnectEmbeddedBaseConfigClaim> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ConnectEmbeddedBaseConfigClaimBuilder::deser_default() })) + } + } + + impl MapBuilder for ConnectEmbeddedBaseConfigClaimBuilder { + type Out = ConnectEmbeddedBaseConfigClaim; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ConnectEmbeddedBaseConfigClaim { + type Builder = ConnectEmbeddedBaseConfigClaimBuilder; + } + + impl FromValueOpt for ConnectEmbeddedBaseConfigClaim { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectEmbeddedBaseConfigClaimBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/connect_embedded_base_features.rs b/generated/stripe_connect/src/connect_embedded_base_features.rs deleted file mode 100644 index ed9dae237..000000000 --- a/generated/stripe_connect/src/connect_embedded_base_features.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct ConnectEmbeddedBaseFeatures {} diff --git a/generated/stripe_connect/src/connect_embedded_payments_config.rs b/generated/stripe_connect/src/connect_embedded_payments_config.rs deleted file mode 100644 index 9279b697d..000000000 --- a/generated/stripe_connect/src/connect_embedded_payments_config.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ConnectEmbeddedPaymentsConfig { - /// Whether the embedded component is enabled. - pub enabled: bool, - pub features: stripe_connect::ConnectEmbeddedPaymentsFeatures, -} diff --git a/generated/stripe_connect/src/connect_embedded_payments_features.rs b/generated/stripe_connect/src/connect_embedded_payments_features.rs deleted file mode 100644 index 7f5bc6721..000000000 --- a/generated/stripe_connect/src/connect_embedded_payments_features.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ConnectEmbeddedPaymentsFeatures { - /// Whether to allow capturing and cancelling payment intents. This is `true` by default. - pub capture_payments: bool, - /// Whether to allow responding to disputes, including submitting evidence and accepting disputes. - /// This is `true` by default. - pub dispute_management: bool, - /// Whether to allow sending refunds. This is `true` by default. - pub refund_management: bool, -} diff --git a/generated/stripe_connect/src/connect_embedded_payouts_config.rs b/generated/stripe_connect/src/connect_embedded_payouts_config.rs deleted file mode 100644 index 7d4856264..000000000 --- a/generated/stripe_connect/src/connect_embedded_payouts_config.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ConnectEmbeddedPayoutsConfig { - /// Whether the embedded component is enabled. - pub enabled: bool, - pub features: stripe_connect::ConnectEmbeddedPayoutsFeatures, -} diff --git a/generated/stripe_connect/src/connect_embedded_payouts_features.rs b/generated/stripe_connect/src/connect_embedded_payouts_features.rs deleted file mode 100644 index 0384aa102..000000000 --- a/generated/stripe_connect/src/connect_embedded_payouts_features.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ConnectEmbeddedPayoutsFeatures { - /// Whether to allow payout schedule to be changed. - /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. - pub edit_payout_schedule: bool, - /// Whether to allow creation of instant payouts. - /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. - pub instant_payouts: bool, - /// Whether to allow creation of standard payouts. - /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. - pub standard_payouts: bool, -} diff --git a/generated/stripe_connect/src/country_spec/requests.rs b/generated/stripe_connect/src/country_spec/requests.rs index 2bf2b8251..96ae9ed21 100644 --- a/generated/stripe_connect/src/country_spec/requests.rs +++ b/generated/stripe_connect/src/country_spec/requests.rs @@ -25,15 +25,10 @@ impl<'a> ListCountrySpec<'a> { } impl<'a> ListCountrySpec<'a> { /// Lists all Country Spec objects available in the API. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_connect::CountrySpec>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_connect::CountrySpec>> { client.get_query("/country_specs", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_connect::CountrySpec>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_connect::CountrySpec>> { stripe::ListPaginator::from_list_params("/country_specs", self) } } @@ -50,11 +45,7 @@ impl<'a> RetrieveCountrySpec<'a> { } impl<'a> RetrieveCountrySpec<'a> { /// Returns a Country Spec for a given Country code. - pub fn send( - &self, - client: &stripe::Client, - country: &stripe_connect::CountrySpecId, - ) -> stripe::Response<stripe_connect::CountrySpec> { + pub fn send(&self, client: &stripe::Client, country: &stripe_connect::CountrySpecId) -> stripe::Response<stripe_connect::CountrySpec> { client.get_query(&format!("/country_specs/{country}"), self) } } diff --git a/generated/stripe_connect/src/country_spec/types.rs b/generated/stripe_connect/src/country_spec/types.rs index fb37dd7fa..84c471413 100644 --- a/generated/stripe_connect/src/country_spec/types.rs +++ b/generated/stripe_connect/src/country_spec/types.rs @@ -6,7 +6,9 @@ /// guide](/docs/connect/required-verification-information). /// /// For more details see <<https://stripe.com/docs/api/country_specs/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CountrySpec { /// The default currency for this country. This applies to both payment methods and bank accounts. pub default_currency: stripe_types::Currency, @@ -24,6 +26,124 @@ pub struct CountrySpec { pub supported_transfer_countries: Vec<String>, pub verification_fields: stripe_connect::CountrySpecVerificationFields, } +#[cfg(feature = "min-ser")] +pub struct CountrySpecBuilder { + default_currency: Option<stripe_types::Currency>, + id: Option<stripe_connect::CountrySpecId>, + supported_bank_account_currencies: Option<std::collections::HashMap<String, Vec<String>>>, + supported_payment_currencies: Option<Vec<String>>, + supported_payment_methods: Option<Vec<String>>, + supported_transfer_countries: Option<Vec<String>>, + verification_fields: Option<stripe_connect::CountrySpecVerificationFields>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CountrySpec { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CountrySpec>, + builder: CountrySpecBuilder, + } + + impl Visitor for Place<CountrySpec> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CountrySpecBuilder::deser_default() })) + } + } + + impl MapBuilder for CountrySpecBuilder { + type Out = CountrySpec; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "default_currency" => Deserialize::begin(&mut self.default_currency), + "id" => Deserialize::begin(&mut self.id), + "supported_bank_account_currencies" => Deserialize::begin(&mut self.supported_bank_account_currencies), + "supported_payment_currencies" => Deserialize::begin(&mut self.supported_payment_currencies), + "supported_payment_methods" => Deserialize::begin(&mut self.supported_payment_methods), + "supported_transfer_countries" => Deserialize::begin(&mut self.supported_transfer_countries), + "verification_fields" => Deserialize::begin(&mut self.verification_fields), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + default_currency: Deserialize::default(), + id: Deserialize::default(), + supported_bank_account_currencies: Deserialize::default(), + supported_payment_currencies: Deserialize::default(), + supported_payment_methods: Deserialize::default(), + supported_transfer_countries: Deserialize::default(), + verification_fields: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let default_currency = self.default_currency.take()?; + let id = self.id.take()?; + let supported_bank_account_currencies = self.supported_bank_account_currencies.take()?; + let supported_payment_currencies = self.supported_payment_currencies.take()?; + let supported_payment_methods = self.supported_payment_methods.take()?; + let supported_transfer_countries = self.supported_transfer_countries.take()?; + let verification_fields = self.verification_fields.take()?; + + Some(Self::Out { default_currency, id, supported_bank_account_currencies, supported_payment_currencies, supported_payment_methods, supported_transfer_countries, verification_fields }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CountrySpec { + type Builder = CountrySpecBuilder; + } + + impl FromValueOpt for CountrySpec { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CountrySpecBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "default_currency" => b.default_currency = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "supported_bank_account_currencies" => b.supported_bank_account_currencies = Some(FromValueOpt::from_value(v)?), + "supported_payment_currencies" => b.supported_payment_currencies = Some(FromValueOpt::from_value(v)?), + "supported_payment_methods" => b.supported_payment_methods = Some(FromValueOpt::from_value(v)?), + "supported_transfer_countries" => b.supported_transfer_countries = Some(FromValueOpt::from_value(v)?), + "verification_fields" => b.verification_fields = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for CountrySpec { type Id = stripe_connect::CountrySpecId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_connect/src/country_spec_verification_field_details.rs b/generated/stripe_connect/src/country_spec_verification_field_details.rs index 1f0195531..831a761ca 100644 --- a/generated/stripe_connect/src/country_spec_verification_field_details.rs +++ b/generated/stripe_connect/src/country_spec_verification_field_details.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CountrySpecVerificationFieldDetails { /// Additional fields which are only required for some users. pub additional: Vec<String>, /// Fields which every account must eventually provide. pub minimum: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct CountrySpecVerificationFieldDetailsBuilder { + additional: Option<Vec<String>>, + minimum: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CountrySpecVerificationFieldDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CountrySpecVerificationFieldDetails>, + builder: CountrySpecVerificationFieldDetailsBuilder, + } + + impl Visitor for Place<CountrySpecVerificationFieldDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CountrySpecVerificationFieldDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for CountrySpecVerificationFieldDetailsBuilder { + type Out = CountrySpecVerificationFieldDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional" => Deserialize::begin(&mut self.additional), + "minimum" => Deserialize::begin(&mut self.minimum), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { additional: Deserialize::default(), minimum: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional = self.additional.take()?; + let minimum = self.minimum.take()?; + + Some(Self::Out { additional, minimum }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CountrySpecVerificationFieldDetails { + type Builder = CountrySpecVerificationFieldDetailsBuilder; + } + + impl FromValueOpt for CountrySpecVerificationFieldDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CountrySpecVerificationFieldDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional" => b.additional = Some(FromValueOpt::from_value(v)?), + "minimum" => b.minimum = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/country_spec_verification_fields.rs b/generated/stripe_connect/src/country_spec_verification_fields.rs index 4fd589811..5aadd6613 100644 --- a/generated/stripe_connect/src/country_spec_verification_fields.rs +++ b/generated/stripe_connect/src/country_spec_verification_fields.rs @@ -1,5 +1,97 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CountrySpecVerificationFields { pub company: stripe_connect::CountrySpecVerificationFieldDetails, pub individual: stripe_connect::CountrySpecVerificationFieldDetails, } +#[cfg(feature = "min-ser")] +pub struct CountrySpecVerificationFieldsBuilder { + company: Option<stripe_connect::CountrySpecVerificationFieldDetails>, + individual: Option<stripe_connect::CountrySpecVerificationFieldDetails>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CountrySpecVerificationFields { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CountrySpecVerificationFields>, + builder: CountrySpecVerificationFieldsBuilder, + } + + impl Visitor for Place<CountrySpecVerificationFields> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CountrySpecVerificationFieldsBuilder::deser_default() })) + } + } + + impl MapBuilder for CountrySpecVerificationFieldsBuilder { + type Out = CountrySpecVerificationFields; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "company" => Deserialize::begin(&mut self.company), + "individual" => Deserialize::begin(&mut self.individual), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { company: Deserialize::default(), individual: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let company = self.company.take()?; + let individual = self.individual.take()?; + + Some(Self::Out { company, individual }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CountrySpecVerificationFields { + type Builder = CountrySpecVerificationFieldsBuilder; + } + + impl FromValueOpt for CountrySpecVerificationFields { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CountrySpecVerificationFieldsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "company" => b.company = Some(FromValueOpt::from_value(v)?), + "individual" => b.individual = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/external_account/requests.rs b/generated/stripe_connect/src/external_account/requests.rs index b11194fdd..a48ea8164 100644 --- a/generated/stripe_connect/src/external_account/requests.rs +++ b/generated/stripe_connect/src/external_account/requests.rs @@ -1,26 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteExternalAccount {} -impl DeleteExternalAccount { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteExternalAccount { - /// Delete a specified external account for a given account. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - id: &str, - ) -> stripe::Response<stripe_shared::DeletedExternalAccount> { - client.send_form( - &format!("/accounts/{account}/external_accounts/{id}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListAccountExternalAccount<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -96,21 +74,11 @@ impl serde::Serialize for ListAccountExternalAccountObject { } impl<'a> ListAccountExternalAccount<'a> { /// List external accounts for an account. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_types::List<stripe_shared::ExternalAccount>> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_types::List<stripe_shared::ExternalAccount>> { client.get_query(&format!("/accounts/{account}/external_accounts"), self) } - pub fn paginate( - self, - account: &stripe_shared::AccountId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ExternalAccount>> { - stripe::ListPaginator::from_list_params( - &format!("/accounts/{account}/external_accounts"), - self, - ) + pub fn paginate(self, account: &stripe_shared::AccountId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ExternalAccount>> { + stripe::ListPaginator::from_list_params(&format!("/accounts/{account}/external_accounts"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -126,12 +94,7 @@ impl<'a> RetrieveExternalAccount<'a> { } impl<'a> RetrieveExternalAccount<'a> { /// Retrieve a specified external account for a given account. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - id: &str, - ) -> stripe::Response<stripe_shared::ExternalAccount> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, id: &str) -> stripe::Response<stripe_shared::ExternalAccount> { client.get_query(&format!("/accounts/{account}/external_accounts/{id}"), self) } } @@ -159,16 +122,8 @@ impl<'a> CreateAccountExternalAccount<'a> { } impl<'a> CreateAccountExternalAccount<'a> { /// Create an external account for a given account. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_shared::ExternalAccount> { - client.send_form( - &format!("/accounts/{account}/external_accounts"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_shared::ExternalAccount> { + client.send_form(&format!("/accounts/{account}/external_accounts"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -338,8 +293,7 @@ pub struct UpdateExternalAccountDocuments<'a> { /// One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement. /// Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a voided check. #[serde(skip_serializing_if = "Option::is_none")] - pub bank_account_ownership_verification: - Option<UpdateExternalAccountDocumentsBankAccountOwnershipVerification<'a>>, + pub bank_account_ownership_verification: Option<UpdateExternalAccountDocumentsBankAccountOwnershipVerification<'a>>, } impl<'a> UpdateExternalAccountDocuments<'a> { pub fn new() -> Self { @@ -364,16 +318,20 @@ impl<'a> UpdateExternalAccount<'a> { /// Other bank account details are not editable by design. /// /// You can re-enable a disabled bank account by performing an update call without providing any arguments or changes. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - id: &str, - ) -> stripe::Response<stripe_shared::ExternalAccount> { - client.send_form( - &format!("/accounts/{account}/external_accounts/{id}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, id: &str) -> stripe::Response<stripe_shared::ExternalAccount> { + client.send_form(&format!("/accounts/{account}/external_accounts/{id}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteExternalAccount {} +impl DeleteExternalAccount { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteExternalAccount { + /// Delete a specified external account for a given account. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, id: &str) -> stripe::Response<stripe_shared::DeletedExternalAccount> { + client.send_form(&format!("/accounts/{account}/external_accounts/{id}"), self, http_types::Method::Delete) } } diff --git a/generated/stripe_connect/src/login_link/requests.rs b/generated/stripe_connect/src/login_link/requests.rs index 25eb26fac..3ff1734fb 100644 --- a/generated/stripe_connect/src/login_link/requests.rs +++ b/generated/stripe_connect/src/login_link/requests.rs @@ -13,15 +13,7 @@ impl<'a> CreateAccountLoginLink<'a> { /// Creates a single-use login link for an Express account to access their Stripe dashboard. /// /// **You may only create login links for [Express accounts](https://stripe.com/docs/connect/express-accounts) connected to your platform**. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_connect::LoginLink> { - client.send_form( - &format!("/accounts/{account}/login_links"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_connect::LoginLink> { + client.send_form(&format!("/accounts/{account}/login_links"), self, http_types::Method::Post) } } diff --git a/generated/stripe_connect/src/login_link/types.rs b/generated/stripe_connect/src/login_link/types.rs index 6ee359ce8..e5f39d4cf 100644 --- a/generated/stripe_connect/src/login_link/types.rs +++ b/generated/stripe_connect/src/login_link/types.rs @@ -1,10 +1,102 @@ /// Login Links are single-use login link for an Express account to access their Stripe dashboard. /// /// For more details see <<https://stripe.com/docs/api/account/login_link>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LoginLink { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// The URL for the login link. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct LoginLinkBuilder { + created: Option<stripe_types::Timestamp>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LoginLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LoginLink>, + builder: LoginLinkBuilder, + } + + impl Visitor for Place<LoginLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LoginLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for LoginLinkBuilder { + type Out = LoginLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { created: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let url = self.url.take()?; + + Some(Self::Out { created, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LoginLink { + type Builder = LoginLinkBuilder; + } + + impl FromValueOpt for LoginLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LoginLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/mod.rs b/generated/stripe_connect/src/mod.rs index 0a0cc93b8..5632a7c05 100644 --- a/generated/stripe_connect/src/mod.rs +++ b/generated/stripe_connect/src/mod.rs @@ -7,10 +7,12 @@ //! for requests mentioned in the `Connect` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_connect; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub mod account; pub use account_link::types::*; pub use stripe_shared::account::*; -pub use stripe_shared::account_annual_revenue::*; pub use stripe_shared::account_bacs_debit_payments_settings::*; pub use stripe_shared::account_branding_settings::*; pub use stripe_shared::account_business_profile::*; @@ -22,7 +24,6 @@ pub use stripe_shared::account_card_payments_settings::*; pub use stripe_shared::account_dashboard_settings::*; pub use stripe_shared::account_decline_charge_on::*; pub use stripe_shared::account_future_requirements::*; -pub use stripe_shared::account_invoices_settings::*; pub mod account_link; pub use account_session::types::*; pub use stripe_shared::account_monthly_estimated_revenue::*; @@ -45,7 +46,6 @@ pub use stripe_shared::application_fee::*; pub mod apps_secret; pub mod capability; pub use stripe_shared::capability::*; -pub use stripe_shared::connect_account_reference::*; #[doc(hidden)] pub mod connect_embedded_account_session_create_components; #[doc(inline)] @@ -54,26 +54,6 @@ pub use connect_embedded_account_session_create_components::*; pub mod connect_embedded_base_config_claim; #[doc(inline)] pub use connect_embedded_base_config_claim::*; -#[doc(hidden)] -pub mod connect_embedded_base_features; -#[doc(inline)] -pub use connect_embedded_base_features::*; -#[doc(hidden)] -pub mod connect_embedded_payments_config; -#[doc(inline)] -pub use connect_embedded_payments_config::*; -#[doc(hidden)] -pub mod connect_embedded_payments_features; -#[doc(inline)] -pub use connect_embedded_payments_features::*; -#[doc(hidden)] -pub mod connect_embedded_payouts_config; -#[doc(inline)] -pub use connect_embedded_payouts_config::*; -#[doc(hidden)] -pub mod connect_embedded_payouts_features; -#[doc(inline)] -pub use connect_embedded_payouts_features::*; pub use country_spec::types::*; pub mod country_spec; #[doc(hidden)] diff --git a/generated/stripe_connect/src/person/requests.rs b/generated/stripe_connect/src/person/requests.rs index a55101d6e..eb979edf8 100644 --- a/generated/stripe_connect/src/person/requests.rs +++ b/generated/stripe_connect/src/person/requests.rs @@ -1,28 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeletePerson {} -impl DeletePerson { - pub fn new() -> Self { - Self::default() - } -} -impl DeletePerson { - /// Deletes an existing person’s relationship to the account’s legal entity. - /// Any person with a relationship for an account can be deleted through the API, except if the person is the `account_opener`. - /// If your integration is using the `executive` parameter, you cannot delete the only verified `executive` on file. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - person: &str, - ) -> stripe::Response<stripe_shared::DeletedPerson> { - client.send_form( - &format!("/accounts/{account}/persons/{person}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListAccountPerson<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -77,17 +53,10 @@ impl ListAccountPersonRelationship { impl<'a> ListAccountPerson<'a> { /// Returns a list of people associated with the account’s legal entity. /// The people are returned sorted by creation date, with the most recent people appearing first. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_types::List<stripe_shared::Person>> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_types::List<stripe_shared::Person>> { client.get_query(&format!("/accounts/{account}/persons"), self) } - pub fn paginate( - self, - account: &stripe_shared::AccountId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Person>> { + pub fn paginate(self, account: &stripe_shared::AccountId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Person>> { stripe::ListPaginator::from_list_params(&format!("/accounts/{account}/persons"), self) } } @@ -104,12 +73,7 @@ impl<'a> RetrievePerson<'a> { } impl<'a> RetrievePerson<'a> { /// Retrieves an existing person. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - person: &str, - ) -> stripe::Response<stripe_shared::Person> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, person: &str) -> stripe::Response<stripe_shared::Person> { client.get_query(&format!("/accounts/{account}/persons/{person}"), self) } } @@ -275,11 +239,7 @@ impl<'a> CreateAccountPersonAddressKanji<'a> { } impl<'a> CreateAccountPerson<'a> { /// Creates a new person. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - ) -> stripe::Response<stripe_shared::Person> { + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId) -> stripe::Response<stripe_shared::Person> { client.send_form(&format!("/accounts/{account}/persons"), self, http_types::Method::Post) } } @@ -445,17 +405,23 @@ impl<'a> UpdatePersonAddressKanji<'a> { } impl<'a> UpdatePerson<'a> { /// Updates an existing person. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - person: &str, - ) -> stripe::Response<stripe_shared::Person> { - client.send_form( - &format!("/accounts/{account}/persons/{person}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, person: &str) -> stripe::Response<stripe_shared::Person> { + client.send_form(&format!("/accounts/{account}/persons/{person}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeletePerson {} +impl DeletePerson { + pub fn new() -> Self { + Self::default() + } +} +impl DeletePerson { + /// Deletes an existing person’s relationship to the account’s legal entity. + /// Any person with a relationship for an account can be deleted through the API, except if the person is the `account_opener`. + /// If your integration is using the `executive` parameter, you cannot delete the only verified `executive` on file. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, person: &str) -> stripe::Response<stripe_shared::DeletedPerson> { + client.send_form(&format!("/accounts/{account}/persons/{person}"), self, http_types::Method::Delete) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_connect/src/secret_service_resource_scope.rs b/generated/stripe_connect/src/secret_service_resource_scope.rs index 406d9c7de..bb9f6d8f8 100644 --- a/generated/stripe_connect/src/secret_service_resource_scope.rs +++ b/generated/stripe_connect/src/secret_service_resource_scope.rs @@ -1,12 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SecretServiceResourceScope { /// The secret scope type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: SecretServiceResourceScopeType, /// The user ID, if type is set to "user" - #[serde(skip_serializing_if = "Option::is_none")] pub user: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SecretServiceResourceScopeBuilder { + type_: Option<SecretServiceResourceScopeType>, + user: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SecretServiceResourceScope { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SecretServiceResourceScope>, + builder: SecretServiceResourceScopeBuilder, + } + + impl Visitor for Place<SecretServiceResourceScope> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SecretServiceResourceScopeBuilder::deser_default() })) + } + } + + impl MapBuilder for SecretServiceResourceScopeBuilder { + type Out = SecretServiceResourceScope; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "type" => Deserialize::begin(&mut self.type_), + "user" => Deserialize::begin(&mut self.user), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), user: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let type_ = self.type_.take()?; + let user = self.user.take()?; + + Some(Self::Out { type_, user }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SecretServiceResourceScope { + type Builder = SecretServiceResourceScopeBuilder; + } + + impl FromValueOpt for SecretServiceResourceScope { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SecretServiceResourceScopeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "user" => b.user = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The secret scope type. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SecretServiceResourceScopeType { @@ -57,8 +148,24 @@ impl<'de> serde::Deserialize<'de> for SecretServiceResourceScopeType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for SecretServiceResourceScopeType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SecretServiceResourceScopeType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SecretServiceResourceScopeType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SecretServiceResourceScopeType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SecretServiceResourceScopeType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SecretServiceResourceScopeType); diff --git a/generated/stripe_connect/src/topup/requests.rs b/generated/stripe_connect/src/topup/requests.rs index 03f9763fc..68c653320 100644 --- a/generated/stripe_connect/src/topup/requests.rs +++ b/generated/stripe_connect/src/topup/requests.rs @@ -1,3 +1,45 @@ +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct CreateTopup<'a> { + /// A positive integer representing how much to transfer. + pub amount: i64, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + pub currency: stripe_types::Currency, + /// An arbitrary string attached to the object. Often useful for displaying to users. + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// The ID of a source to transfer funds from. + /// For most users, this should be left unspecified which will use the bank account that was set up in the dashboard for the specified currency. + /// In test mode, this can be a test bank token (see [Testing Top-ups](https://stripe.com/docs/connect/testing#testing-top-ups)). + #[serde(skip_serializing_if = "Option::is_none")] + pub source: Option<&'a str>, + /// Extra information about a top-up for the source's bank statement. Limited to 15 ASCII characters. + #[serde(skip_serializing_if = "Option::is_none")] + pub statement_descriptor: Option<&'a str>, + /// A string that identifies this top-up as part of a group. + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_group: Option<&'a str>, +} +impl<'a> CreateTopup<'a> { + pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { + Self { amount, currency, description: None, expand: None, metadata: None, source: None, statement_descriptor: None, transfer_group: None } + } +} +impl<'a> CreateTopup<'a> { + /// Top up the balance of an account + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Topup> { + client.send_form("/topups", self, http_types::Method::Post) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListTopup<'a> { /// A positive integer representing how much to transfer. @@ -89,10 +131,7 @@ impl serde::Serialize for ListTopupStatus { } impl<'a> ListTopup<'a> { /// Returns a list of top-ups. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Topup>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Topup>> { client.get_query("/topups", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Topup>> { @@ -113,65 +152,10 @@ impl<'a> RetrieveTopup<'a> { impl<'a> RetrieveTopup<'a> { /// Retrieves the details of a top-up that has previously been created. /// Supply the unique top-up ID that was returned from your previous request, and Stripe will return the corresponding top-up information. - pub fn send( - &self, - client: &stripe::Client, - topup: &stripe_shared::TopupId, - ) -> stripe::Response<stripe_shared::Topup> { + pub fn send(&self, client: &stripe::Client, topup: &stripe_shared::TopupId) -> stripe::Response<stripe_shared::Topup> { client.get_query(&format!("/topups/{topup}"), self) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateTopup<'a> { - /// A positive integer representing how much to transfer. - pub amount: i64, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// An arbitrary string attached to the object. Often useful for displaying to users. - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// The ID of a source to transfer funds from. - /// For most users, this should be left unspecified which will use the bank account that was set up in the dashboard for the specified currency. - /// In test mode, this can be a test bank token (see [Testing Top-ups](https://stripe.com/docs/connect/testing#testing-top-ups)). - #[serde(skip_serializing_if = "Option::is_none")] - pub source: Option<&'a str>, - /// Extra information about a top-up for the source's bank statement. Limited to 15 ASCII characters. - #[serde(skip_serializing_if = "Option::is_none")] - pub statement_descriptor: Option<&'a str>, - /// A string that identifies this top-up as part of a group. - #[serde(skip_serializing_if = "Option::is_none")] - pub transfer_group: Option<&'a str>, -} -impl<'a> CreateTopup<'a> { - pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { - Self { - amount, - currency, - description: None, - expand: None, - metadata: None, - source: None, - statement_descriptor: None, - transfer_group: None, - } - } -} -impl<'a> CreateTopup<'a> { - /// Top up the balance of an account - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Topup> { - client.send_form("/topups", self, http_types::Method::Post) - } -} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateTopup<'a> { /// An arbitrary string attached to the object. Often useful for displaying to users. @@ -194,11 +178,7 @@ impl<'a> UpdateTopup<'a> { } impl<'a> UpdateTopup<'a> { /// Updates the metadata of a top-up. Other top-up details are not editable by design. - pub fn send( - &self, - client: &stripe::Client, - topup: &stripe_shared::TopupId, - ) -> stripe::Response<stripe_shared::Topup> { + pub fn send(&self, client: &stripe::Client, topup: &stripe_shared::TopupId) -> stripe::Response<stripe_shared::Topup> { client.send_form(&format!("/topups/{topup}"), self, http_types::Method::Post) } } @@ -215,11 +195,7 @@ impl<'a> CancelTopup<'a> { } impl<'a> CancelTopup<'a> { /// Cancels a top-up. Only pending top-ups can be canceled. - pub fn send( - &self, - client: &stripe::Client, - topup: &stripe_shared::TopupId, - ) -> stripe::Response<stripe_shared::Topup> { + pub fn send(&self, client: &stripe::Client, topup: &stripe_shared::TopupId) -> stripe::Response<stripe_shared::Topup> { client.send_form(&format!("/topups/{topup}/cancel"), self, http_types::Method::Post) } } diff --git a/generated/stripe_connect/src/transfer/requests.rs b/generated/stripe_connect/src/transfer/requests.rs index 876c3fb8c..ece5f903b 100644 --- a/generated/stripe_connect/src/transfer/requests.rs +++ b/generated/stripe_connect/src/transfer/requests.rs @@ -1,71 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListTransfer<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// Only return transfers for the destination specified by this account ID. - #[serde(skip_serializing_if = "Option::is_none")] - pub destination: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// Only return transfers with the specified transfer group. - #[serde(skip_serializing_if = "Option::is_none")] - pub transfer_group: Option<&'a str>, -} -impl<'a> ListTransfer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListTransfer<'a> { - /// Returns a list of existing transfers sent to connected accounts. - /// The transfers are returned in sorted order, with the most recently created transfers appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Transfer>> { - client.get_query("/transfers", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Transfer>> { - stripe::ListPaginator::from_list_params("/transfers", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTransfer<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveTransfer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveTransfer<'a> { - /// Retrieves the details of an existing transfer. - /// Supply the unique transfer ID from either a transfer creation request or the transfer list, and Stripe will return the corresponding transfer information. - pub fn send( - &self, - client: &stripe::Client, - transfer: &stripe_shared::TransferId, - ) -> stripe::Response<stripe_shared::Transfer> { - client.get_query(&format!("/transfers/{transfer}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTransfer<'a> { /// A positive integer in cents (or local equivalent) representing how much to transfer. @@ -105,17 +37,7 @@ pub struct CreateTransfer<'a> { } impl<'a> CreateTransfer<'a> { pub fn new(currency: stripe_types::Currency, destination: &'a str) -> Self { - Self { - amount: None, - currency, - description: None, - destination, - expand: None, - metadata: None, - source_transaction: None, - source_type: None, - transfer_group: None, - } + Self { amount: None, currency, description: None, destination, expand: None, metadata: None, source_transaction: None, source_type: None, transfer_group: None } } } /// The source balance to use for this transfer. @@ -177,6 +99,67 @@ impl<'a> CreateTransfer<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListTransfer<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// Only return transfers for the destination specified by this account ID. + #[serde(skip_serializing_if = "Option::is_none")] + pub destination: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// Only return transfers with the specified transfer group. + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_group: Option<&'a str>, +} +impl<'a> ListTransfer<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListTransfer<'a> { + /// Returns a list of existing transfers sent to connected accounts. + /// The transfers are returned in sorted order, with the most recently created transfers appearing first. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Transfer>> { + client.get_query("/transfers", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Transfer>> { + stripe::ListPaginator::from_list_params("/transfers", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTransfer<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTransfer<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTransfer<'a> { + /// Retrieves the details of an existing transfer. + /// Supply the unique transfer ID from either a transfer creation request or the transfer list, and Stripe will return the corresponding transfer information. + pub fn send(&self, client: &stripe::Client, transfer: &stripe_shared::TransferId) -> stripe::Response<stripe_shared::Transfer> { + client.get_query(&format!("/transfers/{transfer}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateTransfer<'a> { /// An arbitrary string attached to the object. Often useful for displaying to users. #[serde(skip_serializing_if = "Option::is_none")] @@ -201,11 +184,7 @@ impl<'a> UpdateTransfer<'a> { /// Any parameters not provided will be left unchanged. /// /// This request accepts only metadata as an argument. - pub fn send( - &self, - client: &stripe::Client, - transfer: &stripe_shared::TransferId, - ) -> stripe::Response<stripe_shared::Transfer> { + pub fn send(&self, client: &stripe::Client, transfer: &stripe_shared::TransferId) -> stripe::Response<stripe_shared::Transfer> { client.send_form(&format!("/transfers/{transfer}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_connect/src/transfer_reversal/requests.rs b/generated/stripe_connect/src/transfer_reversal/requests.rs index 66e84e731..43d03a33f 100644 --- a/generated/stripe_connect/src/transfer_reversal/requests.rs +++ b/generated/stripe_connect/src/transfer_reversal/requests.rs @@ -1,4 +1,49 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreateIdTransferReversal<'a> { + /// A positive integer in cents (or local equivalent) representing how much of this transfer to reverse. + /// Can only reverse up to the unreversed amount remaining of the transfer. + /// Partial transfer reversals are only allowed for transfers to Stripe Accounts. + /// Defaults to the entire transfer amount. + #[serde(skip_serializing_if = "Option::is_none")] + pub amount: Option<i64>, + /// An arbitrary string which you can attach to a reversal object. + /// It is displayed alongside the reversal in the Dashboard. + /// This will be unset if you POST an empty value. + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// Boolean indicating whether the application fee should be refunded when reversing this transfer. + /// If a full transfer reversal is given, the full application fee will be refunded. + /// Otherwise, the application fee will be refunded with an amount proportional to the amount of the transfer reversed. + #[serde(skip_serializing_if = "Option::is_none")] + pub refund_application_fee: Option<bool>, +} +impl<'a> CreateIdTransferReversal<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> CreateIdTransferReversal<'a> { + /// When you create a new reversal, you must specify a transfer to create it on. + /// + /// When reversing transfers, you can optionally reverse part of the transfer. + /// You can do so as many times as you wish until the entire transfer has been reversed. + /// + /// Once entirely reversed, a transfer can’t be reversed again. + /// This method will return an error when called on an already-reversed transfer, or when trying to reverse more money than is left on a transfer. + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::TransferId) -> stripe::Response<stripe_shared::TransferReversal> { + client.send_form(&format!("/transfers/{id}/reversals"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListIdTransferReversal<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -27,17 +72,10 @@ impl<'a> ListIdTransferReversal<'a> { /// You can see a list of the reversals belonging to a specific transfer. /// Note that the 10 most recent reversals are always available by default on the transfer object. /// If you need more than those 10, you can use this API method and the `limit` and `starting_after` parameters to page through additional reversals. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::TransferId, - ) -> stripe::Response<stripe_types::List<stripe_shared::TransferReversal>> { + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::TransferId) -> stripe::Response<stripe_types::List<stripe_shared::TransferReversal>> { client.get_query(&format!("/transfers/{id}/reversals"), self) } - pub fn paginate( - self, - id: &stripe_shared::TransferId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TransferReversal>> { + pub fn paginate(self, id: &stripe_shared::TransferId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TransferReversal>> { stripe::ListPaginator::from_list_params(&format!("/transfers/{id}/reversals"), self) } } @@ -54,65 +92,11 @@ impl<'a> RetrieveTransferReversal<'a> { } impl<'a> RetrieveTransferReversal<'a> { /// By default, you can see the 10 most recent reversals stored directly on the transfer object, but you can also retrieve details about a specific reversal stored on the transfer. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - transfer: &stripe_shared::TransferId, - ) -> stripe::Response<stripe_shared::TransferReversal> { + pub fn send(&self, client: &stripe::Client, id: &str, transfer: &stripe_shared::TransferId) -> stripe::Response<stripe_shared::TransferReversal> { client.get_query(&format!("/transfers/{transfer}/reversals/{id}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateIdTransferReversal<'a> { - /// A positive integer in cents (or local equivalent) representing how much of this transfer to reverse. - /// Can only reverse up to the unreversed amount remaining of the transfer. - /// Partial transfer reversals are only allowed for transfers to Stripe Accounts. - /// Defaults to the entire transfer amount. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option<i64>, - /// An arbitrary string which you can attach to a reversal object. - /// It is displayed alongside the reversal in the Dashboard. - /// This will be unset if you POST an empty value. - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Boolean indicating whether the application fee should be refunded when reversing this transfer. - /// If a full transfer reversal is given, the full application fee will be refunded. - /// Otherwise, the application fee will be refunded with an amount proportional to the amount of the transfer reversed. - #[serde(skip_serializing_if = "Option::is_none")] - pub refund_application_fee: Option<bool>, -} -impl<'a> CreateIdTransferReversal<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CreateIdTransferReversal<'a> { - /// When you create a new reversal, you must specify a transfer to create it on. - /// - /// When reversing transfers, you can optionally reverse part of the transfer. - /// You can do so as many times as you wish until the entire transfer has been reversed. - /// - /// Once entirely reversed, a transfer can’t be reversed again. - /// This method will return an error when called on an already-reversed transfer, or when trying to reverse more money than is left on a transfer. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::TransferId, - ) -> stripe::Response<stripe_shared::TransferReversal> { - client.send_form(&format!("/transfers/{id}/reversals"), self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateTransferReversal<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -134,16 +118,7 @@ impl<'a> UpdateTransferReversal<'a> { /// Any parameters not provided will be left unchanged. /// /// This request only accepts metadata and description as arguments. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - transfer: &stripe_shared::TransferId, - ) -> stripe::Response<stripe_shared::TransferReversal> { - client.send_form( - &format!("/transfers/{transfer}/reversals/{id}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, id: &str, transfer: &stripe_shared::TransferId) -> stripe::Response<stripe_shared::TransferReversal> { + client.send_form(&format!("/transfers/{transfer}/reversals/{id}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/.rustfmt.toml b/generated/stripe_core/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_core/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_core/Cargo.toml b/generated/stripe_core/Cargo.toml index 0a810ddff..2b37b2922 100644 --- a/generated/stripe_core/Cargo.toml +++ b/generated/stripe_core/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] @@ -43,7 +45,6 @@ charge = [] customer = [] customer_balance_transaction = [] customer_cash_balance_transaction = [] -customer_session = [] dispute = [] event = [] file = [] @@ -64,7 +65,6 @@ full = ["balance", "customer", "customer_balance_transaction", "customer_cash_balance_transaction", -"customer_session", "dispute", "event", "file", diff --git a/generated/stripe_core/src/balance/types.rs b/generated/stripe_core/src/balance/types.rs index 8fda3090d..6666e8f0c 100644 --- a/generated/stripe_core/src/balance/types.rs +++ b/generated/stripe_core/src/balance/types.rs @@ -11,19 +11,18 @@ /// Related guide: [Understanding Connect account balances](https://stripe.com/docs/connect/account-balances). /// /// For more details see <<https://stripe.com/docs/api/balance/balance_object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Balance { /// Available funds that you can transfer or pay out automatically by Stripe or explicitly through the [Transfers API](https://stripe.com/docs/api#transfers) or [Payouts API](https://stripe.com/docs/api#payouts). /// You can find the available balance for each currency and payment type in the `source_types` property. pub available: Vec<stripe_core::BalanceAmount>, /// Funds held due to negative balances on connected Custom accounts. /// You can find the connect reserve balance for each currency and payment type in the `source_types` property. - #[serde(skip_serializing_if = "Option::is_none")] pub connect_reserved: Option<Vec<stripe_core::BalanceAmount>>, /// Funds that you can pay out using Instant Payouts. - #[serde(skip_serializing_if = "Option::is_none")] pub instant_available: Option<Vec<stripe_core::BalanceAmountNet>>, - #[serde(skip_serializing_if = "Option::is_none")] pub issuing: Option<stripe_core::BalanceDetail>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, @@ -31,3 +30,116 @@ pub struct Balance { /// You can find the pending balance for each currency and each payment type in the `source_types` property. pub pending: Vec<stripe_core::BalanceAmount>, } +#[cfg(feature = "min-ser")] +pub struct BalanceBuilder { + available: Option<Vec<stripe_core::BalanceAmount>>, + connect_reserved: Option<Option<Vec<stripe_core::BalanceAmount>>>, + instant_available: Option<Option<Vec<stripe_core::BalanceAmountNet>>>, + issuing: Option<Option<stripe_core::BalanceDetail>>, + livemode: Option<bool>, + pending: Option<Vec<stripe_core::BalanceAmount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Balance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Balance>, + builder: BalanceBuilder, + } + + impl Visitor for Place<Balance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for BalanceBuilder { + type Out = Balance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available" => Deserialize::begin(&mut self.available), + "connect_reserved" => Deserialize::begin(&mut self.connect_reserved), + "instant_available" => Deserialize::begin(&mut self.instant_available), + "issuing" => Deserialize::begin(&mut self.issuing), + "livemode" => Deserialize::begin(&mut self.livemode), + "pending" => Deserialize::begin(&mut self.pending), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + available: Deserialize::default(), + connect_reserved: Deserialize::default(), + instant_available: Deserialize::default(), + issuing: Deserialize::default(), + livemode: Deserialize::default(), + pending: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available = self.available.take()?; + let connect_reserved = self.connect_reserved.take()?; + let instant_available = self.instant_available.take()?; + let issuing = self.issuing.take()?; + let livemode = self.livemode.take()?; + let pending = self.pending.take()?; + + Some(Self::Out { available, connect_reserved, instant_available, issuing, livemode, pending }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Balance { + type Builder = BalanceBuilder; + } + + impl FromValueOpt for Balance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available" => b.available = Some(FromValueOpt::from_value(v)?), + "connect_reserved" => b.connect_reserved = Some(FromValueOpt::from_value(v)?), + "instant_available" => b.instant_available = Some(FromValueOpt::from_value(v)?), + "issuing" => b.issuing = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "pending" => b.pending = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_core/src/balance_amount.rs b/generated/stripe_core/src/balance_amount.rs index 4ced136aa..eba47cf8f 100644 --- a/generated/stripe_core/src/balance_amount.rs +++ b/generated/stripe_core/src/balance_amount.rs @@ -1,10 +1,105 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BalanceAmount { /// Balance amount. pub amount: i64, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: stripe_types::Currency, - #[serde(skip_serializing_if = "Option::is_none")] pub source_types: Option<stripe_core::BalanceAmountBySourceType>, } +#[cfg(feature = "min-ser")] +pub struct BalanceAmountBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, + source_types: Option<Option<stripe_core::BalanceAmountBySourceType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BalanceAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BalanceAmount>, + builder: BalanceAmountBuilder, + } + + impl Visitor for Place<BalanceAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BalanceAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for BalanceAmountBuilder { + type Out = BalanceAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "source_types" => Deserialize::begin(&mut self.source_types), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default(), source_types: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let source_types = self.source_types.take()?; + + Some(Self::Out { amount, currency, source_types }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BalanceAmount { + type Builder = BalanceAmountBuilder; + } + + impl FromValueOpt for BalanceAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BalanceAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "source_types" => b.source_types = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_core/src/balance_amount_by_source_type.rs b/generated/stripe_core/src/balance_amount_by_source_type.rs index 6fbb1b6eb..d8aa767c8 100644 --- a/generated/stripe_core/src/balance_amount_by_source_type.rs +++ b/generated/stripe_core/src/balance_amount_by_source_type.rs @@ -1,12 +1,105 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BalanceAmountBySourceType { /// Amount for bank account. - #[serde(skip_serializing_if = "Option::is_none")] pub bank_account: Option<i64>, /// Amount for card. - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<i64>, /// Amount for FPX. - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct BalanceAmountBySourceTypeBuilder { + bank_account: Option<Option<i64>>, + card: Option<Option<i64>>, + fpx: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BalanceAmountBySourceType { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BalanceAmountBySourceType>, + builder: BalanceAmountBySourceTypeBuilder, + } + + impl Visitor for Place<BalanceAmountBySourceType> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BalanceAmountBySourceTypeBuilder::deser_default() })) + } + } + + impl MapBuilder for BalanceAmountBySourceTypeBuilder { + type Out = BalanceAmountBySourceType; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_account" => Deserialize::begin(&mut self.bank_account), + "card" => Deserialize::begin(&mut self.card), + "fpx" => Deserialize::begin(&mut self.fpx), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_account: Deserialize::default(), card: Deserialize::default(), fpx: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_account = self.bank_account.take()?; + let card = self.card.take()?; + let fpx = self.fpx.take()?; + + Some(Self::Out { bank_account, card, fpx }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BalanceAmountBySourceType { + type Builder = BalanceAmountBySourceTypeBuilder; + } + + impl FromValueOpt for BalanceAmountBySourceType { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BalanceAmountBySourceTypeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_account" => b.bank_account = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "fpx" => b.fpx = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_core/src/balance_amount_net.rs b/generated/stripe_core/src/balance_amount_net.rs index a8fe12a30..b17a35eaa 100644 --- a/generated/stripe_core/src/balance_amount_net.rs +++ b/generated/stripe_core/src/balance_amount_net.rs @@ -1,10 +1,105 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BalanceAmountNet { /// Balance amount. pub amount: i64, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: stripe_types::Currency, - #[serde(skip_serializing_if = "Option::is_none")] pub source_types: Option<stripe_core::BalanceAmountBySourceType>, } +#[cfg(feature = "min-ser")] +pub struct BalanceAmountNetBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, + source_types: Option<Option<stripe_core::BalanceAmountBySourceType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BalanceAmountNet { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BalanceAmountNet>, + builder: BalanceAmountNetBuilder, + } + + impl Visitor for Place<BalanceAmountNet> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BalanceAmountNetBuilder::deser_default() })) + } + } + + impl MapBuilder for BalanceAmountNetBuilder { + type Out = BalanceAmountNet; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "source_types" => Deserialize::begin(&mut self.source_types), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default(), source_types: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let source_types = self.source_types.take()?; + + Some(Self::Out { amount, currency, source_types }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BalanceAmountNet { + type Builder = BalanceAmountNetBuilder; + } + + impl FromValueOpt for BalanceAmountNet { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BalanceAmountNetBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "source_types" => b.source_types = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_core/src/balance_detail.rs b/generated/stripe_core/src/balance_detail.rs index c7cdd9af8..5e74a9250 100644 --- a/generated/stripe_core/src/balance_detail.rs +++ b/generated/stripe_core/src/balance_detail.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BalanceDetail { /// Funds that are available for use. pub available: Vec<stripe_core::BalanceAmount>, } +#[cfg(feature = "min-ser")] +pub struct BalanceDetailBuilder { + available: Option<Vec<stripe_core::BalanceAmount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BalanceDetail { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BalanceDetail>, + builder: BalanceDetailBuilder, + } + + impl Visitor for Place<BalanceDetail> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BalanceDetailBuilder::deser_default() })) + } + } + + impl MapBuilder for BalanceDetailBuilder { + type Out = BalanceDetail; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available" => Deserialize::begin(&mut self.available), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available = self.available.take()?; + + Some(Self::Out { available }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BalanceDetail { + type Builder = BalanceDetailBuilder; + } + + impl FromValueOpt for BalanceDetail { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BalanceDetailBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available" => b.available = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_core/src/balance_transaction/requests.rs b/generated/stripe_core/src/balance_transaction/requests.rs index ecdda4709..c3793f39d 100644 --- a/generated/stripe_core/src/balance_transaction/requests.rs +++ b/generated/stripe_core/src/balance_transaction/requests.rs @@ -31,8 +31,8 @@ pub struct ListBalanceTransaction<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, /// Only returns transactions of the given type. - /// One of: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. - #[serde(rename = "type")] + /// One of: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_inbound`, `obligation_outbound`, `obligation_reversal_inbound`, `obligation_reversal_outbound`, `obligation_payout`, `obligation_payout_failure`, `payment`, `payment_failure_refund`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<&'a str>, } @@ -46,15 +46,10 @@ impl<'a> ListBalanceTransaction<'a> { /// The transactions are returned in sorted order, with the most recent transactions appearing first. /// /// Note that this endpoint was previously called “Balance history” and used the path `/v1/balance/history`. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::BalanceTransaction>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::BalanceTransaction>> { client.get_query("/balance_transactions", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::BalanceTransaction>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::BalanceTransaction>> { stripe::ListPaginator::from_list_params("/balance_transactions", self) } } @@ -73,11 +68,7 @@ impl<'a> RetrieveBalanceTransaction<'a> { /// Retrieves the balance transaction with the given ID. /// /// Note that this endpoint previously used the path `/v1/balance/history/:id`. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::BalanceTransactionId, - ) -> stripe::Response<stripe_shared::BalanceTransaction> { + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::BalanceTransactionId) -> stripe::Response<stripe_shared::BalanceTransaction> { client.get_query(&format!("/balance_transactions/{id}"), self) } } diff --git a/generated/stripe_core/src/cash_balance/requests.rs b/generated/stripe_core/src/cash_balance/requests.rs index 48acee1ca..907e0dd92 100644 --- a/generated/stripe_core/src/cash_balance/requests.rs +++ b/generated/stripe_core/src/cash_balance/requests.rs @@ -11,11 +11,7 @@ impl<'a> RetrieveCashBalance<'a> { } impl<'a> RetrieveCashBalance<'a> { /// Retrieves a customer’s cash balance. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::CashBalance> { + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::CashBalance> { client.get_query(&format!("/customers/{customer}/cash_balance"), self) } } @@ -100,15 +96,7 @@ impl serde::Serialize for UpdateCashBalanceSettingsReconciliationMode { } impl<'a> UpdateCashBalance<'a> { /// Changes the settings on a customer’s cash balance. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::CashBalance> { - client.send_form( - &format!("/customers/{customer}/cash_balance"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::CashBalance> { + client.send_form(&format!("/customers/{customer}/cash_balance"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/src/charge/requests.rs b/generated/stripe_core/src/charge/requests.rs index cf495c77b..b2dea2c4d 100644 --- a/generated/stripe_core/src/charge/requests.rs +++ b/generated/stripe_core/src/charge/requests.rs @@ -1,3 +1,40 @@ +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct SearchCharge<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for pagination across multiple pages of results. + /// Don't include this parameter on the first call. + /// Use the next_page value returned in a previous response to request subsequent results. + #[serde(skip_serializing_if = "Option::is_none")] + pub page: Option<&'a str>, + /// The search query string. + /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for charges](https://stripe.com/docs/search#query-fields-for-charges). + pub query: &'a str, +} +impl<'a> SearchCharge<'a> { + pub fn new(query: &'a str) -> Self { + Self { expand: None, limit: None, page: None, query } + } +} +impl<'a> SearchCharge<'a> { + /// Search for charges you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). + /// Don’t use search in read-after-write flows where strict consistency is necessary. + /// Under normal operating. + /// conditions, data is searchable in less than a minute. + /// Occasionally, propagation of new or updated data can be up. + /// to an hour behind during outages. Search functionality is not available to merchants in India. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::SearchList<stripe_shared::Charge>> { + client.get_query("/charges/search", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Charge>> { + stripe::ListPaginator::from_search_params("/charges/search", self) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListCharge<'a> { #[serde(skip_serializing_if = "Option::is_none")] @@ -37,10 +74,7 @@ impl<'a> ListCharge<'a> { impl<'a> ListCharge<'a> { /// Returns a list of charges you’ve previously created. /// The charges are returned in sorted order, with the most recent charges appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Charge>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Charge>> { client.get_query("/charges", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Charge>> { @@ -48,71 +82,6 @@ impl<'a> ListCharge<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveCharge<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveCharge<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveCharge<'a> { - /// Retrieves the details of a charge that has previously been created. - /// Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. - /// The same information is returned when creating or refunding the charge. - pub fn send( - &self, - client: &stripe::Client, - charge: &stripe_shared::ChargeId, - ) -> stripe::Response<stripe_shared::Charge> { - client.get_query(&format!("/charges/{charge}"), self) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct SearchCharge<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for pagination across multiple pages of results. - /// Don't include this parameter on the first call. - /// Use the next_page value returned in a previous response to request subsequent results. - #[serde(skip_serializing_if = "Option::is_none")] - pub page: Option<&'a str>, - /// The search query string. - /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for charges](https://stripe.com/docs/search#query-fields-for-charges). - pub query: &'a str, -} -impl<'a> SearchCharge<'a> { - pub fn new(query: &'a str) -> Self { - Self { expand: None, limit: None, page: None, query } - } -} -impl<'a> SearchCharge<'a> { - /// Search for charges you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). - /// Don’t use search in read-after-write flows where strict consistency is necessary. - /// Under normal operating. - /// conditions, data is searchable in less than a minute. - /// Occasionally, propagation of new or updated data can be up. - /// to an hour behind during outages. Search functionality is not available to merchants in India. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::SearchList<stripe_shared::Charge>> { - client.get_query("/charges/search", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Charge>> { - stripe::ListPaginator::from_search_params("/charges/search", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCharge<'a> { /// Amount intended to be collected by this payment. /// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). @@ -249,14 +218,33 @@ impl<'a> CreateChargeTransferData<'a> { } } impl<'a> CreateCharge<'a> { - /// This method is no longer recommended—use the [Payment Intents API](https://stripe.com/docs/api/payment_intents). - /// to initiate a new payment instead. Confirmation of the PaymentIntent creates the `Charge` - /// object used to request payment. + /// Use the [Payment Intents API](https://stripe.com/docs/api/payment_intents) to initiate a new payment instead. + /// of using this method. Confirmation of the PaymentIntent creates the `Charge` + /// object used to request payment, so this method is limited to legacy integrations. pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Charge> { client.send_form("/charges", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveCharge<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveCharge<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveCharge<'a> { + /// Retrieves the details of a charge that has previously been created. + /// Supply the unique charge ID that was returned from your previous request, and Stripe will return the corresponding charge information. + /// The same information is returned when creating or refunding the charge. + pub fn send(&self, client: &stripe::Client, charge: &stripe_shared::ChargeId) -> stripe::Response<stripe_shared::Charge> { + client.get_query(&format!("/charges/{charge}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateCharge<'a> { /// The ID of an existing customer that will be associated with this request. /// This field may only be updated if there is no existing associated customer with this charge. @@ -363,11 +351,7 @@ impl serde::Serialize for UpdateChargeFraudDetailsUserReport { impl<'a> UpdateCharge<'a> { /// Updates the specified charge by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - charge: &stripe_shared::ChargeId, - ) -> stripe::Response<stripe_shared::Charge> { + pub fn send(&self, client: &stripe::Client, charge: &stripe_shared::ChargeId) -> stripe::Response<stripe_shared::Charge> { client.send_form(&format!("/charges/{charge}"), self, http_types::Method::Post) } } @@ -437,11 +421,7 @@ impl<'a> CaptureCharge<'a> { /// /// Don’t use this method to capture a PaymentIntent-initiated charge. /// Use [Capture a PaymentIntent](https://stripe.com/docs/api/payment_intents/capture). - pub fn send( - &self, - client: &stripe::Client, - charge: &stripe_shared::ChargeId, - ) -> stripe::Response<stripe_shared::Charge> { + pub fn send(&self, client: &stripe::Client, charge: &stripe_shared::ChargeId) -> stripe::Response<stripe_shared::Charge> { client.send_form(&format!("/charges/{charge}/capture"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/src/customer/requests.rs b/generated/stripe_core/src/customer/requests.rs index f6917085a..984dd32c9 100644 --- a/generated/stripe_core/src/customer/requests.rs +++ b/generated/stripe_core/src/customer/requests.rs @@ -1,41 +1,38 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteCustomer {} -impl DeleteCustomer { - pub fn new() -> Self { - Self::default() - } +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct SearchCustomer<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for pagination across multiple pages of results. + /// Don't include this parameter on the first call. + /// Use the next_page value returned in a previous response to request subsequent results. + #[serde(skip_serializing_if = "Option::is_none")] + pub page: Option<&'a str>, + /// The search query string. + /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for customers](https://stripe.com/docs/search#query-fields-for-customers). + pub query: &'a str, } -impl DeleteCustomer { - /// Permanently deletes a customer. - /// It cannot be undone. - /// Also immediately cancels any active subscriptions on the customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::DeletedCustomer> { - client.send_form(&format!("/customers/{customer}"), self, http_types::Method::Delete) +impl<'a> SearchCustomer<'a> { + pub fn new(query: &'a str) -> Self { + Self { expand: None, limit: None, page: None, query } } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteDiscountCustomer {} -impl DeleteDiscountCustomer { - pub fn new() -> Self { - Self::default() +impl<'a> SearchCustomer<'a> { + /// Search for customers you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). + /// Don’t use search in read-after-write flows where strict consistency is necessary. + /// Under normal operating. + /// conditions, data is searchable in less than a minute. + /// Occasionally, propagation of new or updated data can be up. + /// to an hour behind during outages. Search functionality is not available to merchants in India. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::SearchList<stripe_shared::Customer>> { + client.get_query("/customers/search", self) } -} -impl DeleteDiscountCustomer { - /// Removes the currently applied discount on a customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::DeletedDiscount> { - client.send_form( - &format!("/customers/{customer}/discount"), - self, - http_types::Method::Delete, - ) + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Customer>> { + stripe::ListPaginator::from_search_params("/customers/search", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -76,10 +73,7 @@ impl<'a> ListCustomer<'a> { impl<'a> ListCustomer<'a> { /// Returns a list of your customers. /// The customers are returned sorted by creation date, with the most recent customers appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Customer>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Customer>> { client.get_query("/customers", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Customer>> { @@ -87,336 +81,6 @@ impl<'a> ListCustomer<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveCustomer<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveCustomer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveCustomer<'a> { - /// Retrieves a Customer object. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<RetrieveCustomerReturned> { - client.get_query(&format!("/customers/{customer}"), self) - } -} -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] -pub enum RetrieveCustomerReturned { - Customer(stripe_shared::Customer), - DeletedCustomer(stripe_shared::DeletedCustomer), -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct BalanceTransactionsCustomer<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> BalanceTransactionsCustomer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> BalanceTransactionsCustomer<'a> { - /// Returns a list of transactions that updated the customer’s [balances](https://stripe.com/docs/billing/customer/balance). - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { - client.get_query(&format!("/customers/{customer}/balance_transactions"), self) - } - pub fn paginate( - self, - customer: &stripe_shared::CustomerId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { - stripe::ListPaginator::from_list_params( - &format!("/customers/{customer}/balance_transactions"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListPaymentMethodsCustomer<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// An optional filter on the list, based on the object `type` field. - /// Without the filter, the list includes all current and future payment method types. - /// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub type_: Option<ListPaymentMethodsCustomerType>, -} -impl<'a> ListPaymentMethodsCustomer<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// An optional filter on the list, based on the object `type` field. -/// Without the filter, the list includes all current and future payment method types. -/// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -#[non_exhaustive] -pub enum ListPaymentMethodsCustomerType { - AcssDebit, - Affirm, - AfterpayClearpay, - Alipay, - AuBecsDebit, - BacsDebit, - Bancontact, - Blik, - Boleto, - Card, - Cashapp, - CustomerBalance, - Eps, - Fpx, - Giropay, - Grabpay, - Ideal, - Klarna, - Konbini, - Link, - Oxxo, - P24, - Paynow, - Paypal, - Pix, - Promptpay, - RevolutPay, - SepaDebit, - Sofort, - Swish, - UsBankAccount, - WechatPay, - Zip, - /// An unrecognized value from Stripe. Should not be used as a request parameter. - Unknown, -} -impl ListPaymentMethodsCustomerType { - pub fn as_str(self) -> &'static str { - use ListPaymentMethodsCustomerType::*; - match self { - AcssDebit => "acss_debit", - Affirm => "affirm", - AfterpayClearpay => "afterpay_clearpay", - Alipay => "alipay", - AuBecsDebit => "au_becs_debit", - BacsDebit => "bacs_debit", - Bancontact => "bancontact", - Blik => "blik", - Boleto => "boleto", - Card => "card", - Cashapp => "cashapp", - CustomerBalance => "customer_balance", - Eps => "eps", - Fpx => "fpx", - Giropay => "giropay", - Grabpay => "grabpay", - Ideal => "ideal", - Klarna => "klarna", - Konbini => "konbini", - Link => "link", - Oxxo => "oxxo", - P24 => "p24", - Paynow => "paynow", - Paypal => "paypal", - Pix => "pix", - Promptpay => "promptpay", - RevolutPay => "revolut_pay", - SepaDebit => "sepa_debit", - Sofort => "sofort", - Swish => "swish", - UsBankAccount => "us_bank_account", - WechatPay => "wechat_pay", - Zip => "zip", - Unknown => "unknown", - } - } -} - -impl std::str::FromStr for ListPaymentMethodsCustomerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ListPaymentMethodsCustomerType::*; - match s { - "acss_debit" => Ok(AcssDebit), - "affirm" => Ok(Affirm), - "afterpay_clearpay" => Ok(AfterpayClearpay), - "alipay" => Ok(Alipay), - "au_becs_debit" => Ok(AuBecsDebit), - "bacs_debit" => Ok(BacsDebit), - "bancontact" => Ok(Bancontact), - "blik" => Ok(Blik), - "boleto" => Ok(Boleto), - "card" => Ok(Card), - "cashapp" => Ok(Cashapp), - "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), - "fpx" => Ok(Fpx), - "giropay" => Ok(Giropay), - "grabpay" => Ok(Grabpay), - "ideal" => Ok(Ideal), - "klarna" => Ok(Klarna), - "konbini" => Ok(Konbini), - "link" => Ok(Link), - "oxxo" => Ok(Oxxo), - "p24" => Ok(P24), - "paynow" => Ok(Paynow), - "paypal" => Ok(Paypal), - "pix" => Ok(Pix), - "promptpay" => Ok(Promptpay), - "revolut_pay" => Ok(RevolutPay), - "sepa_debit" => Ok(SepaDebit), - "sofort" => Ok(Sofort), - "swish" => Ok(Swish), - "us_bank_account" => Ok(UsBankAccount), - "wechat_pay" => Ok(WechatPay), - "zip" => Ok(Zip), - _ => Err(()), - } - } -} -impl std::fmt::Display for ListPaymentMethodsCustomerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ListPaymentMethodsCustomerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ListPaymentMethodsCustomerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> ListPaymentMethodsCustomer<'a> { - /// Returns a list of PaymentMethods for a given Customer - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_types::List<stripe_shared::PaymentMethod>> { - client.get_query(&format!("/customers/{customer}/payment_methods"), self) - } - pub fn paginate( - self, - customer: &stripe_shared::CustomerId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentMethod>> { - stripe::ListPaginator::from_list_params( - &format!("/customers/{customer}/payment_methods"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrievePaymentMethodCustomer<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrievePaymentMethodCustomer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrievePaymentMethodCustomer<'a> { - /// Retrieves a PaymentMethod object for a given Customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - payment_method: &str, - ) -> stripe::Response<stripe_shared::PaymentMethod> { - client.get_query(&format!("/customers/{customer}/payment_methods/{payment_method}"), self) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct SearchCustomer<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for pagination across multiple pages of results. - /// Don't include this parameter on the first call. - /// Use the next_page value returned in a previous response to request subsequent results. - #[serde(skip_serializing_if = "Option::is_none")] - pub page: Option<&'a str>, - /// The search query string. - /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for customers](https://stripe.com/docs/search#query-fields-for-customers). - pub query: &'a str, -} -impl<'a> SearchCustomer<'a> { - pub fn new(query: &'a str) -> Self { - Self { expand: None, limit: None, page: None, query } - } -} -impl<'a> SearchCustomer<'a> { - /// Search for customers you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). - /// Don’t use search in read-after-write flows where strict consistency is necessary. - /// Under normal operating. - /// conditions, data is searchable in less than a minute. - /// Occasionally, propagation of new or updated data can be up. - /// to an hour behind during outages. Search functionality is not available to merchants in India. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::SearchList<stripe_shared::Customer>> { - client.get_query("/customers/search", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Customer>> { - stripe::ListPaginator::from_search_params("/customers/search", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCustomer<'a> { /// The customer's address. #[serde(skip_serializing_if = "Option::is_none")] @@ -481,7 +145,7 @@ pub struct CreateCustomer<'a> { pub source: Option<&'a str>, /// Tax details about the customer. #[serde(skip_serializing_if = "Option::is_none")] - pub tax: Option<CreateCustomerTax<'a>>, + pub tax: Option<TaxParam<'a>>, /// The customer's tax exemption. One of `none`, `exempt`, or `reverse`. #[serde(skip_serializing_if = "Option::is_none")] pub tax_exempt: Option<stripe_shared::CustomerTaxExempt>, @@ -581,7 +245,7 @@ impl serde::Serialize for CreateCustomerCashBalanceSettingsReconciliationMode { /// Default invoice settings for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCustomerInvoiceSettings<'a> { - /// The list of up to 4 default custom fields to be displayed on invoices for this customer. + /// Default custom fields to be displayed on invoices for this customer. /// When updating, pass an empty string to remove previously-defined fields. #[serde(skip_serializing_if = "Option::is_none")] pub custom_fields: Option<&'a [CustomFieldParams<'a>]>, @@ -664,76 +328,11 @@ impl serde::Serialize for CreateCustomerInvoiceSettingsRenderingOptionsAmountTax serializer.serialize_str(self.as_str()) } } -/// Tax details about the customer. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateCustomerTax<'a> { - /// A recent IP address of the customer used for tax reporting and tax location inference. - /// Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. - /// We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes. - #[serde(skip_serializing_if = "Option::is_none")] - pub ip_address: Option<&'a str>, - /// A flag that indicates when Stripe should validate the customer tax location. - /// Defaults to `deferred`. - #[serde(skip_serializing_if = "Option::is_none")] - pub validate_location: Option<CreateCustomerTaxValidateLocation>, -} -impl<'a> CreateCustomerTax<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// A flag that indicates when Stripe should validate the customer tax location. -/// Defaults to `deferred`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateCustomerTaxValidateLocation { - Deferred, - Immediately, -} -impl CreateCustomerTaxValidateLocation { - pub fn as_str(self) -> &'static str { - use CreateCustomerTaxValidateLocation::*; - match self { - Deferred => "deferred", - Immediately => "immediately", - } - } -} - -impl std::str::FromStr for CreateCustomerTaxValidateLocation { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateCustomerTaxValidateLocation::*; - match s { - "deferred" => Ok(Deferred), - "immediately" => Ok(Immediately), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateCustomerTaxValidateLocation { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateCustomerTaxValidateLocation { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateCustomerTaxValidateLocation { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// The customer's tax IDs. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCustomerTaxIdData<'a> { /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateCustomerTaxIdDataType, /// Value of the tax ID. pub value: &'a str, @@ -984,13 +583,110 @@ impl serde::Serialize for CreateCustomerTaxIdDataType { { serializer.serialize_str(self.as_str()) } -} -impl<'a> CreateCustomer<'a> { - /// Creates a new customer object. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Customer> { - client.send_form("/customers", self, http_types::Method::Post) +} +impl<'a> CreateCustomer<'a> { + /// Creates a new customer object. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::Customer> { + client.send_form("/customers", self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveCustomer<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveCustomer<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveCustomer<'a> { + /// Retrieves a Customer object. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<RetrieveCustomerReturned> { + client.get_query(&format!("/customers/{customer}"), self) + } +} +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] +pub enum RetrieveCustomerReturned { + Customer(stripe_shared::Customer), + DeletedCustomer(stripe_shared::DeletedCustomer), +} + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct RetrieveCustomerReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<RetrieveCustomerReturned>, + builder: RetrieveCustomerReturnedBuilder, + } + + impl Deserialize for RetrieveCustomerReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<RetrieveCustomerReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for RetrieveCustomerReturnedBuilder { + type Out = RetrieveCustomerReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + RetrieveCustomerReturned::DeletedCustomer(FromValueOpt::from_value(Value::Object(o))?) + } else { + RetrieveCustomerReturned::Customer(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for RetrieveCustomerReturned { + type Builder = RetrieveCustomerReturnedBuilder; } -} +}; + #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateCustomer<'a> { /// The customer's address. @@ -1061,7 +757,7 @@ pub struct UpdateCustomer<'a> { pub source: Option<&'a str>, /// Tax details about the customer. #[serde(skip_serializing_if = "Option::is_none")] - pub tax: Option<UpdateCustomerTax<'a>>, + pub tax: Option<TaxParam<'a>>, /// The customer's tax exemption. One of `none`, `exempt`, or `reverse`. #[serde(skip_serializing_if = "Option::is_none")] pub tax_exempt: Option<stripe_shared::CustomerTaxExempt>, @@ -1121,30 +817,317 @@ impl UpdateCustomerCashBalanceSettingsReconciliationMode { } } -impl std::str::FromStr for UpdateCustomerCashBalanceSettingsReconciliationMode { +impl std::str::FromStr for UpdateCustomerCashBalanceSettingsReconciliationMode { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use UpdateCustomerCashBalanceSettingsReconciliationMode::*; + match s { + "automatic" => Ok(Automatic), + "manual" => Ok(Manual), + "merchant_default" => Ok(MerchantDefault), + _ => Err(()), + } + } +} +impl std::fmt::Display for UpdateCustomerCashBalanceSettingsReconciliationMode { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for UpdateCustomerCashBalanceSettingsReconciliationMode { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for UpdateCustomerCashBalanceSettingsReconciliationMode { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +/// Default invoice settings for this customer. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateCustomerInvoiceSettings<'a> { + /// Default custom fields to be displayed on invoices for this customer. + /// When updating, pass an empty string to remove previously-defined fields. + #[serde(skip_serializing_if = "Option::is_none")] + pub custom_fields: Option<&'a [CustomFieldParams<'a>]>, + /// ID of a payment method that's attached to the customer, to be used as the customer's default payment method for subscriptions and invoices. + #[serde(skip_serializing_if = "Option::is_none")] + pub default_payment_method: Option<&'a str>, + /// Default footer to be displayed on invoices for this customer. + #[serde(skip_serializing_if = "Option::is_none")] + pub footer: Option<&'a str>, + /// Default options for invoice PDF rendering for this customer. + #[serde(skip_serializing_if = "Option::is_none")] + pub rendering_options: Option<UpdateCustomerInvoiceSettingsRenderingOptions>, +} +impl<'a> UpdateCustomerInvoiceSettings<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Default options for invoice PDF rendering for this customer. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateCustomerInvoiceSettingsRenderingOptions { + /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. + /// One of `exclude_tax` or `include_inclusive_tax`. + /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. + /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. + #[serde(skip_serializing_if = "Option::is_none")] + pub amount_tax_display: Option<UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay>, +} +impl UpdateCustomerInvoiceSettingsRenderingOptions { + pub fn new() -> Self { + Self::default() + } +} +/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. +/// One of `exclude_tax` or `include_inclusive_tax`. +/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. +/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { + ExcludeTax, + IncludeInclusiveTax, +} +impl UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { + pub fn as_str(self) -> &'static str { + use UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*; + match self { + ExcludeTax => "exclude_tax", + IncludeInclusiveTax => "include_inclusive_tax", + } + } +} + +impl std::str::FromStr for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*; + match s { + "exclude_tax" => Ok(ExcludeTax), + "include_inclusive_tax" => Ok(IncludeInclusiveTax), + _ => Err(()), + } + } +} +impl std::fmt::Display for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> UpdateCustomer<'a> { + /// Updates the specified customer by setting the values of the parameters passed. + /// Any parameters not provided will be left unchanged. + /// For example, if you pass the **source** parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. + /// When you update a customer to a new valid card source by passing the **source** parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the `past_due` state, then the latest open invoice for the subscription with automatic collection enabled will be retried. + /// This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. + /// Changing the **default_source** for a customer will not trigger this behavior. + /// + /// This request accepts mostly the same arguments as the customer creation call. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::Customer> { + client.send_form(&format!("/customers/{customer}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteCustomer {} +impl DeleteCustomer { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteCustomer { + /// Permanently deletes a customer. + /// It cannot be undone. + /// Also immediately cancels any active subscriptions on the customer. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::DeletedCustomer> { + client.send_form(&format!("/customers/{customer}"), self, http_types::Method::Delete) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListPaymentMethodsCustomer<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// An optional filter on the list, based on the object `type` field. + /// Without the filter, the list includes all current and future payment method types. + /// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + #[serde(skip_serializing_if = "Option::is_none")] + pub type_: Option<ListPaymentMethodsCustomerType>, +} +impl<'a> ListPaymentMethodsCustomer<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// An optional filter on the list, based on the object `type` field. +/// Without the filter, the list includes all current and future payment method types. +/// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. +#[derive(Copy, Clone, Eq, PartialEq)] +#[non_exhaustive] +pub enum ListPaymentMethodsCustomerType { + AcssDebit, + Affirm, + AfterpayClearpay, + Alipay, + AuBecsDebit, + BacsDebit, + Bancontact, + Blik, + Boleto, + Card, + Cashapp, + CustomerBalance, + Eps, + Fpx, + Giropay, + Grabpay, + Ideal, + Klarna, + Konbini, + Link, + Oxxo, + P24, + Paynow, + Paypal, + Pix, + Promptpay, + RevolutPay, + SepaDebit, + Sofort, + UsBankAccount, + WechatPay, + Zip, + /// An unrecognized value from Stripe. Should not be used as a request parameter. + Unknown, +} +impl ListPaymentMethodsCustomerType { + pub fn as_str(self) -> &'static str { + use ListPaymentMethodsCustomerType::*; + match self { + AcssDebit => "acss_debit", + Affirm => "affirm", + AfterpayClearpay => "afterpay_clearpay", + Alipay => "alipay", + AuBecsDebit => "au_becs_debit", + BacsDebit => "bacs_debit", + Bancontact => "bancontact", + Blik => "blik", + Boleto => "boleto", + Card => "card", + Cashapp => "cashapp", + CustomerBalance => "customer_balance", + Eps => "eps", + Fpx => "fpx", + Giropay => "giropay", + Grabpay => "grabpay", + Ideal => "ideal", + Klarna => "klarna", + Konbini => "konbini", + Link => "link", + Oxxo => "oxxo", + P24 => "p24", + Paynow => "paynow", + Paypal => "paypal", + Pix => "pix", + Promptpay => "promptpay", + RevolutPay => "revolut_pay", + SepaDebit => "sepa_debit", + Sofort => "sofort", + UsBankAccount => "us_bank_account", + WechatPay => "wechat_pay", + Zip => "zip", + Unknown => "unknown", + } + } +} + +impl std::str::FromStr for ListPaymentMethodsCustomerType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateCustomerCashBalanceSettingsReconciliationMode::*; + use ListPaymentMethodsCustomerType::*; match s { - "automatic" => Ok(Automatic), - "manual" => Ok(Manual), - "merchant_default" => Ok(MerchantDefault), + "acss_debit" => Ok(AcssDebit), + "affirm" => Ok(Affirm), + "afterpay_clearpay" => Ok(AfterpayClearpay), + "alipay" => Ok(Alipay), + "au_becs_debit" => Ok(AuBecsDebit), + "bacs_debit" => Ok(BacsDebit), + "bancontact" => Ok(Bancontact), + "blik" => Ok(Blik), + "boleto" => Ok(Boleto), + "card" => Ok(Card), + "cashapp" => Ok(Cashapp), + "customer_balance" => Ok(CustomerBalance), + "eps" => Ok(Eps), + "fpx" => Ok(Fpx), + "giropay" => Ok(Giropay), + "grabpay" => Ok(Grabpay), + "ideal" => Ok(Ideal), + "klarna" => Ok(Klarna), + "konbini" => Ok(Konbini), + "link" => Ok(Link), + "oxxo" => Ok(Oxxo), + "p24" => Ok(P24), + "paynow" => Ok(Paynow), + "paypal" => Ok(Paypal), + "pix" => Ok(Pix), + "promptpay" => Ok(Promptpay), + "revolut_pay" => Ok(RevolutPay), + "sepa_debit" => Ok(SepaDebit), + "sofort" => Ok(Sofort), + "us_bank_account" => Ok(UsBankAccount), + "wechat_pay" => Ok(WechatPay), + "zip" => Ok(Zip), _ => Err(()), } } } -impl std::fmt::Display for UpdateCustomerCashBalanceSettingsReconciliationMode { +impl std::fmt::Display for ListPaymentMethodsCustomerType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateCustomerCashBalanceSettingsReconciliationMode { +impl std::fmt::Debug for ListPaymentMethodsCustomerType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateCustomerCashBalanceSettingsReconciliationMode { +impl serde::Serialize for ListPaymentMethodsCustomerType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1152,172 +1135,92 @@ impl serde::Serialize for UpdateCustomerCashBalanceSettingsReconciliationMode { serializer.serialize_str(self.as_str()) } } -/// Default invoice settings for this customer. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerInvoiceSettings<'a> { - /// The list of up to 4 default custom fields to be displayed on invoices for this customer. - /// When updating, pass an empty string to remove previously-defined fields. - #[serde(skip_serializing_if = "Option::is_none")] - pub custom_fields: Option<&'a [CustomFieldParams<'a>]>, - /// ID of a payment method that's attached to the customer, to be used as the customer's default payment method for subscriptions and invoices. - #[serde(skip_serializing_if = "Option::is_none")] - pub default_payment_method: Option<&'a str>, - /// Default footer to be displayed on invoices for this customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub footer: Option<&'a str>, - /// Default options for invoice PDF rendering for this customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub rendering_options: Option<UpdateCustomerInvoiceSettingsRenderingOptions>, -} -impl<'a> UpdateCustomerInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() +impl<'a> ListPaymentMethodsCustomer<'a> { + /// Returns a list of PaymentMethods for a given Customer + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_types::List<stripe_shared::PaymentMethod>> { + client.get_query(&format!("/customers/{customer}/payment_methods"), self) + } + pub fn paginate(self, customer: &stripe_shared::CustomerId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentMethod>> { + stripe::ListPaginator::from_list_params(&format!("/customers/{customer}/payment_methods"), self) } } -/// Default options for invoice PDF rendering for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerInvoiceSettingsRenderingOptions { - /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. - /// One of `exclude_tax` or `include_inclusive_tax`. - /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. - /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. +pub struct RetrievePaymentMethodCustomer<'a> { + /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: Option<UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay>, + pub expand: Option<&'a [&'a str]>, } -impl UpdateCustomerInvoiceSettingsRenderingOptions { +impl<'a> RetrievePaymentMethodCustomer<'a> { pub fn new() -> Self { Self::default() } } -/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. -/// One of `exclude_tax` or `include_inclusive_tax`. -/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. -/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { - ExcludeTax, - IncludeInclusiveTax, -} -impl UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { - pub fn as_str(self) -> &'static str { - use UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*; - match self { - ExcludeTax => "exclude_tax", - IncludeInclusiveTax => "include_inclusive_tax", - } - } -} - -impl std::str::FromStr for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*; - match s { - "exclude_tax" => Ok(ExcludeTax), - "include_inclusive_tax" => Ok(IncludeInclusiveTax), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl<'a> RetrievePaymentMethodCustomer<'a> { + /// Retrieves a PaymentMethod object for a given Customer. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, payment_method: &str) -> stripe::Response<stripe_shared::PaymentMethod> { + client.get_query(&format!("/customers/{customer}/payment_methods/{payment_method}"), self) } } -/// Tax details about the customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerTax<'a> { - /// A recent IP address of the customer used for tax reporting and tax location inference. - /// Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. - /// We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes. +pub struct BalanceTransactionsCustomer<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. #[serde(skip_serializing_if = "Option::is_none")] - pub ip_address: Option<&'a str>, - /// A flag that indicates when Stripe should validate the customer tax location. - /// Defaults to `deferred`. + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. #[serde(skip_serializing_if = "Option::is_none")] - pub validate_location: Option<UpdateCustomerTaxValidateLocation>, + pub starting_after: Option<&'a str>, } -impl<'a> UpdateCustomerTax<'a> { +impl<'a> BalanceTransactionsCustomer<'a> { pub fn new() -> Self { Self::default() } } -/// A flag that indicates when Stripe should validate the customer tax location. -/// Defaults to `deferred`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateCustomerTaxValidateLocation { - Deferred, - Immediately, -} -impl UpdateCustomerTaxValidateLocation { - pub fn as_str(self) -> &'static str { - use UpdateCustomerTaxValidateLocation::*; - match self { - Deferred => "deferred", - Immediately => "immediately", - } - } -} - -impl std::str::FromStr for UpdateCustomerTaxValidateLocation { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateCustomerTaxValidateLocation::*; - match s { - "deferred" => Ok(Deferred), - "immediately" => Ok(Immediately), - _ => Err(()), - } +impl<'a> BalanceTransactionsCustomer<'a> { + /// Returns a list of transactions that updated the customer’s [balances](https://stripe.com/docs/billing/customer/balance). + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { + client.get_query(&format!("/customers/{customer}/balance_transactions"), self) } -} -impl std::fmt::Display for UpdateCustomerTaxValidateLocation { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + pub fn paginate(self, customer: &stripe_shared::CustomerId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { + stripe::ListPaginator::from_list_params(&format!("/customers/{customer}/balance_transactions"), self) } } - -impl std::fmt::Debug for UpdateCustomerTaxValidateLocation { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct FundCashBalanceCustomer<'a> { + /// Amount to be used for this test cash balance transaction. + /// A positive integer representing how much to fund in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to fund $1.00 or 100 to fund ¥100, a zero-decimal currency). + pub amount: i64, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + pub currency: stripe_types::Currency, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A description of the test funding. + /// This simulates free-text references supplied by customers when making bank transfers to their cash balance. + /// You can use this to test how Stripe's [reconciliation algorithm](https://stripe.com/docs/payments/customer-balance/reconciliation) applies to different user inputs. + #[serde(skip_serializing_if = "Option::is_none")] + pub reference: Option<&'a str>, } -impl serde::Serialize for UpdateCustomerTaxValidateLocation { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl<'a> FundCashBalanceCustomer<'a> { + pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { + Self { amount, currency, expand: None, reference: None } } } -impl<'a> UpdateCustomer<'a> { - /// Updates the specified customer by setting the values of the parameters passed. - /// Any parameters not provided will be left unchanged. - /// For example, if you pass the **source** parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future. - /// When you update a customer to a new valid card source by passing the **source** parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the `past_due` state, then the latest open invoice for the subscription with automatic collection enabled will be retried. - /// This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice. - /// Changing the **default_source** for a customer will not trigger this behavior. - /// - /// This request accepts mostly the same arguments as the customer creation call. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::Customer> { - client.send_form(&format!("/customers/{customer}"), self, http_types::Method::Post) +impl<'a> FundCashBalanceCustomer<'a> { + /// Create an incoming testmode bank transfer + pub fn send(&self, client: &stripe::Client, customer: &str) -> stripe::Response<stripe_shared::CustomerCashBalanceTransaction> { + client.send_form(&format!("/test_helpers/customers/{customer}/fund_cash_balance"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -1334,11 +1237,7 @@ pub struct CreateFundingInstructionsCustomer<'a> { pub funding_type: CreateFundingInstructionsCustomerFundingType, } impl<'a> CreateFundingInstructionsCustomer<'a> { - pub fn new( - bank_transfer: CreateFundingInstructionsCustomerBankTransfer<'a>, - currency: stripe_types::Currency, - funding_type: CreateFundingInstructionsCustomerFundingType, - ) -> Self { + pub fn new(bank_transfer: CreateFundingInstructionsCustomerBankTransfer<'a>, currency: stripe_types::Currency, funding_type: CreateFundingInstructionsCustomerFundingType) -> Self { Self { bank_transfer, currency, expand: None, funding_type } } } @@ -1353,10 +1252,9 @@ pub struct CreateFundingInstructionsCustomerBankTransfer<'a> { /// /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. #[serde(skip_serializing_if = "Option::is_none")] - pub requested_address_types: - Option<&'a [CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes]>, + pub requested_address_types: Option<&'a [CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes]>, /// The type of the `bank_transfer` - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateFundingInstructionsCustomerBankTransferType, } impl<'a> CreateFundingInstructionsCustomerBankTransfer<'a> { @@ -1536,52 +1434,21 @@ impl<'a> CreateFundingInstructionsCustomer<'a> { /// If funding instructions have already been created for a given customer, the same. /// funding instructions will be retrieved. /// In other words, we will return the same funding instructions each time. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::FundingInstructions> { - client.send_form( - &format!("/customers/{customer}/funding_instructions"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::FundingInstructions> { + client.send_form(&format!("/customers/{customer}/funding_instructions"), self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct FundCashBalanceCustomer<'a> { - /// Amount to be used for this test cash balance transaction. - /// A positive integer representing how much to fund in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to fund $1.00 or 100 to fund ¥100, a zero-decimal currency). - pub amount: i64, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A description of the test funding. - /// This simulates free-text references supplied by customers when making bank transfers to their cash balance. - /// You can use this to test how Stripe's [reconciliation algorithm](https://stripe.com/docs/payments/customer-balance/reconciliation) applies to different user inputs. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference: Option<&'a str>, -} -impl<'a> FundCashBalanceCustomer<'a> { - pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { - Self { amount, currency, expand: None, reference: None } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteDiscountCustomer {} +impl DeleteDiscountCustomer { + pub fn new() -> Self { + Self::default() } } -impl<'a> FundCashBalanceCustomer<'a> { - /// Create an incoming testmode bank transfer - pub fn send( - &self, - client: &stripe::Client, - customer: &str, - ) -> stripe::Response<stripe_shared::CustomerCashBalanceTransaction> { - client.send_form( - &format!("/test_helpers/customers/{customer}/fund_cash_balance"), - self, - http_types::Method::Post, - ) +impl DeleteDiscountCustomer { + /// Removes the currently applied discount on a customer. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::DeletedDiscount> { + client.send_form(&format!("/customers/{customer}/discount"), self, http_types::Method::Delete) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -1622,6 +1489,19 @@ impl<'a> CustomFieldParams<'a> { Self { name, value } } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct TaxParam<'a> { + /// A recent IP address of the customer used for tax reporting and tax location inference. + /// Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. + /// We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes. + #[serde(skip_serializing_if = "Option::is_none")] + pub ip_address: Option<&'a str>, +} +impl<'a> TaxParam<'a> { + pub fn new() -> Self { + Self::default() + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CustomerShipping<'a> { /// Customer shipping address. diff --git a/generated/stripe_core/src/customer_balance_transaction/requests.rs b/generated/stripe_core/src/customer_balance_transaction/requests.rs index b9e868401..5f5d4a58b 100644 --- a/generated/stripe_core/src/customer_balance_transaction/requests.rs +++ b/generated/stripe_core/src/customer_balance_transaction/requests.rs @@ -1,4 +1,21 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveCustomerBalanceTransaction<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveCustomerBalanceTransaction<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveCustomerBalanceTransaction<'a> { + /// Retrieves a specific customer balance transaction that updated the customer’s [balances](https://stripe.com/docs/billing/customer/balance). + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, transaction: &str) -> stripe::Response<stripe_shared::CustomerBalanceTransaction> { + client.get_query(&format!("/customers/{customer}/balance_transactions/{transaction}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListCustomerCustomerBalanceTransaction<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -25,43 +42,11 @@ impl<'a> ListCustomerCustomerBalanceTransaction<'a> { } impl<'a> ListCustomerCustomerBalanceTransaction<'a> { /// Returns a list of transactions that updated the customer’s [balances](https://stripe.com/docs/billing/customer/balance). - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { client.get_query(&format!("/customers/{customer}/balance_transactions"), self) } - pub fn paginate( - self, - customer: &stripe_shared::CustomerId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { - stripe::ListPaginator::from_list_params( - &format!("/customers/{customer}/balance_transactions"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveCustomerBalanceTransaction<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveCustomerBalanceTransaction<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveCustomerBalanceTransaction<'a> { - /// Retrieves a specific customer balance transaction that updated the customer’s [balances](https://stripe.com/docs/billing/customer/balance). - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - transaction: &str, - ) -> stripe::Response<stripe_shared::CustomerBalanceTransaction> { - client.get_query(&format!("/customers/{customer}/balance_transactions/{transaction}"), self) + pub fn paginate(self, customer: &stripe_shared::CustomerId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CustomerBalanceTransaction>> { + stripe::ListPaginator::from_list_params(&format!("/customers/{customer}/balance_transactions"), self) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -93,16 +78,8 @@ impl<'a> CreateCustomerCustomerBalanceTransaction<'a> { } impl<'a> CreateCustomerCustomerBalanceTransaction<'a> { /// Creates an immutable transaction that updates the customer’s credit [balance](https://stripe.com/docs/billing/customer/balance). - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::CustomerBalanceTransaction> { - client.send_form( - &format!("/customers/{customer}/balance_transactions"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::CustomerBalanceTransaction> { + client.send_form(&format!("/customers/{customer}/balance_transactions"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -127,16 +104,7 @@ impl<'a> UpdateCustomerBalanceTransaction<'a> { } impl<'a> UpdateCustomerBalanceTransaction<'a> { /// Most credit balance transaction fields are immutable, but you may update its `description` and `metadata`. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - transaction: &str, - ) -> stripe::Response<stripe_shared::CustomerBalanceTransaction> { - client.send_form( - &format!("/customers/{customer}/balance_transactions/{transaction}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, transaction: &str) -> stripe::Response<stripe_shared::CustomerBalanceTransaction> { + client.send_form(&format!("/customers/{customer}/balance_transactions/{transaction}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/src/customer_cash_balance_transaction/requests.rs b/generated/stripe_core/src/customer_cash_balance_transaction/requests.rs index 7ffb1c3aa..86f285580 100644 --- a/generated/stripe_core/src/customer_cash_balance_transaction/requests.rs +++ b/generated/stripe_core/src/customer_cash_balance_transaction/requests.rs @@ -1,4 +1,21 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveCustomerCashBalanceTransaction<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveCustomerCashBalanceTransaction<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveCustomerCashBalanceTransaction<'a> { + /// Retrieves a specific cash balance transaction, which updated the customer’s [cash balance](https://stripe.com/docs/payments/customer-balance). + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, transaction: &str) -> stripe::Response<stripe_shared::CustomerCashBalanceTransaction> { + client.get_query(&format!("/customers/{customer}/cash_balance_transactions/{transaction}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListCustomerCustomerCashBalanceTransaction<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -25,46 +42,10 @@ impl<'a> ListCustomerCustomerCashBalanceTransaction<'a> { } impl<'a> ListCustomerCustomerCashBalanceTransaction<'a> { /// Returns a list of transactions that modified the customer’s [cash balance](https://stripe.com/docs/payments/customer-balance). - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CustomerCashBalanceTransaction>> { + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_types::List<stripe_shared::CustomerCashBalanceTransaction>> { client.get_query(&format!("/customers/{customer}/cash_balance_transactions"), self) } - pub fn paginate( - self, - customer: &stripe_shared::CustomerId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CustomerCashBalanceTransaction>> - { - stripe::ListPaginator::from_list_params( - &format!("/customers/{customer}/cash_balance_transactions"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveCustomerCashBalanceTransaction<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveCustomerCashBalanceTransaction<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveCustomerCashBalanceTransaction<'a> { - /// Retrieves a specific cash balance transaction, which updated the customer’s [cash balance](https://stripe.com/docs/payments/customer-balance). - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - transaction: &str, - ) -> stripe::Response<stripe_shared::CustomerCashBalanceTransaction> { - client.get_query( - &format!("/customers/{customer}/cash_balance_transactions/{transaction}"), - self, - ) + pub fn paginate(self, customer: &stripe_shared::CustomerId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CustomerCashBalanceTransaction>> { + stripe::ListPaginator::from_list_params(&format!("/customers/{customer}/cash_balance_transactions"), self) } } diff --git a/generated/stripe_core/src/customer_session/mod.rs b/generated/stripe_core/src/customer_session/mod.rs deleted file mode 100644 index 2228c469b..000000000 --- a/generated/stripe_core/src/customer_session/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "customer_session")] -mod requests; -pub(crate) mod types; -#[cfg(feature = "customer_session")] -pub use requests::*; diff --git a/generated/stripe_core/src/customer_session/requests.rs b/generated/stripe_core/src/customer_session/requests.rs deleted file mode 100644 index 958250f84..000000000 --- a/generated/stripe_core/src/customer_session/requests.rs +++ /dev/null @@ -1,58 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCustomerSession<'a> { - /// Configuration for each component. Exactly 1 component must be enabled. - pub components: CreateCustomerSessionComponents, - /// The ID of an existing customer for which to create the customer session. - pub customer: &'a str, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CreateCustomerSession<'a> { - pub fn new(components: CreateCustomerSessionComponents, customer: &'a str) -> Self { - Self { components, customer, expand: None } - } -} -/// Configuration for each component. Exactly 1 component must be enabled. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateCustomerSessionComponents { - /// Configuration for buy button. - #[serde(skip_serializing_if = "Option::is_none")] - pub buy_button: Option<CreateCustomerSessionComponentsBuyButton>, - /// Configuration for the pricing table. - #[serde(skip_serializing_if = "Option::is_none")] - pub pricing_table: Option<CreateCustomerSessionComponentsPricingTable>, -} -impl CreateCustomerSessionComponents { - pub fn new() -> Self { - Self::default() - } -} -/// Configuration for buy button. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCustomerSessionComponentsBuyButton { - /// Whether the buy button is enabled. - pub enabled: bool, -} -impl CreateCustomerSessionComponentsBuyButton { - pub fn new(enabled: bool) -> Self { - Self { enabled } - } -} -/// Configuration for the pricing table. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateCustomerSessionComponentsPricingTable { - /// Whether the pricing table is enabled. - pub enabled: bool, -} -impl CreateCustomerSessionComponentsPricingTable { - pub fn new(enabled: bool) -> Self { - Self { enabled } - } -} -impl<'a> CreateCustomerSession<'a> { - /// Creates a customer session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_core::CustomerSession> { - client.send_form("/customer_sessions", self, http_types::Method::Post) - } -} diff --git a/generated/stripe_core/src/customer_session/types.rs b/generated/stripe_core/src/customer_session/types.rs deleted file mode 100644 index cbd2e4bb5..000000000 --- a/generated/stripe_core/src/customer_session/types.rs +++ /dev/null @@ -1,22 +0,0 @@ -/// A customer session allows you to grant client access to Stripe's frontend SDKs (like StripeJs) -/// control over a customer. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct CustomerSession { - /// The client secret of this customer session. - /// Used on the client to set up secure access to the given `customer`. - /// - /// The client secret can be used to provide access to `customer` from your frontend. - /// It should not be stored, logged, or exposed to anyone other than the relevant customer. - /// Make sure that you have TLS enabled on any page that includes the client secret. - pub client_secret: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub components: Option<stripe_core::CustomerSessionResourceComponents>, - /// Time at which the object was created. Measured in seconds since the Unix epoch. - pub created: stripe_types::Timestamp, - /// The customer the customer session was created for. - pub customer: stripe_types::Expandable<stripe_shared::Customer>, - /// The timestamp at which this customer session will expire. - pub expires_at: stripe_types::Timestamp, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - pub livemode: bool, -} diff --git a/generated/stripe_core/src/customer_session_resource_components.rs b/generated/stripe_core/src/customer_session_resource_components.rs deleted file mode 100644 index 2539e1437..000000000 --- a/generated/stripe_core/src/customer_session_resource_components.rs +++ /dev/null @@ -1,6 +0,0 @@ -/// Configuration for the components supported by this customer session. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct CustomerSessionResourceComponents { - pub buy_button: stripe_core::CustomerSessionResourceComponentsResourceBuyButton, - pub pricing_table: stripe_core::CustomerSessionResourceComponentsResourcePricingTable, -} diff --git a/generated/stripe_core/src/customer_session_resource_components_resource_buy_button.rs b/generated/stripe_core/src/customer_session_resource_components_resource_buy_button.rs deleted file mode 100644 index 748cb2ded..000000000 --- a/generated/stripe_core/src/customer_session_resource_components_resource_buy_button.rs +++ /dev/null @@ -1,6 +0,0 @@ -/// This hash contains whether the buy button is enabled. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct CustomerSessionResourceComponentsResourceBuyButton { - /// Whether the buy button is enabled. - pub enabled: bool, -} diff --git a/generated/stripe_core/src/customer_session_resource_components_resource_pricing_table.rs b/generated/stripe_core/src/customer_session_resource_components_resource_pricing_table.rs deleted file mode 100644 index 6f8dbc4ed..000000000 --- a/generated/stripe_core/src/customer_session_resource_components_resource_pricing_table.rs +++ /dev/null @@ -1,6 +0,0 @@ -/// This hash contains whether the pricing table is enabled. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct CustomerSessionResourceComponentsResourcePricingTable { - /// Whether the pricing table is enabled. - pub enabled: bool, -} diff --git a/generated/stripe_core/src/dispute/requests.rs b/generated/stripe_core/src/dispute/requests.rs index 510a361ef..f00e505e6 100644 --- a/generated/stripe_core/src/dispute/requests.rs +++ b/generated/stripe_core/src/dispute/requests.rs @@ -33,10 +33,7 @@ impl<'a> ListDispute<'a> { } impl<'a> ListDispute<'a> { /// Returns a list of your disputes. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Dispute>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Dispute>> { client.get_query("/disputes", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Dispute>> { @@ -56,11 +53,7 @@ impl<'a> RetrieveDispute<'a> { } impl<'a> RetrieveDispute<'a> { /// Retrieves the dispute with the given ID. - pub fn send( - &self, - client: &stripe::Client, - dispute: &stripe_shared::DisputeId, - ) -> stripe::Response<stripe_shared::Dispute> { + pub fn send(&self, client: &stripe::Client, dispute: &stripe_shared::DisputeId) -> stripe::Response<stripe_shared::Dispute> { client.get_query(&format!("/disputes/{dispute}"), self) } } @@ -205,11 +198,7 @@ impl<'a> UpdateDispute<'a> { /// /// Depending on your dispute type, different evidence fields will give you a better chance of winning your dispute. /// To figure out which evidence fields to provide, see our [guide to dispute types](https://stripe.com/docs/disputes/categories). - pub fn send( - &self, - client: &stripe::Client, - dispute: &stripe_shared::DisputeId, - ) -> stripe::Response<stripe_shared::Dispute> { + pub fn send(&self, client: &stripe::Client, dispute: &stripe_shared::DisputeId) -> stripe::Response<stripe_shared::Dispute> { client.send_form(&format!("/disputes/{dispute}"), self, http_types::Method::Post) } } @@ -229,11 +218,7 @@ impl<'a> CloseDispute<'a> { /// /// The status of the dispute will change from `needs_response` to `lost`. /// _Closing a dispute is irreversible_. - pub fn send( - &self, - client: &stripe::Client, - dispute: &stripe_shared::DisputeId, - ) -> stripe::Response<stripe_shared::Dispute> { + pub fn send(&self, client: &stripe::Client, dispute: &stripe_shared::DisputeId) -> stripe::Response<stripe_shared::Dispute> { client.send_form(&format!("/disputes/{dispute}/close"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/src/event/requests.rs b/generated/stripe_core/src/event/requests.rs index e8b871e15..e9272abab 100644 --- a/generated/stripe_core/src/event/requests.rs +++ b/generated/stripe_core/src/event/requests.rs @@ -25,7 +25,7 @@ pub struct ListEvent<'a> { pub starting_after: Option<&'a str>, /// A string containing a specific event name, or group of events using * as a wildcard. /// The list will be filtered to include only events with a matching event property. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<&'a str>, /// An array of up to 20 strings containing specific event names. @@ -42,10 +42,7 @@ impl<'a> ListEvent<'a> { impl<'a> ListEvent<'a> { /// List events, going back up to 30 days. /// Each event data is rendered according to Stripe API version at its creation time, specified in [event object](https://stripe.com/docs/api/events/object) `api_version` attribute (not according to your current Stripe API version or `Stripe-Version` header). - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Event>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Event>> { client.get_query("/events", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Event>> { @@ -66,11 +63,7 @@ impl<'a> RetrieveEvent<'a> { impl<'a> RetrieveEvent<'a> { /// Retrieves the details of an event. /// Supply the unique identifier of the event, which you might have received in a webhook. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::EventId, - ) -> stripe::Response<stripe_shared::Event> { + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::EventId) -> stripe::Response<stripe_shared::Event> { client.get_query(&format!("/events/{id}"), self) } } diff --git a/generated/stripe_core/src/file/requests.rs b/generated/stripe_core/src/file/requests.rs index f456ef8e6..b94a8194a 100644 --- a/generated/stripe_core/src/file/requests.rs +++ b/generated/stripe_core/src/file/requests.rs @@ -32,10 +32,7 @@ impl<'a> ListFile<'a> { impl<'a> ListFile<'a> { /// Returns a list of the files that your account has access to. /// Stripe sorts and returns the files by their creation dates, placing the most recently created files at the top. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::File>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::File>> { client.get_query("/files", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::File>> { @@ -57,11 +54,7 @@ impl<'a> RetrieveFile<'a> { /// Retrieves the details of an existing file object. /// After you supply a unique file ID, Stripe returns the corresponding file object. /// Learn how to [access file contents](https://stripe.com/docs/file-upload#download-file-contents). - pub fn send( - &self, - client: &stripe::Client, - file: &stripe_shared::FileId, - ) -> stripe::Response<stripe_shared::File> { + pub fn send(&self, client: &stripe::Client, file: &stripe_shared::FileId) -> stripe::Response<stripe_shared::File> { client.get_query(&format!("/files/{file}"), self) } } diff --git a/generated/stripe_core/src/file_link/requests.rs b/generated/stripe_core/src/file_link/requests.rs index dbc96f3ff..94a8d496a 100644 --- a/generated/stripe_core/src/file_link/requests.rs +++ b/generated/stripe_core/src/file_link/requests.rs @@ -1,49 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListFileLink<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Filter links by their expiration status. By default, Stripe returns all links. - #[serde(skip_serializing_if = "Option::is_none")] - pub expired: Option<bool>, - /// Only return links for the given file. - #[serde(skip_serializing_if = "Option::is_none")] - pub file: Option<&'a str>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListFileLink<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListFileLink<'a> { - /// Returns a list of file links. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::FileLink>> { - client.get_query("/file_links", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::FileLink>> { - stripe::ListPaginator::from_list_params("/file_links", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveFileLink<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -56,11 +11,7 @@ impl<'a> RetrieveFileLink<'a> { } impl<'a> RetrieveFileLink<'a> { /// Retrieves the file link with the given ID. - pub fn send( - &self, - client: &stripe::Client, - link: &stripe_shared::FileLinkId, - ) -> stripe::Response<stripe_shared::FileLink> { + pub fn send(&self, client: &stripe::Client, link: &stripe_shared::FileLinkId) -> stripe::Response<stripe_shared::FileLink> { client.get_query(&format!("/file_links/{link}"), self) } } @@ -122,11 +73,49 @@ pub enum UpdateFileLinkExpiresAt { } impl<'a> UpdateFileLink<'a> { /// Updates an existing file link object. Expired links can no longer be updated. - pub fn send( - &self, - client: &stripe::Client, - link: &stripe_shared::FileLinkId, - ) -> stripe::Response<stripe_shared::FileLink> { + pub fn send(&self, client: &stripe::Client, link: &stripe_shared::FileLinkId) -> stripe::Response<stripe_shared::FileLink> { client.send_form(&format!("/file_links/{link}"), self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListFileLink<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Filter links by their expiration status. By default, Stripe returns all links. + #[serde(skip_serializing_if = "Option::is_none")] + pub expired: Option<bool>, + /// Only return links for the given file. + #[serde(skip_serializing_if = "Option::is_none")] + pub file: Option<&'a str>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListFileLink<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListFileLink<'a> { + /// Returns a list of file links. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::FileLink>> { + client.get_query("/file_links", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::FileLink>> { + stripe::ListPaginator::from_list_params("/file_links", self) + } +} diff --git a/generated/stripe_core/src/mandate/requests.rs b/generated/stripe_core/src/mandate/requests.rs index d244fe515..11ea49d0c 100644 --- a/generated/stripe_core/src/mandate/requests.rs +++ b/generated/stripe_core/src/mandate/requests.rs @@ -11,11 +11,7 @@ impl<'a> RetrieveMandate<'a> { } impl<'a> RetrieveMandate<'a> { /// Retrieves a Mandate object. - pub fn send( - &self, - client: &stripe::Client, - mandate: &stripe_shared::MandateId, - ) -> stripe::Response<stripe_shared::Mandate> { + pub fn send(&self, client: &stripe::Client, mandate: &stripe_shared::MandateId) -> stripe::Response<stripe_shared::Mandate> { client.get_query(&format!("/mandates/{mandate}"), self) } } diff --git a/generated/stripe_core/src/mod.rs b/generated/stripe_core/src/mod.rs index 45b93a5eb..9f10b0178 100644 --- a/generated/stripe_core/src/mod.rs +++ b/generated/stripe_core/src/mod.rs @@ -7,6 +7,9 @@ //! for requests mentioned in the `Core Resources` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_core; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub use balance::types::*; pub mod balance; #[doc(hidden)] @@ -37,29 +40,26 @@ pub use stripe_shared::charge_outcome::*; pub use stripe_shared::charge_transfer_data::*; pub use stripe_shared::connect_collection_transfer::*; pub mod customer; -pub use stripe_shared::customer::*;pub use stripe_shared::customer_acceptance::*;pub use stripe_shared::customer_balance_customer_balance_settings::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_adjusted_for_overdraft::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_applied_to_payment_transaction::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_eu_bank_transfer::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_gb_bank_transfer::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_jp_bank_transfer::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_us_bank_transfer::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_refunded_from_payment_transaction::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_transferred_to_balance::*;pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction::*; +pub use stripe_shared::customer::*; +pub use stripe_shared::customer_acceptance::*; +pub use stripe_shared::customer_balance_customer_balance_settings::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_adjusted_for_overdraft::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_applied_to_payment_transaction::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_eu_bank_transfer::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_gb_bank_transfer::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_jp_bank_transfer::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_us_bank_transfer::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_refunded_from_payment_transaction::*; +pub use stripe_shared::customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction::*; pub mod customer_balance_transaction; pub use stripe_shared::customer_balance_transaction::*; pub mod customer_cash_balance_transaction; -pub use customer_session::types::*; pub use stripe_shared::customer_cash_balance_transaction::*; -pub mod customer_session; -#[doc(hidden)] -pub mod customer_session_resource_components; -#[doc(inline)] -pub use customer_session_resource_components::*; -#[doc(hidden)] -pub mod customer_session_resource_components_resource_buy_button; -#[doc(inline)] -pub use customer_session_resource_components_resource_buy_button::*; -#[doc(hidden)] -pub mod customer_session_resource_components_resource_pricing_table; -#[doc(inline)] -pub use customer_session_resource_components_resource_pricing_table::*; pub use stripe_shared::customer_tax::*; pub use stripe_shared::customer_tax_location::*; pub use stripe_shared::deleted_customer::*; -pub use stripe_shared::destination_details_unimplemented::*; pub mod dispute; pub use stripe_shared::dispute::*; pub use stripe_shared::dispute_evidence::*; @@ -118,8 +118,6 @@ pub use stripe_shared::payment_intent_next_action_paynow_display_qr_code::*; pub use stripe_shared::payment_intent_next_action_pix_display_qr_code::*; pub use stripe_shared::payment_intent_next_action_promptpay_display_qr_code::*; pub use stripe_shared::payment_intent_next_action_redirect_to_url::*; -pub use stripe_shared::payment_intent_next_action_swish_handle_redirect_or_display_qr_code::*; -pub use stripe_shared::payment_intent_next_action_swish_qr_code::*; pub use stripe_shared::payment_intent_next_action_verify_with_microdeposits::*; pub use stripe_shared::payment_intent_next_action_wechat_pay_display_qr_code::*; pub use stripe_shared::payment_intent_next_action_wechat_pay_redirect_to_android_app::*; @@ -134,7 +132,6 @@ pub use stripe_shared::payment_intent_payment_method_options_link::*; pub use stripe_shared::payment_intent_payment_method_options_mandate_options_acss_debit::*; pub use stripe_shared::payment_intent_payment_method_options_mandate_options_sepa_debit::*; pub use stripe_shared::payment_intent_payment_method_options_sepa_debit::*; -pub use stripe_shared::payment_intent_payment_method_options_swish::*; pub use stripe_shared::payment_intent_payment_method_options_us_bank_account::*; pub use stripe_shared::payment_intent_processing::*; pub use stripe_shared::payment_intent_processing_customer_notification::*; @@ -145,9 +142,6 @@ pub use stripe_shared::payout::*; pub use stripe_shared::platform_tax_fee::*; pub mod refund; pub use stripe_shared::refund::*; -pub use stripe_shared::refund_destination_details::*; -pub use stripe_shared::refund_destination_details_card::*; -pub use stripe_shared::refund_destination_details_generic::*; pub use stripe_shared::refund_next_action::*; pub use stripe_shared::refund_next_action_display_details::*; pub use stripe_shared::reserve_transaction::*; diff --git a/generated/stripe_core/src/payment_intent/requests.rs b/generated/stripe_core/src/payment_intent/requests.rs index c56754f87..a076c282f 100644 --- a/generated/stripe_core/src/payment_intent/requests.rs +++ b/generated/stripe_core/src/payment_intent/requests.rs @@ -1,80 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListPaymentIntent<'a> { - /// A filter on the list, based on the object `created` field. - /// The value can be a string with an integer Unix timestamp or a dictionary with a number of different query options. - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// Only return PaymentIntents for the customer that this customer ID specifies. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListPaymentIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListPaymentIntent<'a> { - /// Returns a list of PaymentIntents. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::PaymentIntent>> { - client.get_query("/payment_intents", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentIntent>> { - stripe::ListPaginator::from_list_params("/payment_intents", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrievePaymentIntent<'a> { - /// The client secret of the PaymentIntent. - /// We require it if you use a publishable key to retrieve the source. - #[serde(skip_serializing_if = "Option::is_none")] - pub client_secret: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrievePaymentIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrievePaymentIntent<'a> { - /// Retrieves the details of a PaymentIntent that has previously been created. - /// - /// You can retrieve a PaymentIntent client-side using a publishable key when the `client_secret` is in the query string. - /// - /// - /// If you retrieve a PaymentIntent with a publishable key, it only returns a subset of properties. - /// Refer to the [payment intent](https://stripe.com/docs/api#payment_intent_object) object reference for more details. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { - client.get_query(&format!("/payment_intents/{intent}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct SearchPaymentIntent<'a> { /// Specifies which fields in the response should be expanded. @@ -105,15 +28,10 @@ impl<'a> SearchPaymentIntent<'a> { /// conditions, data is searchable in less than a minute. /// Occasionally, propagation of new or updated data can be up. /// to an hour behind during outages. Search functionality is not available to merchants in India. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::SearchList<stripe_shared::PaymentIntent>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::SearchList<stripe_shared::PaymentIntent>> { client.get_query("/payment_intents/search", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::PaymentIntent>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::PaymentIntent>> { stripe::ListPaginator::from_search_params("/payment_intents/search", self) } } @@ -140,7 +58,6 @@ pub struct CreatePaymentIntent<'a> { /// When creating and confirming a PaymentIntent at the same time, you can also provide the parameters available in the [Confirm API](https://stripe.com/docs/api/payment_intents/confirm). #[serde(skip_serializing_if = "Option::is_none")] pub confirm: Option<bool>, - /// Describes whether we can confirm this PaymentIntent automatically, or if it requires customer action to confirm the payment. #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_method: Option<stripe_shared::PaymentIntentConfirmationMethod>, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. @@ -233,8 +150,7 @@ pub struct CreatePaymentIntent<'a> { /// Shipping information for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] pub shipping: Option<CreatePaymentIntentShipping<'a>>, - /// For card charges, use [statement_descriptor_suffix](https://stripe.com/docs/payments/account/statement-descriptors#dynamic). - /// Otherwise, you can use this value as the complete description of a charge on your customers' statements. + /// For non-card charges, you can use this value as the complete description that appears on your customers’ statements. /// It must contain at least one letter and be 1–22 characters long. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, @@ -384,7 +300,7 @@ pub struct CreatePaymentIntentMandateDataCustomerAcceptance<'a> { pub online: Option<OnlineParam<'a>>, /// The type of customer acceptance information included with the Mandate. /// One of `online` or `offline`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreatePaymentIntentMandateDataCustomerAcceptanceType, } impl<'a> CreatePaymentIntentMandateDataCustomerAcceptance<'a> { @@ -554,13 +470,10 @@ pub struct CreatePaymentIntentPaymentMethodData<'a> { /// If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<CreatePaymentIntentPaymentMethodDataSofort>, - /// If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<&'a serde_json::Value>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreatePaymentIntentPaymentMethodDataType, /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. #[serde(skip_serializing_if = "Option::is_none")] @@ -607,7 +520,6 @@ impl<'a> CreatePaymentIntentPaymentMethodData<'a> { revolut_pay: None, sepa_debit: None, sofort: None, - swish: None, type_, us_bank_account: None, wechat_pay: None, @@ -1036,7 +948,6 @@ pub enum CreatePaymentIntentPaymentMethodDataIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -1059,7 +970,6 @@ impl CreatePaymentIntentPaymentMethodDataIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -1085,7 +995,6 @@ impl std::str::FromStr for CreatePaymentIntentPaymentMethodDataIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -1168,7 +1077,6 @@ pub enum CreatePaymentIntentPaymentMethodDataP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -1201,7 +1109,6 @@ impl CreatePaymentIntentPaymentMethodDataP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -1237,7 +1144,6 @@ impl std::str::FromStr for CreatePaymentIntentPaymentMethodDataP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -1389,7 +1295,6 @@ pub enum CreatePaymentIntentPaymentMethodDataType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -1428,7 +1333,6 @@ impl CreatePaymentIntentPaymentMethodDataType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -1470,7 +1374,6 @@ impl std::str::FromStr for CreatePaymentIntentPaymentMethodDataType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -1502,8 +1405,7 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataType { pub struct CreatePaymentIntentPaymentMethodDataUsBankAccount<'a> { /// Account holder type: individual or company. #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: - Option<CreatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType>, + pub account_holder_type: Option<CreatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType>, /// Account number of the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<&'a str>, @@ -1640,7 +1542,7 @@ pub struct CreatePaymentIntentPaymentMethodOptions<'a> { pub bancontact: Option<CreatePaymentIntentPaymentMethodOptionsBancontact>, /// If this is a `blik` PaymentMethod, this sub-hash contains details about the BLIK payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<CreatePaymentIntentPaymentMethodOptionsBlik<'a>>, + pub blik: Option<PaymentIntentPaymentMethodOptionsParam<'a>>, /// If this is a `boleto` PaymentMethod, this sub-hash contains details about the Boleto payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<CreatePaymentIntentPaymentMethodOptionsBoleto>, @@ -1701,7 +1603,7 @@ pub struct CreatePaymentIntentPaymentMethodOptions<'a> { /// If this is a `promptpay` PaymentMethod, this sub-hash contains details about the PromptPay payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option<CreatePaymentIntentPaymentMethodOptionsPromptpay>, - /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. + /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Demo Pay payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option<CreatePaymentIntentPaymentMethodOptionsRevolutPay>, /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. @@ -1710,9 +1612,6 @@ pub struct CreatePaymentIntentPaymentMethodOptions<'a> { /// If this is a `sofort` PaymentMethod, this sub-hash contains details about the SOFORT payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<CreatePaymentIntentPaymentMethodOptionsSofort>, - /// If this is a `Swish` PaymentMethod, this sub-hash contains details about the Swish payment method options. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<CreatePaymentIntentPaymentMethodOptionsSwish<'a>>, /// If this is a `us_bank_account` PaymentMethod, this sub-hash contains details about the US bank account payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccount<'a>>, @@ -1743,12 +1642,10 @@ pub struct CreatePaymentIntentPaymentMethodOptionsAcssDebit<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>, - /// Bank account verification method. + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>, + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsAcssDebit<'a> { pub fn new() -> Self { @@ -1769,12 +1666,10 @@ pub struct CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub interval_description: Option<&'a str>, /// Payment schedule for the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_schedule: - Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, + pub payment_schedule: Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: - Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, + pub transaction_type: Option<CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub fn new() -> Self { @@ -1799,9 +1694,7 @@ impl CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedu } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule::*; @@ -1813,24 +1706,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1854,9 +1741,7 @@ impl CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionTy } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -1867,24 +1752,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1948,7 +1827,7 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAcssDebitSetupF serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { Automatic, @@ -2132,8 +2011,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { /// /// If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. #[serde(skip_serializing_if = "Option::is_none")] - pub capture_method: - Option<CreatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod>, + pub capture_method: Option<CreatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod>, /// An internal identifier or reference that this payment corresponds to. /// You must limit the identifier to 128 characters, and it can only contain letters, numbers, underscores, backslashes, and dashes. /// This field differs from the statement descriptor and item name. @@ -2148,8 +2026,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { pub fn new() -> Self { @@ -2337,8 +2214,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsAuBecsDebit { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, } impl CreatePaymentIntentPaymentMethodOptionsAuBecsDebit { pub fn new() -> Self { @@ -2413,8 +2289,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsBacsDebit { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage>, } impl CreatePaymentIntentPaymentMethodOptionsBacsDebit { pub fn new() -> Self { @@ -2482,8 +2357,7 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBacsDebitSetupF pub struct CreatePaymentIntentPaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_language: - Option<CreatePaymentIntentPaymentMethodOptionsBancontactPreferredLanguage>, + pub preferred_language: Option<CreatePaymentIntentPaymentMethodOptionsBancontactPreferredLanguage>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -2493,8 +2367,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsBancontact { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage>, } impl CreatePaymentIntentPaymentMethodOptionsBancontact { pub fn new() -> Self { @@ -2606,79 +2479,6 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBancontactSetup serializer.serialize_str(self.as_str()) } } -/// If this is a `blik` PaymentMethod, this sub-hash contains details about the BLIK payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsBlik<'a> { - /// The 6-digit BLIK code that a customer has generated using their banking application. - /// Can only be set on confirmation. - #[serde(skip_serializing_if = "Option::is_none")] - pub code: Option<&'a str>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage>, -} -impl<'a> CreatePaymentIntentPaymentMethodOptionsBlik<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -/// -/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - None, -} -impl CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; - match self { - None => "none", - } - } -} - -impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; - match s { - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `boleto` PaymentMethod, this sub-hash contains details about the Boleto payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsBoleto { @@ -2793,30 +2593,23 @@ pub struct CreatePaymentIntentPaymentMethodOptionsCard<'a> { pub network: Option<CreatePaymentIntentPaymentMethodOptionsCardNetwork>, /// Request ability to [capture beyond the standard authorization validity window](https://stripe.com/docs/payments/extended-authorization) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_extended_authorization: - Option<CreatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, - /// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. + pub request_extended_authorization: Option<CreatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, + /// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_incremental_authorization: - Option<CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, + pub request_incremental_authorization: Option<CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_multicapture: - Option<CreatePaymentIntentPaymentMethodOptionsCardRequestMulticapture>, + pub request_multicapture: Option<CreatePaymentIntentPaymentMethodOptionsCardRequestMulticapture>, /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] pub request_overcapture: Option<CreatePaymentIntentPaymentMethodOptionsCardRequestOvercapture>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<CreatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>, - /// When enabled, using a card that is attached to a customer will require the CVC to be provided again (i.e. - /// using the cvc_token parameter). - #[serde(skip_serializing_if = "Option::is_none")] - pub require_cvc_recollection: Option<bool>, + pub request_three_d_secure: Option<CreatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -2839,10 +2632,6 @@ pub struct CreatePaymentIntentPaymentMethodOptionsCard<'a> { /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 17 characters. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix_kanji: Option<&'a str>, - /// If 3D Secure authentication was performed with a third-party provider, - /// the authentication details to use for this payment. - #[serde(skip_serializing_if = "Option::is_none")] - pub three_d_secure: Option<CreatePaymentIntentPaymentMethodOptionsCardThreeDSecure<'a>>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -2926,15 +2715,11 @@ pub struct CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlan { /// One of `month`. pub interval: CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, /// Type of installment plan, one of `fixed_count`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType, } impl CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlan { - pub fn new( - count: u64, - interval: CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, - type_: CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType, - ) -> Self { + pub fn new(count: u64, interval: CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, type_: CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType) -> Self { Self { count, interval, type_ } } } @@ -3056,8 +2841,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { pub start_date: stripe_types::Timestamp, /// Specifies the type of mandates supported. Possible values are `india`. #[serde(skip_serializing_if = "Option::is_none")] - pub supported_types: - Option<&'a [CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, + pub supported_types: Option<&'a [CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { pub fn new( @@ -3067,17 +2851,7 @@ impl<'a> CreatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { reference: &'a str, start_date: stripe_types::Timestamp, ) -> Self { - Self { - amount, - amount_type, - description: None, - end_date: None, - interval, - interval_count: None, - reference, - start_date, - supported_types: None, - } + Self { amount, amount_type, description: None, end_date: None, interval, interval_count: None, reference, start_date, supported_types: None } } } /// One of `fixed` or `maximum`. @@ -3347,7 +3121,7 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardRequestExte serializer.serialize_str(self.as_str()) } } -/// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. +/// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { IfAvailable, @@ -3363,9 +3137,7 @@ impl CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::*; @@ -3376,24 +3148,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3495,13 +3261,13 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardRequestOver } /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl CreatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -3509,7 +3275,6 @@ impl CreatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -3521,7 +3286,6 @@ impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCardRequestThr match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -3601,180 +3365,72 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardSetupFuture serializer.serialize_str(self.as_str()) } } -/// If 3D Secure authentication was performed with a third-party provider, -/// the authentication details to use for this payment. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsCardThreeDSecure<'a> { - /// The `transStatus` returned from the card Issuer’s ACS in the ARes. - #[serde(skip_serializing_if = "Option::is_none")] - pub ares_trans_status: - Option<CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus>, - /// The cryptogram, also known as the "authentication value" (AAV, CAVV or - /// AEVV). This value is 20 bytes, base64-encoded into a 28-character string. - /// (Most 3D Secure providers will return the base64-encoded version, which - /// is what you should specify here.) - pub cryptogram: &'a str, - /// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure - /// provider and indicates what degree of authentication was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub electronic_commerce_indicator: - Option<CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator>, - /// The exemption requested via 3DS and accepted by the issuer at authentication time. - #[serde(skip_serializing_if = "Option::is_none")] - pub exemption_indicator: - Option<CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator>, - /// Network specific 3DS fields. Network specific arguments require an - /// explicit card brand choice. The parameter `payment_method_options.card.network`` - /// must be populated accordingly - #[serde(skip_serializing_if = "Option::is_none")] - pub network_options: - Option<CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a>>, - /// The challenge indicator (`threeDSRequestorChallengeInd`) which was requested in the - /// AReq sent to the card Issuer's ACS. A string containing 2 digits from 01-99. - #[serde(skip_serializing_if = "Option::is_none")] - pub requestor_challenge_indicator: Option<&'a str>, - /// For 3D Secure 1, the XID. For 3D Secure 2, the Directory Server - /// Transaction ID (dsTransID). - pub transaction_id: &'a str, - /// The version of 3D Secure that was performed. - pub version: CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion, -} -impl<'a> CreatePaymentIntentPaymentMethodOptionsCardThreeDSecure<'a> { - pub fn new( - cryptogram: &'a str, - transaction_id: &'a str, - version: CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion, - ) -> Self { - Self { - ares_trans_status: None, - cryptogram, - electronic_commerce_indicator: None, - exemption_indicator: None, - network_options: None, - requestor_challenge_indicator: None, - transaction_id, - version, - } - } -} -/// The `transStatus` returned from the card Issuer’s ACS in the ARes. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - A, - C, - I, - N, - R, - U, - Y, -} -impl CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match self { - A => "A", - C => "C", - I => "I", - N => "N", - R => "R", - U => "U", - Y => "Y", - } - } -} - -impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match s { - "A" => Ok(A), - "C" => Ok(C), - "I" => Ok(I), - "N" => Ok(N), - "R" => Ok(R), - "U" => Ok(U), - "Y" => Ok(Y), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } +/// If this is a `cashapp` PaymentMethod, this sub-hash contains details about the Cash App Pay payment method options. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreatePaymentIntentPaymentMethodOptionsCashapp { + /// Controls when the funds will be captured from the customer's account. + /// + /// If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. + /// + /// If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. + #[serde(skip_serializing_if = "Option::is_none")] + pub capture_method: Option<CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod>, + /// Indicates that you intend to make future payments with this PaymentIntent's payment method. + /// + /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. + /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + /// + /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + /// + /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. + #[serde(skip_serializing_if = "Option::is_none")] + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage>, } -impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl CreatePaymentIntentPaymentMethodOptionsCashapp { + pub fn new() -> Self { + Self::default() } } -/// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure -/// provider and indicates what degree of authentication was performed. +/// Controls when the funds will be captured from the customer's account. +/// +/// If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. +/// +/// If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { +pub enum CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { + Manual, +} +impl CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; + use CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod::*; match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", + Manual => "manual", } } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; + use CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod::*; match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), + "manual" => Ok(Manual), _ => Err(()), } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3782,51 +3438,55 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// The exemption requested via 3DS and accepted by the issuer at authentication time. +/// Indicates that you intend to make future payments with this PaymentIntent's payment method. +/// +/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. +/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. +/// +/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). +/// +/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { - LowRisk, +pub enum CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { None, + OffSession, + OnSession, } -impl CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { +impl CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator::*; + use CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage::*; match self { - LowRisk => "low_risk", None => "none", + OffSession => "off_session", + OnSession => "on_session", } } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator::*; + use CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage::*; match s { - "low_risk" => Ok(LowRisk), "none" => Ok(None), + "off_session" => Ok(OffSession), + "on_session" => Ok(OnSession), _ => Err(()), } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3834,344 +3494,50 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Network specific 3DS fields. Network specific arguments require an -/// explicit card brand choice. The parameter `payment_method_options.card.network`` -/// must be populated accordingly +/// If this is a `customer balance` PaymentMethod, this sub-hash contains details about the customer balance payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - /// Cartes Bancaires-specific 3DS fields. +pub struct CreatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { + /// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. + #[serde(skip_serializing_if = "Option::is_none")] + pub bank_transfer: Option<CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, + /// The funding method type to be used when there are not enough funds in the customer balance. + /// Permitted values include: `bank_transfer`. + #[serde(skip_serializing_if = "Option::is_none")] + pub funding_type: Option<CreatePaymentIntentPaymentMethodOptionsCustomerBalanceFundingType>, + /// Indicates that you intend to make future payments with this PaymentIntent's payment method. + /// + /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. + /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. + /// + /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). + /// + /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option< - CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a>, - >, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, } -impl<'a> CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { +impl<'a> CreatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { pub fn new() -> Self { Self::default() } } -/// Cartes Bancaires-specific 3DS fields. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - /// The cryptogram calculation algorithm used by the card Issuer's ACS - /// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. - /// messageExtension: CB-AVALGO -pub cb_avalgo: CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - /// The exemption indicator returned from Cartes Bancaires in the ARes. - /// message extension: CB-EXEMPTION; string (4 characters) - /// This is a 3 byte bitmap (low significant byte first and most significant - /// bit first) that has been Base64 encoded -#[serde(skip_serializing_if = "Option::is_none")] -pub cb_exemption: Option<&'a str>, - /// The risk score returned from Cartes Bancaires in the ARes. - /// message extension: CB-SCORE; numeric value 0-99 -#[serde(skip_serializing_if = "Option::is_none")] -pub cb_score: Option<i64>, - -} -impl<'a> CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - pub fn new( - cb_avalgo: CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - ) -> Self { - Self { cb_avalgo, cb_exemption: None, cb_score: None } - } -} -/// The cryptogram calculation algorithm used by the card Issuer's ACS -/// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. -/// messageExtension: CB-AVALGO -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - V0, - V1, - V2, - V3, - V4, - A, -} -impl CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match self { - V0 => "0", - V1 => "1", - V2 => "2", - V3 => "3", - V4 => "4", - A => "A", - } - } -} - -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match s { - "0" => Ok(V0), - "1" => Ok(V1), - "2" => Ok(V2), - "3" => Ok(V3), - "4" => Ok(V4), - "A" => Ok(A), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The version of 3D Secure that was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - V1_0_2, - V2_1_0, - V2_2_0, -} -impl CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match self { - V1_0_2 => "1.0.2", - V2_1_0 => "2.1.0", - V2_2_0 => "2.2.0", - } - } -} - -impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match s { - "1.0.2" => Ok(V1_0_2), - "2.1.0" => Ok(V2_1_0), - "2.2.0" => Ok(V2_2_0), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// If this is a `cashapp` PaymentMethod, this sub-hash contains details about the Cash App Pay payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsCashapp { - /// Controls when the funds will be captured from the customer's account. - /// - /// If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. - /// - /// If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. - #[serde(skip_serializing_if = "Option::is_none")] - pub capture_method: Option<CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage>, -} -impl CreatePaymentIntentPaymentMethodOptionsCashapp { - pub fn new() -> Self { - Self::default() - } -} -/// Controls when the funds will be captured from the customer's account. -/// -/// If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. -/// -/// If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { - Manual, -} -impl CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod::*; - match self { - Manual => "manual", - } - } -} - -impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod::*; - match s { - "manual" => Ok(Manual), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -/// -/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { - None, - OffSession, - OnSession, -} -impl CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage::*; - match self { - None => "none", - OffSession => "off_session", - OnSession => "on_session", - } - } -} - -impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage::*; - match s { - "none" => Ok(None), - "off_session" => Ok(OffSession), - "on_session" => Ok(OnSession), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// If this is a `customer balance` PaymentMethod, this sub-hash contains details about the customer balance payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { - /// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. - #[serde(skip_serializing_if = "Option::is_none")] - pub bank_transfer: - Option<CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, - /// The funding method type to be used when there are not enough funds in the customer balance. - /// Permitted values include: `bank_transfer`. - #[serde(skip_serializing_if = "Option::is_none")] - pub funding_type: Option<CreatePaymentIntentPaymentMethodOptionsCustomerBalanceFundingType>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, -} -impl<'a> CreatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. +/// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { /// Configuration for the eu_bank_transfer funding type. -#[serde(skip_serializing_if = "Option::is_none")] -pub eu_bank_transfer: Option<EuBankTransferParams<'a>>, - /// List of address types that should be returned in the financial_addresses response. + #[serde(skip_serializing_if = "Option::is_none")] + pub eu_bank_transfer: Option<EuBankTransferParams<'a>>, + /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. -#[serde(skip_serializing_if = "Option::is_none")] -pub requested_address_types: Option<&'a [CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, - /// The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. -#[serde(rename = "type")] -pub type_: CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, - + #[serde(skip_serializing_if = "Option::is_none")] + pub requested_address_types: Option<&'a [CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, + /// The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, } impl<'a> CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { - pub fn new( - type_: CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, - ) -> Self { + pub fn new(type_: CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType) -> Self { Self { eu_bank_transfer: None, requested_address_types: None, type_ } } } @@ -4204,9 +3570,7 @@ impl CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequested } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes::*; @@ -4222,24 +3586,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5799,8 +5157,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsPromptpay { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage>, } impl CreatePaymentIntentPaymentMethodOptionsPromptpay { pub fn new() -> Self { @@ -5857,7 +5214,7 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsPromptpaySetupF serializer.serialize_str(self.as_str()) } } -/// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. +/// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Demo Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsRevolutPay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -5867,8 +5224,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsRevolutPay { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage>, } impl CreatePaymentIntentPaymentMethodOptionsRevolutPay { pub fn new() -> Self { @@ -5941,8 +5297,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { pub fn new() -> Self { @@ -6141,12 +5496,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsSofortSetupFutu serializer.serialize_str(self.as_str()) } } -/// If this is a `Swish` PaymentMethod, this sub-hash contains details about the Swish payment method options. +/// If this is a `us_bank_account` PaymentMethod, this sub-hash contains details about the US bank account payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsSwish<'a> { - /// The order ID displayed in the Swish app after the payment is authorized. +pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccount<'a> { + /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub reference: Option<&'a str>, + pub financial_connections: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, + /// Additional fields for network related functions + #[serde(skip_serializing_if = "Option::is_none")] + pub networks: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a>>, + /// Preferred transaction settlement speed + #[serde(skip_serializing_if = "Option::is_none")] + pub preferred_settlement_speed: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -6156,120 +5517,31 @@ pub struct CreatePaymentIntentPaymentMethodOptionsSwish<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>, + /// Verification method for the intent + #[serde(skip_serializing_if = "Option::is_none")] + pub verification_method: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } -impl<'a> CreatePaymentIntentPaymentMethodOptionsSwish<'a> { +impl<'a> CreatePaymentIntentPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { Self::default() } } -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -/// -/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - None, -} -impl CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match self { - None => "none", - } - } -} - -impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match s { - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// If this is a `us_bank_account` PaymentMethod, this sub-hash contains details about the US bank account payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccount<'a> { - /// Additional fields for Financial Connections Session creation - #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, - /// Additional fields for Mandate creation - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions>, - /// Additional fields for network related functions - #[serde(skip_serializing_if = "Option::is_none")] - pub networks: Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a>>, - /// Preferred transaction settlement speed - #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_settlement_speed: - Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>, - /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, -} -impl<'a> CreatePaymentIntentPaymentMethodOptionsUsBankAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Additional fields for Financial Connections Session creation -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { - /// The list of permissions to request. - /// If this parameter is passed, the `payment_method` permission must be included. - /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. - #[serde(skip_serializing_if = "Option::is_none")] - pub permissions: Option< - &'a [CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions], - >, - /// List of data features that you would like to retrieve upon account creation. - #[serde(skip_serializing_if = "Option::is_none")] - pub prefetch: Option< - &'a [CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch], - >, - /// For webview integrations only. - /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. - #[serde(skip_serializing_if = "Option::is_none")] - pub return_url: Option<&'a str>, +/// Additional fields for Financial Connections Session creation +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { + /// The list of permissions to request. + /// If this parameter is passed, the `payment_method` permission must be included. + /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. + #[serde(skip_serializing_if = "Option::is_none")] + pub permissions: Option<&'a [CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, + /// List of data features that you would like to retrieve upon account creation. + #[serde(skip_serializing_if = "Option::is_none")] + pub prefetch: Option<&'a [CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, + /// For webview integrations only. + /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. + #[serde(skip_serializing_if = "Option::is_none")] + pub return_url: Option<&'a str>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { pub fn new() -> Self { @@ -6298,9 +5570,7 @@ impl CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPer } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; @@ -6313,24 +5583,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -6342,113 +5606,38 @@ impl serde::Serialize #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } impl CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Additional fields for Mandate creation -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { - /// The method used to collect offline mandate customer acceptance. - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: - Option<CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod>, -} -impl CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { - pub fn new() -> Self { - Self::default() - } -} -/// The method used to collect offline mandate customer acceptance. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - Paper, -} -impl CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - pub fn as_str(self) -> &'static str { - use CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match self { - Paper => "paper", - } - } -} - -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match s { - "paper" => Ok(Paper), _ => Err(()), } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -6461,8 +5650,7 @@ impl serde::Serialize pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { /// Triggers validations to run across the selected networks #[serde(skip_serializing_if = "Option::is_none")] - pub requested: - Option<&'a [CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, + pub requested: Option<&'a [CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { pub fn new() -> Self { @@ -6531,9 +5719,7 @@ impl CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpee } } -impl std::str::FromStr - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::str::FromStr for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::*; @@ -6544,24 +5730,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::fmt::Display for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::fmt::Debug for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -6625,7 +5805,7 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsUsBankAccountSe serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, @@ -6691,8 +5871,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsWechatPay<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<CreatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage>, + pub setup_future_usage: Option<CreatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage>, } impl<'a> CreatePaymentIntentPaymentMethodOptionsWechatPay<'a> { pub fn new(client: CreatePaymentIntentPaymentMethodOptionsWechatPayClient) -> Self { @@ -6970,6 +6149,74 @@ impl<'a> CreatePaymentIntent<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListPaymentIntent<'a> { + /// A filter on the list, based on the object `created` field. + /// The value can be a string with an integer Unix timestamp or a dictionary with a number of different query options. + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// Only return PaymentIntents for the customer that this customer ID specifies. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListPaymentIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListPaymentIntent<'a> { + /// Returns a list of PaymentIntents. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::PaymentIntent>> { + client.get_query("/payment_intents", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentIntent>> { + stripe::ListPaginator::from_list_params("/payment_intents", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrievePaymentIntent<'a> { + /// The client secret of the PaymentIntent. + /// We require it if you use a publishable key to retrieve the source. + #[serde(skip_serializing_if = "Option::is_none")] + pub client_secret: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrievePaymentIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrievePaymentIntent<'a> { + /// Retrieves the details of a PaymentIntent that has previously been created. + /// + /// You can retrieve a PaymentIntent client-side using a publishable key when the `client_secret` is in the query string. + /// + /// + /// If you retrieve a PaymentIntent with a publishable key, it only returns a subset of properties. + /// Refer to the [payment intent](https://stripe.com/docs/api#payment_intent_object) object reference for more details. + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { + client.get_query(&format!("/payment_intents/{intent}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntent<'a> { /// Amount intended to be collected by this PaymentIntent. /// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). @@ -7043,9 +6290,8 @@ pub struct UpdatePaymentIntent<'a> { /// Shipping information for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] pub shipping: Option<UpdatePaymentIntentShipping<'a>>, - /// For card charges, use [statement_descriptor_suffix](https://stripe.com/docs/payments/account/statement-descriptors#dynamic). - /// Otherwise, you can use this value as the complete description of a charge on your customers' statements. - /// It must contain at least one letter and be 1–22 characters long. + /// For non-card charges, you can use this value as the complete description that appears on your customers’ statements. + /// Must contain at least one letter, maximum 22 characters. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, /// Provides information about a card payment that customers see on their statements. @@ -7173,13 +6419,10 @@ pub struct UpdatePaymentIntentPaymentMethodData<'a> { /// If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<UpdatePaymentIntentPaymentMethodDataSofort>, - /// If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<&'a serde_json::Value>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: UpdatePaymentIntentPaymentMethodDataType, /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. #[serde(skip_serializing_if = "Option::is_none")] @@ -7226,7 +6469,6 @@ impl<'a> UpdatePaymentIntentPaymentMethodData<'a> { revolut_pay: None, sepa_debit: None, sofort: None, - swish: None, type_, us_bank_account: None, wechat_pay: None, @@ -7655,7 +6897,6 @@ pub enum UpdatePaymentIntentPaymentMethodDataIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -7678,7 +6919,6 @@ impl UpdatePaymentIntentPaymentMethodDataIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -7704,7 +6944,6 @@ impl std::str::FromStr for UpdatePaymentIntentPaymentMethodDataIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -7787,7 +7026,6 @@ pub enum UpdatePaymentIntentPaymentMethodDataP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -7820,7 +7058,6 @@ impl UpdatePaymentIntentPaymentMethodDataP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -7856,7 +7093,6 @@ impl std::str::FromStr for UpdatePaymentIntentPaymentMethodDataP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -8008,7 +7244,6 @@ pub enum UpdatePaymentIntentPaymentMethodDataType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -8047,7 +7282,6 @@ impl UpdatePaymentIntentPaymentMethodDataType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -8089,7 +7323,6 @@ impl std::str::FromStr for UpdatePaymentIntentPaymentMethodDataType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -8121,8 +7354,7 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataType { pub struct UpdatePaymentIntentPaymentMethodDataUsBankAccount<'a> { /// Account holder type: individual or company. #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: - Option<UpdatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType>, + pub account_holder_type: Option<UpdatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType>, /// Account number of the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<&'a str>, @@ -8259,7 +7491,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptions<'a> { pub bancontact: Option<UpdatePaymentIntentPaymentMethodOptionsBancontact>, /// If this is a `blik` PaymentMethod, this sub-hash contains details about the BLIK payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<UpdatePaymentIntentPaymentMethodOptionsBlik<'a>>, + pub blik: Option<PaymentIntentPaymentMethodOptionsParam<'a>>, /// If this is a `boleto` PaymentMethod, this sub-hash contains details about the Boleto payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<UpdatePaymentIntentPaymentMethodOptionsBoleto>, @@ -8320,7 +7552,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptions<'a> { /// If this is a `promptpay` PaymentMethod, this sub-hash contains details about the PromptPay payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option<UpdatePaymentIntentPaymentMethodOptionsPromptpay>, - /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. + /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Demo Pay payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option<UpdatePaymentIntentPaymentMethodOptionsRevolutPay>, /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. @@ -8329,9 +7561,6 @@ pub struct UpdatePaymentIntentPaymentMethodOptions<'a> { /// If this is a `sofort` PaymentMethod, this sub-hash contains details about the SOFORT payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<UpdatePaymentIntentPaymentMethodOptionsSofort>, - /// If this is a `Swish` PaymentMethod, this sub-hash contains details about the Swish payment method options. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<UpdatePaymentIntentPaymentMethodOptionsSwish<'a>>, /// If this is a `us_bank_account` PaymentMethod, this sub-hash contains details about the US bank account payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccount<'a>>, @@ -8362,12 +7591,10 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsAcssDebit<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>, - /// Bank account verification method. + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>, + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsAcssDebit<'a> { pub fn new() -> Self { @@ -8388,12 +7615,10 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub interval_description: Option<&'a str>, /// Payment schedule for the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_schedule: - Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, + pub payment_schedule: Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: - Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, + pub transaction_type: Option<UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub fn new() -> Self { @@ -8418,9 +7643,7 @@ impl UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedu } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule::*; @@ -8432,24 +7655,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -8473,9 +7690,7 @@ impl UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionTy } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -8486,24 +7701,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -8567,7 +7776,7 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAcssDebitSetupF serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { Automatic, @@ -8751,8 +7960,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { /// /// If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. #[serde(skip_serializing_if = "Option::is_none")] - pub capture_method: - Option<UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod>, + pub capture_method: Option<UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod>, /// An internal identifier or reference that this payment corresponds to. /// You must limit the identifier to 128 characters, and it can only contain letters, numbers, underscores, backslashes, and dashes. /// This field differs from the statement descriptor and item name. @@ -8767,8 +7975,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { pub fn new() -> Self { @@ -8956,8 +8163,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsAuBecsDebit { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, } impl UpdatePaymentIntentPaymentMethodOptionsAuBecsDebit { pub fn new() -> Self { @@ -9032,8 +8238,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsBacsDebit { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage>, } impl UpdatePaymentIntentPaymentMethodOptionsBacsDebit { pub fn new() -> Self { @@ -9101,8 +8306,7 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBacsDebitSetupF pub struct UpdatePaymentIntentPaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_language: - Option<UpdatePaymentIntentPaymentMethodOptionsBancontactPreferredLanguage>, + pub preferred_language: Option<UpdatePaymentIntentPaymentMethodOptionsBancontactPreferredLanguage>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -9112,8 +8316,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsBancontact { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage>, } impl UpdatePaymentIntentPaymentMethodOptionsBancontact { pub fn new() -> Self { @@ -9225,79 +8428,6 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBancontactSetup serializer.serialize_str(self.as_str()) } } -/// If this is a `blik` PaymentMethod, this sub-hash contains details about the BLIK payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsBlik<'a> { - /// The 6-digit BLIK code that a customer has generated using their banking application. - /// Can only be set on confirmation. - #[serde(skip_serializing_if = "Option::is_none")] - pub code: Option<&'a str>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage>, -} -impl<'a> UpdatePaymentIntentPaymentMethodOptionsBlik<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -/// -/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - None, -} -impl UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; - match self { - None => "none", - } - } -} - -impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; - match s { - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `boleto` PaymentMethod, this sub-hash contains details about the Boleto payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsBoleto { @@ -9412,30 +8542,23 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsCard<'a> { pub network: Option<UpdatePaymentIntentPaymentMethodOptionsCardNetwork>, /// Request ability to [capture beyond the standard authorization validity window](https://stripe.com/docs/payments/extended-authorization) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_extended_authorization: - Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, - /// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. + pub request_extended_authorization: Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, + /// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_incremental_authorization: - Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, + pub request_incremental_authorization: Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_multicapture: - Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestMulticapture>, + pub request_multicapture: Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestMulticapture>, /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] pub request_overcapture: Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestOvercapture>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>, - /// When enabled, using a card that is attached to a customer will require the CVC to be provided again (i.e. - /// using the cvc_token parameter). - #[serde(skip_serializing_if = "Option::is_none")] - pub require_cvc_recollection: Option<bool>, + pub request_three_d_secure: Option<UpdatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -9458,10 +8581,6 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsCard<'a> { /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 17 characters. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix_kanji: Option<&'a str>, - /// If 3D Secure authentication was performed with a third-party provider, - /// the authentication details to use for this payment. - #[serde(skip_serializing_if = "Option::is_none")] - pub three_d_secure: Option<UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecure<'a>>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -9545,15 +8664,11 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlan { /// One of `month`. pub interval: UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, /// Type of installment plan, one of `fixed_count`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType, } impl UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlan { - pub fn new( - count: u64, - interval: UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, - type_: UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType, - ) -> Self { + pub fn new(count: u64, interval: UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, type_: UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType) -> Self { Self { count, interval, type_ } } } @@ -9675,8 +8790,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { pub start_date: stripe_types::Timestamp, /// Specifies the type of mandates supported. Possible values are `india`. #[serde(skip_serializing_if = "Option::is_none")] - pub supported_types: - Option<&'a [UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, + pub supported_types: Option<&'a [UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { pub fn new( @@ -9686,17 +8800,7 @@ impl<'a> UpdatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { reference: &'a str, start_date: stripe_types::Timestamp, ) -> Self { - Self { - amount, - amount_type, - description: None, - end_date: None, - interval, - interval_count: None, - reference, - start_date, - supported_types: None, - } + Self { amount, amount_type, description: None, end_date: None, interval, interval_count: None, reference, start_date, supported_types: None } } } /// One of `fixed` or `maximum`. @@ -9966,7 +9070,7 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardRequestExte serializer.serialize_str(self.as_str()) } } -/// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. +/// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { IfAvailable, @@ -9982,9 +9086,7 @@ impl UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::*; @@ -9995,24 +9097,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -10114,13 +9210,13 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardRequestOver } /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl UpdatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -10128,7 +9224,6 @@ impl UpdatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -10140,7 +9235,6 @@ impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsCardRequestThr match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -10220,399 +9314,6 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardSetupFuture serializer.serialize_str(self.as_str()) } } -/// If 3D Secure authentication was performed with a third-party provider, -/// the authentication details to use for this payment. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecure<'a> { - /// The `transStatus` returned from the card Issuer’s ACS in the ARes. - #[serde(skip_serializing_if = "Option::is_none")] - pub ares_trans_status: - Option<UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus>, - /// The cryptogram, also known as the "authentication value" (AAV, CAVV or - /// AEVV). This value is 20 bytes, base64-encoded into a 28-character string. - /// (Most 3D Secure providers will return the base64-encoded version, which - /// is what you should specify here.) - pub cryptogram: &'a str, - /// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure - /// provider and indicates what degree of authentication was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub electronic_commerce_indicator: - Option<UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator>, - /// The exemption requested via 3DS and accepted by the issuer at authentication time. - #[serde(skip_serializing_if = "Option::is_none")] - pub exemption_indicator: - Option<UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator>, - /// Network specific 3DS fields. Network specific arguments require an - /// explicit card brand choice. The parameter `payment_method_options.card.network`` - /// must be populated accordingly - #[serde(skip_serializing_if = "Option::is_none")] - pub network_options: - Option<UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a>>, - /// The challenge indicator (`threeDSRequestorChallengeInd`) which was requested in the - /// AReq sent to the card Issuer's ACS. A string containing 2 digits from 01-99. - #[serde(skip_serializing_if = "Option::is_none")] - pub requestor_challenge_indicator: Option<&'a str>, - /// For 3D Secure 1, the XID. For 3D Secure 2, the Directory Server - /// Transaction ID (dsTransID). - pub transaction_id: &'a str, - /// The version of 3D Secure that was performed. - pub version: UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion, -} -impl<'a> UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecure<'a> { - pub fn new( - cryptogram: &'a str, - transaction_id: &'a str, - version: UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion, - ) -> Self { - Self { - ares_trans_status: None, - cryptogram, - electronic_commerce_indicator: None, - exemption_indicator: None, - network_options: None, - requestor_challenge_indicator: None, - transaction_id, - version, - } - } -} -/// The `transStatus` returned from the card Issuer’s ACS in the ARes. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - A, - C, - I, - N, - R, - U, - Y, -} -impl UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match self { - A => "A", - C => "C", - I => "I", - N => "N", - R => "R", - U => "U", - Y => "Y", - } - } -} - -impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match s { - "A" => Ok(A), - "C" => Ok(C), - "I" => Ok(I), - "N" => Ok(N), - "R" => Ok(R), - "U" => Ok(U), - "Y" => Ok(Y), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure -/// provider and indicates what degree of authentication was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", - } - } -} - -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), - _ => Err(()), - } - } -} -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The exemption requested via 3DS and accepted by the issuer at authentication time. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { - LowRisk, - None, -} -impl UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator::*; - match self { - LowRisk => "low_risk", - None => "none", - } - } -} - -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator::*; - match s { - "low_risk" => Ok(LowRisk), - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Network specific 3DS fields. Network specific arguments require an -/// explicit card brand choice. The parameter `payment_method_options.card.network`` -/// must be populated accordingly -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - /// Cartes Bancaires-specific 3DS fields. - #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option< - UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a>, - >, -} -impl<'a> UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Cartes Bancaires-specific 3DS fields. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - /// The cryptogram calculation algorithm used by the card Issuer's ACS - /// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. - /// messageExtension: CB-AVALGO -pub cb_avalgo: UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - /// The exemption indicator returned from Cartes Bancaires in the ARes. - /// message extension: CB-EXEMPTION; string (4 characters) - /// This is a 3 byte bitmap (low significant byte first and most significant - /// bit first) that has been Base64 encoded -#[serde(skip_serializing_if = "Option::is_none")] -pub cb_exemption: Option<&'a str>, - /// The risk score returned from Cartes Bancaires in the ARes. - /// message extension: CB-SCORE; numeric value 0-99 -#[serde(skip_serializing_if = "Option::is_none")] -pub cb_score: Option<i64>, - -} -impl<'a> UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - pub fn new( - cb_avalgo: UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - ) -> Self { - Self { cb_avalgo, cb_exemption: None, cb_score: None } - } -} -/// The cryptogram calculation algorithm used by the card Issuer's ACS -/// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. -/// messageExtension: CB-AVALGO -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - V0, - V1, - V2, - V3, - V4, - A, -} -impl UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match self { - V0 => "0", - V1 => "1", - V2 => "2", - V3 => "3", - V4 => "4", - A => "A", - } - } -} - -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match s { - "0" => Ok(V0), - "1" => Ok(V1), - "2" => Ok(V2), - "3" => Ok(V3), - "4" => Ok(V4), - "A" => Ok(A), - _ => Err(()), - } - } -} -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The version of 3D Secure that was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - V1_0_2, - V2_1_0, - V2_2_0, -} -impl UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match self { - V1_0_2 => "1.0.2", - V2_1_0 => "2.1.0", - V2_2_0 => "2.2.0", - } - } -} - -impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match s { - "1.0.2" => Ok(V1_0_2), - "2.1.0" => Ok(V2_1_0), - "2.2.0" => Ok(V2_2_0), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `cashapp` PaymentMethod, this sub-hash contains details about the Cash App Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsCashapp { @@ -10747,8 +9448,7 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCashappSetupFut pub struct UpdatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { /// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. #[serde(skip_serializing_if = "Option::is_none")] - pub bank_transfer: - Option<UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, + pub bank_transfer: Option<UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. #[serde(skip_serializing_if = "Option::is_none")] @@ -10762,8 +9462,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { pub fn new() -> Self { @@ -10774,23 +9473,20 @@ impl<'a> UpdatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { /// Configuration for the eu_bank_transfer funding type. -#[serde(skip_serializing_if = "Option::is_none")] -pub eu_bank_transfer: Option<EuBankTransferParams<'a>>, - /// List of address types that should be returned in the financial_addresses response. + #[serde(skip_serializing_if = "Option::is_none")] + pub eu_bank_transfer: Option<EuBankTransferParams<'a>>, + /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. -#[serde(skip_serializing_if = "Option::is_none")] -pub requested_address_types: Option<&'a [UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, - /// The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. -#[serde(rename = "type")] -pub type_: UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, - + #[serde(skip_serializing_if = "Option::is_none")] + pub requested_address_types: Option<&'a [UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, + /// The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { - pub fn new( - type_: UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, - ) -> Self { + pub fn new(type_: UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType) -> Self { Self { eu_bank_transfer: None, requested_address_types: None, type_ } } } @@ -10823,9 +9519,7 @@ impl UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequested } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes::*; @@ -10841,24 +9535,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -12418,8 +11106,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsPromptpay { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage>, } impl UpdatePaymentIntentPaymentMethodOptionsPromptpay { pub fn new() -> Self { @@ -12476,7 +11163,7 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsPromptpaySetupF serializer.serialize_str(self.as_str()) } } -/// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. +/// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Demo Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsRevolutPay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -12486,8 +11173,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsRevolutPay { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage>, } impl UpdatePaymentIntentPaymentMethodOptionsRevolutPay { pub fn new() -> Self { @@ -12560,8 +11246,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { pub fn new() -> Self { @@ -12760,95 +11445,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsSofortSetupFutu serializer.serialize_str(self.as_str()) } } -/// If this is a `Swish` PaymentMethod, this sub-hash contains details about the Swish payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsSwish<'a> { - /// The order ID displayed in the Swish app after the payment is authorized. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference: Option<&'a str>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage>, -} -impl<'a> UpdatePaymentIntentPaymentMethodOptionsSwish<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -/// -/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - None, -} -impl UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match self { - None => "none", - } - } -} - -impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match s { - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `us_bank_account` PaymentMethod, this sub-hash contains details about the US bank account payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, - /// Additional fields for Mandate creation - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions>, + pub financial_connections: Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Additional fields for network related functions #[serde(skip_serializing_if = "Option::is_none")] pub networks: Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a>>, /// Preferred transaction settlement speed #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_settlement_speed: - Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, + pub preferred_settlement_speed: Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -12858,12 +11466,10 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccount<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>, - /// Bank account verification method. + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>, + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -12877,14 +11483,10 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnecti /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[serde(skip_serializing_if = "Option::is_none")] - pub permissions: Option< - &'a [UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions], - >, + pub permissions: Option<&'a [UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. #[serde(skip_serializing_if = "Option::is_none")] - pub prefetch: Option< - &'a [UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch], - >, + pub prefetch: Option<&'a [UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, /// For webview integrations only. /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. #[serde(skip_serializing_if = "Option::is_none")] @@ -12917,9 +11519,7 @@ impl UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPer } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; @@ -12932,24 +11532,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -12961,49 +11555,38 @@ impl serde::Serialize #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } impl UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -13011,122 +11594,57 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Additional fields for Mandate creation +/// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { - /// The method used to collect offline mandate customer acceptance. +pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { + /// Triggers validations to run across the selected networks #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: - Option<UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod>, + pub requested: Option<&'a [UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, } -impl UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { +impl<'a> UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { pub fn new() -> Self { Self::default() } } -/// The method used to collect offline mandate customer acceptance. +/// Triggers validations to run across the selected networks #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - Paper, +pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { + Ach, + UsDomesticWire, } -impl UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { +impl UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; + use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; match self { - Paper => "paper", + Ach => "ach", + UsDomesticWire => "us_domestic_wire", } } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; + use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; match s { - "paper" => Ok(Paper), + "ach" => Ok(Ach), + "us_domestic_wire" => Ok(UsDomesticWire), _ => Err(()), } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Additional fields for network related functions -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { - /// Triggers validations to run across the selected networks - #[serde(skip_serializing_if = "Option::is_none")] - pub requested: - Option<&'a [UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, -} -impl<'a> UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Triggers validations to run across the selected networks -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - Ach, - UsDomesticWire, -} -impl UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - pub fn as_str(self) -> &'static str { - use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; - match self { - Ach => "ach", - UsDomesticWire => "us_domestic_wire", - } - } -} - -impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; - match s { - "ach" => Ok(Ach), - "us_domestic_wire" => Ok(UsDomesticWire), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -13150,9 +11668,7 @@ impl UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpee } } -impl std::str::FromStr - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::str::FromStr for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::*; @@ -13163,24 +11679,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::fmt::Display for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::fmt::Debug for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -13244,7 +11754,7 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountSe serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, @@ -13310,8 +11820,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsWechatPay<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<UpdatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage>, + pub setup_future_usage: Option<UpdatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage>, } impl<'a> UpdatePaymentIntentPaymentMethodOptionsWechatPay<'a> { pub fn new(client: UpdatePaymentIntentPaymentMethodOptionsWechatPayClient) -> Self { @@ -13544,208 +12053,11 @@ impl<'a> UpdatePaymentIntent<'a> { /// always requires you to confirm the PaymentIntent again. If you prefer to /// update and confirm at the same time, we recommend updating properties through /// the [confirm API](https://stripe.com/docs/api/payment_intents/confirm) instead. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { client.send_form(&format!("/payment_intents/{intent}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ApplyCustomerBalancePaymentIntent<'a> { - /// Amount that you intend to apply to this PaymentIntent from the customer’s cash balance. - /// - /// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (for example, 100 cents to charge 1 USD or 100 to charge 100 JPY, a zero-decimal currency). - /// - /// The maximum amount is the amount of the PaymentIntent. - /// - /// When you omit the amount, it defaults to the remaining amount requested on the PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option<i64>, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - #[serde(skip_serializing_if = "Option::is_none")] - pub currency: Option<stripe_types::Currency>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> ApplyCustomerBalancePaymentIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ApplyCustomerBalancePaymentIntent<'a> { - /// Manually reconcile the remaining amount for a `customer_balance` PaymentIntent. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { - client.send_form( - &format!("/payment_intents/{intent}/apply_customer_balance"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelPaymentIntent<'a> { - /// Reason for canceling this PaymentIntent. - /// Possible values are: `duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`. - #[serde(skip_serializing_if = "Option::is_none")] - pub cancellation_reason: Option<CancelPaymentIntentCancellationReason>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CancelPaymentIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Reason for canceling this PaymentIntent. -/// Possible values are: `duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CancelPaymentIntentCancellationReason { - Abandoned, - Duplicate, - Fraudulent, - RequestedByCustomer, -} -impl CancelPaymentIntentCancellationReason { - pub fn as_str(self) -> &'static str { - use CancelPaymentIntentCancellationReason::*; - match self { - Abandoned => "abandoned", - Duplicate => "duplicate", - Fraudulent => "fraudulent", - RequestedByCustomer => "requested_by_customer", - } - } -} - -impl std::str::FromStr for CancelPaymentIntentCancellationReason { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CancelPaymentIntentCancellationReason::*; - match s { - "abandoned" => Ok(Abandoned), - "duplicate" => Ok(Duplicate), - "fraudulent" => Ok(Fraudulent), - "requested_by_customer" => Ok(RequestedByCustomer), - _ => Err(()), - } - } -} -impl std::fmt::Display for CancelPaymentIntentCancellationReason { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CancelPaymentIntentCancellationReason { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CancelPaymentIntentCancellationReason { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> CancelPaymentIntent<'a> { - /// You can cancel a PaymentIntent object when it’s in one of these statuses: `requires_payment_method`, `requires_capture`, `requires_confirmation`, `requires_action` or, [in rare cases](https://stripe.com/docs/payments/intents), `processing`. - /// - /// - /// After it’s canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. - /// For PaymentIntents with a `status` of `requires_capture`, the remaining `amount_capturable` is automatically refunded. - /// - /// - /// You can’t cancel the PaymentIntent for a Checkout Session. - /// [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { - client.send_form( - &format!("/payment_intents/{intent}/cancel"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CapturePaymentIntent<'a> { - /// The amount to capture from the PaymentIntent, which must be less than or equal to the original amount. - /// Any additional amount is automatically refunded. - /// Defaults to the full `amount_capturable` if it's not provided. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount_to_capture: Option<i64>, - /// The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. - /// The amount of the application fee collected will be capped at the total payment amount. - /// For more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). - #[serde(skip_serializing_if = "Option::is_none")] - pub application_fee_amount: Option<i64>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Defaults to `true`. - /// When capturing a PaymentIntent, setting `final_capture` to `false` notifies Stripe to not release the remaining uncaptured funds to make sure that they're captured in future requests. - /// You can only use this setting when [multicapture](https://stripe.com/docs/payments/multicapture) is available for PaymentIntents. - #[serde(skip_serializing_if = "Option::is_none")] - pub final_capture: Option<bool>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// For card charges, use [statement_descriptor_suffix](https://stripe.com/docs/payments/account/statement-descriptors#dynamic). - /// Otherwise, you can use this value as the complete description of a charge on your customers' statements. - /// It must contain at least one letter and be 1–22 characters long. - #[serde(skip_serializing_if = "Option::is_none")] - pub statement_descriptor: Option<&'a str>, - /// Provides information about a card payment that customers see on their statements. - /// Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. - /// The concatenated descriptor must be 1-22 characters long. - #[serde(skip_serializing_if = "Option::is_none")] - pub statement_descriptor_suffix: Option<&'a str>, - /// The parameters that you can use to automatically create a transfer after the payment - /// is captured. - /// Learn more about the [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). - #[serde(skip_serializing_if = "Option::is_none")] - pub transfer_data: Option<TransferDataUpdateParams>, -} -impl<'a> CapturePaymentIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CapturePaymentIntent<'a> { - /// Capture the funds of an existing uncaptured PaymentIntent when its status is `requires_capture`. - /// - /// Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. - /// - /// Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { - client.send_form( - &format!("/payment_intents/{intent}/capture"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntent<'a> { /// Controls when the funds will be captured from the customer's account. #[serde(skip_serializing_if = "Option::is_none")] @@ -13824,9 +12136,7 @@ pub struct ConfirmPaymentIntentSecretKeyParam<'a> { pub customer_acceptance: ConfirmPaymentIntentSecretKeyParamCustomerAcceptance<'a>, } impl<'a> ConfirmPaymentIntentSecretKeyParam<'a> { - pub fn new( - customer_acceptance: ConfirmPaymentIntentSecretKeyParamCustomerAcceptance<'a>, - ) -> Self { + pub fn new(customer_acceptance: ConfirmPaymentIntentSecretKeyParamCustomerAcceptance<'a>) -> Self { Self { customer_acceptance } } } @@ -13844,7 +12154,7 @@ pub struct ConfirmPaymentIntentSecretKeyParamCustomerAcceptance<'a> { pub online: Option<OnlineParam<'a>>, /// The type of customer acceptance information included with the Mandate. /// One of `online` or `offline`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ConfirmPaymentIntentSecretKeyParamCustomerAcceptanceType, } impl<'a> ConfirmPaymentIntentSecretKeyParamCustomerAcceptance<'a> { @@ -13905,9 +12215,7 @@ pub struct ConfirmPaymentIntentClientKeyParam<'a> { pub customer_acceptance: ConfirmPaymentIntentClientKeyParamCustomerAcceptance<'a>, } impl<'a> ConfirmPaymentIntentClientKeyParam<'a> { - pub fn new( - customer_acceptance: ConfirmPaymentIntentClientKeyParamCustomerAcceptance<'a>, - ) -> Self { + pub fn new(customer_acceptance: ConfirmPaymentIntentClientKeyParamCustomerAcceptance<'a>) -> Self { Self { customer_acceptance } } } @@ -13917,14 +12225,11 @@ pub struct ConfirmPaymentIntentClientKeyParamCustomerAcceptance<'a> { /// If this is a Mandate accepted online, this hash contains details about the online acceptance. pub online: ConfirmPaymentIntentClientKeyParamCustomerAcceptanceOnline<'a>, /// The type of customer acceptance information included with the Mandate. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ConfirmPaymentIntentClientKeyParamCustomerAcceptanceType, } impl<'a> ConfirmPaymentIntentClientKeyParamCustomerAcceptance<'a> { - pub fn new( - online: ConfirmPaymentIntentClientKeyParamCustomerAcceptanceOnline<'a>, - type_: ConfirmPaymentIntentClientKeyParamCustomerAcceptanceType, - ) -> Self { + pub fn new(online: ConfirmPaymentIntentClientKeyParamCustomerAcceptanceOnline<'a>, type_: ConfirmPaymentIntentClientKeyParamCustomerAcceptanceType) -> Self { Self { online, type_ } } } @@ -14100,13 +12405,10 @@ pub struct ConfirmPaymentIntentPaymentMethodData<'a> { /// If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<ConfirmPaymentIntentPaymentMethodDataSofort>, - /// If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<&'a serde_json::Value>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ConfirmPaymentIntentPaymentMethodDataType, /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. #[serde(skip_serializing_if = "Option::is_none")] @@ -14153,7 +12455,6 @@ impl<'a> ConfirmPaymentIntentPaymentMethodData<'a> { revolut_pay: None, sepa_debit: None, sofort: None, - swish: None, type_, us_bank_account: None, wechat_pay: None, @@ -14582,7 +12883,6 @@ pub enum ConfirmPaymentIntentPaymentMethodDataIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -14605,7 +12905,6 @@ impl ConfirmPaymentIntentPaymentMethodDataIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -14631,7 +12930,6 @@ impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodDataIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -14714,7 +13012,6 @@ pub enum ConfirmPaymentIntentPaymentMethodDataP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -14747,7 +13044,6 @@ impl ConfirmPaymentIntentPaymentMethodDataP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -14783,7 +13079,6 @@ impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodDataP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -14935,7 +13230,6 @@ pub enum ConfirmPaymentIntentPaymentMethodDataType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -14974,7 +13268,6 @@ impl ConfirmPaymentIntentPaymentMethodDataType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -15016,7 +13309,6 @@ impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodDataType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -15048,8 +13340,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataType { pub struct ConfirmPaymentIntentPaymentMethodDataUsBankAccount<'a> { /// Account holder type: individual or company. #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: - Option<ConfirmPaymentIntentPaymentMethodDataUsBankAccountAccountHolderType>, + pub account_holder_type: Option<ConfirmPaymentIntentPaymentMethodDataUsBankAccountAccountHolderType>, /// Account number of the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<&'a str>, @@ -15186,7 +13477,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptions<'a> { pub bancontact: Option<ConfirmPaymentIntentPaymentMethodOptionsBancontact>, /// If this is a `blik` PaymentMethod, this sub-hash contains details about the BLIK payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<ConfirmPaymentIntentPaymentMethodOptionsBlik<'a>>, + pub blik: Option<PaymentIntentPaymentMethodOptionsParam<'a>>, /// If this is a `boleto` PaymentMethod, this sub-hash contains details about the Boleto payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<ConfirmPaymentIntentPaymentMethodOptionsBoleto>, @@ -15247,7 +13538,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptions<'a> { /// If this is a `promptpay` PaymentMethod, this sub-hash contains details about the PromptPay payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option<ConfirmPaymentIntentPaymentMethodOptionsPromptpay>, - /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. + /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Demo Pay payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option<ConfirmPaymentIntentPaymentMethodOptionsRevolutPay>, /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. @@ -15256,9 +13547,6 @@ pub struct ConfirmPaymentIntentPaymentMethodOptions<'a> { /// If this is a `sofort` PaymentMethod, this sub-hash contains details about the SOFORT payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<ConfirmPaymentIntentPaymentMethodOptionsSofort>, - /// If this is a `Swish` PaymentMethod, this sub-hash contains details about the Swish payment method options. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<ConfirmPaymentIntentPaymentMethodOptionsSwish<'a>>, /// If this is a `us_bank_account` PaymentMethod, this sub-hash contains details about the US bank account payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccount<'a>>, @@ -15279,8 +13567,7 @@ impl<'a> ConfirmPaymentIntentPaymentMethodOptions<'a> { pub struct ConfirmPaymentIntentPaymentMethodOptionsAcssDebit<'a> { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a>>, + pub mandate_options: Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a>>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -15290,12 +13577,10 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsAcssDebit<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>, - /// Bank account verification method. + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>, + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsAcssDebit<'a> { pub fn new() -> Self { @@ -15316,12 +13601,10 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub interval_description: Option<&'a str>, /// Payment schedule for the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_schedule: - Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, + pub payment_schedule: Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: - Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, + pub transaction_type: Option<ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub fn new() -> Self { @@ -15346,9 +13629,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSched } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule::*; @@ -15360,24 +13641,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -15401,9 +13676,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionT } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -15414,24 +13687,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -15495,7 +13762,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitSetup serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { Automatic, @@ -15679,8 +13946,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { /// /// If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. #[serde(skip_serializing_if = "Option::is_none")] - pub capture_method: - Option<ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod>, + pub capture_method: Option<ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod>, /// An internal identifier or reference that this payment corresponds to. /// You must limit the identifier to 128 characters, and it can only contain letters, numbers, underscores, backslashes, and dashes. /// This field differs from the statement descriptor and item name. @@ -15695,8 +13961,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { pub fn new() -> Self { @@ -15771,9 +14036,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage { } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage::*; @@ -15783,9 +14046,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -15888,8 +14149,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebit { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, } impl ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebit { pub fn new() -> Self { @@ -15964,8 +14224,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsBacsDebit { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage>, } impl ConfirmPaymentIntentPaymentMethodOptionsBacsDebit { pub fn new() -> Self { @@ -16033,8 +14292,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBacsDebitSetup pub struct ConfirmPaymentIntentPaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_language: - Option<ConfirmPaymentIntentPaymentMethodOptionsBancontactPreferredLanguage>, + pub preferred_language: Option<ConfirmPaymentIntentPaymentMethodOptionsBancontactPreferredLanguage>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -16044,8 +14302,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsBancontact { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage>, } impl ConfirmPaymentIntentPaymentMethodOptionsBancontact { pub fn new() -> Self { @@ -16157,13 +14414,13 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBancontactSetu serializer.serialize_str(self.as_str()) } } -/// If this is a `blik` PaymentMethod, this sub-hash contains details about the BLIK payment method options. +/// If this is a `boleto` PaymentMethod, this sub-hash contains details about the Boleto payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsBlik<'a> { - /// The 6-digit BLIK code that a customer has generated using their banking application. - /// Can only be set on confirmation. +pub struct ConfirmPaymentIntentPaymentMethodOptionsBoleto { + /// The number of calendar days before a Boleto voucher expires. + /// For example, if you create a Boleto voucher on Monday and you set expires_after_days to 2, the Boleto invoice will expire on Wednesday at 23:59 America/Sao_Paulo time. #[serde(skip_serializing_if = "Option::is_none")] - pub code: Option<&'a str>, + pub expires_after_days: Option<u32>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -16173,9 +14430,9 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsBlik<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage>, } -impl<'a> ConfirmPaymentIntentPaymentMethodOptionsBlik<'a> { +impl ConfirmPaymentIntentPaymentMethodOptionsBoleto { pub fn new() -> Self { Self::default() } @@ -16189,40 +14446,46 @@ impl<'a> ConfirmPaymentIntentPaymentMethodOptionsBlik<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { +pub enum ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { None, + OffSession, + OnSession, } -impl ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { +impl ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; + use ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage::*; match self { None => "none", + OffSession => "off_session", + OnSession => "on_session", } } } -impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; + use ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage::*; match s { "none" => Ok(None), + "off_session" => Ok(OffSession), + "on_session" => Ok(OnSession), _ => Err(()), } } } -impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -16230,86 +14493,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutur serializer.serialize_str(self.as_str()) } } -/// If this is a `boleto` PaymentMethod, this sub-hash contains details about the Boleto payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsBoleto { - /// The number of calendar days before a Boleto voucher expires. - /// For example, if you create a Boleto voucher on Monday and you set expires_after_days to 2, the Boleto invoice will expire on Wednesday at 23:59 America/Sao_Paulo time. - #[serde(skip_serializing_if = "Option::is_none")] - pub expires_after_days: Option<u32>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage>, -} -impl ConfirmPaymentIntentPaymentMethodOptionsBoleto { - pub fn new() -> Self { - Self::default() - } -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -/// -/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { - None, - OffSession, - OnSession, -} -impl ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage::*; - match self { - None => "none", - OffSession => "off_session", - OnSession => "on_session", - } - } -} - -impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage::*; - match s { - "none" => Ok(None), - "off_session" => Ok(OffSession), - "on_session" => Ok(OnSession), - _ => Err(()), - } - } -} -impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Configuration for any card payments attempted on this PaymentIntent. +/// Configuration for any card payments attempted on this PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsCard<'a> { /// Controls when the funds will be captured from the customer's account. @@ -16344,30 +14528,23 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsCard<'a> { pub network: Option<ConfirmPaymentIntentPaymentMethodOptionsCardNetwork>, /// Request ability to [capture beyond the standard authorization validity window](https://stripe.com/docs/payments/extended-authorization) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_extended_authorization: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, - /// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. + pub request_extended_authorization: Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, + /// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_incremental_authorization: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, + pub request_incremental_authorization: Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] - pub request_multicapture: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestMulticapture>, + pub request_multicapture: Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestMulticapture>, /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. #[serde(skip_serializing_if = "Option::is_none")] pub request_overcapture: Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestOvercapture>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>, - /// When enabled, using a card that is attached to a customer will require the CVC to be provided again (i.e. - /// using the cvc_token parameter). - #[serde(skip_serializing_if = "Option::is_none")] - pub require_cvc_recollection: Option<bool>, + pub request_three_d_secure: Option<ConfirmPaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -16390,10 +14567,6 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsCard<'a> { /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 17 characters. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix_kanji: Option<&'a str>, - /// If 3D Secure authentication was performed with a third-party provider, - /// the authentication details to use for this payment. - #[serde(skip_serializing_if = "Option::is_none")] - pub three_d_secure: Option<ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecure<'a>>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -16477,15 +14650,11 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlan { /// One of `month`. pub interval: ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, /// Type of installment plan, one of `fixed_count`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanType, } impl ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlan { - pub fn new( - count: u64, - interval: ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, - type_: ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanType, - ) -> Self { + pub fn new(count: u64, interval: ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval, type_: ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanType) -> Self { Self { count, interval, type_ } } } @@ -16607,8 +14776,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { pub start_date: stripe_types::Timestamp, /// Specifies the type of mandates supported. Possible values are `india`. #[serde(skip_serializing_if = "Option::is_none")] - pub supported_types: - Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, + pub supported_types: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { pub fn new( @@ -16618,17 +14786,7 @@ impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { reference: &'a str, start_date: stripe_types::Timestamp, ) -> Self { - Self { - amount, - amount_type, - description: None, - end_date: None, - interval, - interval_count: None, - reference, - start_date, - supported_types: None, - } + Self { amount, amount_type, description: None, end_date: None, interval, interval_count: None, reference, start_date, supported_types: None } } } /// One of `fixed` or `maximum`. @@ -16748,9 +14906,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes::*; @@ -16760,9 +14916,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -16872,9 +15026,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization::*; @@ -16885,9 +15037,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -16906,7 +15056,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardRequestExt serializer.serialize_str(self.as_str()) } } -/// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. +/// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { IfAvailable, @@ -16922,9 +15072,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::*; @@ -16935,24 +15083,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -17054,13 +15196,13 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardRequestOve } /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl ConfirmPaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -17068,7 +15210,6 @@ impl ConfirmPaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -17080,7 +15221,6 @@ impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCardRequestTh match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -17160,391 +15300,6 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardSetupFutur serializer.serialize_str(self.as_str()) } } -/// If 3D Secure authentication was performed with a third-party provider, -/// the authentication details to use for this payment. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecure<'a> { - /// The `transStatus` returned from the card Issuer’s ACS in the ARes. - #[serde(skip_serializing_if = "Option::is_none")] - pub ares_trans_status: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus>, - /// The cryptogram, also known as the "authentication value" (AAV, CAVV or - /// AEVV). This value is 20 bytes, base64-encoded into a 28-character string. - /// (Most 3D Secure providers will return the base64-encoded version, which - /// is what you should specify here.) - pub cryptogram: &'a str, - /// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure - /// provider and indicates what degree of authentication was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub electronic_commerce_indicator: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator>, - /// The exemption requested via 3DS and accepted by the issuer at authentication time. - #[serde(skip_serializing_if = "Option::is_none")] - pub exemption_indicator: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator>, - /// Network specific 3DS fields. Network specific arguments require an - /// explicit card brand choice. The parameter `payment_method_options.card.network`` - /// must be populated accordingly - #[serde(skip_serializing_if = "Option::is_none")] - pub network_options: - Option<ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a>>, - /// The challenge indicator (`threeDSRequestorChallengeInd`) which was requested in the - /// AReq sent to the card Issuer's ACS. A string containing 2 digits from 01-99. - #[serde(skip_serializing_if = "Option::is_none")] - pub requestor_challenge_indicator: Option<&'a str>, - /// For 3D Secure 1, the XID. For 3D Secure 2, the Directory Server - /// Transaction ID (dsTransID). - pub transaction_id: &'a str, - /// The version of 3D Secure that was performed. - pub version: ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion, -} -impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecure<'a> { - pub fn new( - cryptogram: &'a str, - transaction_id: &'a str, - version: ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion, - ) -> Self { - Self { - ares_trans_status: None, - cryptogram, - electronic_commerce_indicator: None, - exemption_indicator: None, - network_options: None, - requestor_challenge_indicator: None, - transaction_id, - version, - } - } -} -/// The `transStatus` returned from the card Issuer’s ACS in the ARes. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - A, - C, - I, - N, - R, - U, - Y, -} -impl ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match self { - A => "A", - C => "C", - I => "I", - N => "N", - R => "R", - U => "U", - Y => "Y", - } - } -} - -impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match s { - "A" => Ok(A), - "C" => Ok(C), - "I" => Ok(I), - "N" => Ok(N), - "R" => Ok(R), - "U" => Ok(U), - "Y" => Ok(Y), - _ => Err(()), - } - } -} -impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure -/// provider and indicates what degree of authentication was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", - } - } -} - -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), - _ => Err(()), - } - } -} -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The exemption requested via 3DS and accepted by the issuer at authentication time. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { - LowRisk, - None, -} -impl ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator::*; - match self { - LowRisk => "low_risk", - None => "none", - } - } -} - -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator::*; - match s { - "low_risk" => Ok(LowRisk), - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Network specific 3DS fields. Network specific arguments require an -/// explicit card brand choice. The parameter `payment_method_options.card.network`` -/// must be populated accordingly -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - /// Cartes Bancaires-specific 3DS fields. - #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option< - ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a>, - >, -} -impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Cartes Bancaires-specific 3DS fields. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - /// The cryptogram calculation algorithm used by the card Issuer's ACS - /// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. - /// messageExtension: CB-AVALGO -pub cb_avalgo: ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - /// The exemption indicator returned from Cartes Bancaires in the ARes. - /// message extension: CB-EXEMPTION; string (4 characters) - /// This is a 3 byte bitmap (low significant byte first and most significant - /// bit first) that has been Base64 encoded -#[serde(skip_serializing_if = "Option::is_none")] -pub cb_exemption: Option<&'a str>, - /// The risk score returned from Cartes Bancaires in the ARes. - /// message extension: CB-SCORE; numeric value 0-99 -#[serde(skip_serializing_if = "Option::is_none")] -pub cb_score: Option<i64>, - -} -impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - pub fn new( - cb_avalgo: ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - ) -> Self { - Self { cb_avalgo, cb_exemption: None, cb_score: None } - } -} -/// The cryptogram calculation algorithm used by the card Issuer's ACS -/// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. -/// messageExtension: CB-AVALGO -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - V0, - V1, - V2, - V3, - V4, - A, -} -impl ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match self { - V0 => "0", - V1 => "1", - V2 => "2", - V3 => "3", - V4 => "4", - A => "A", - } - } -} - -impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match s { - "0" => Ok(V0), -"1" => Ok(V1), -"2" => Ok(V2), -"3" => Ok(V3), -"4" => Ok(V4), -"A" => Ok(A), -_ => Err(()) - - } - } -} -impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { - serializer.serialize_str(self.as_str()) - } -} -/// The version of 3D Secure that was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - V1_0_2, - V2_1_0, - V2_2_0, -} -impl ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match self { - V1_0_2 => "1.0.2", - V2_1_0 => "2.1.0", - V2_2_0 => "2.2.0", - } - } -} - -impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match s { - "1.0.2" => Ok(V1_0_2), - "2.1.0" => Ok(V2_1_0), - "2.2.0" => Ok(V2_2_0), - _ => Err(()), - } - } -} -impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `cashapp` PaymentMethod, this sub-hash contains details about the Cash App Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsCashapp { @@ -17679,8 +15434,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCashappSetupFu pub struct ConfirmPaymentIntentPaymentMethodOptionsCustomerBalance<'a> { /// Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. #[serde(skip_serializing_if = "Option::is_none")] - pub bank_transfer: - Option<ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, + pub bank_transfer: Option<ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a>>, /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. #[serde(skip_serializing_if = "Option::is_none")] @@ -17694,8 +15448,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsCustomerBalance<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCustomerBalance<'a> { pub fn new() -> Self { @@ -17706,23 +15459,20 @@ impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCustomerBalance<'a> { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { /// Configuration for the eu_bank_transfer funding type. -#[serde(skip_serializing_if = "Option::is_none")] -pub eu_bank_transfer: Option<EuBankTransferParams<'a>>, - /// List of address types that should be returned in the financial_addresses response. + #[serde(skip_serializing_if = "Option::is_none")] + pub eu_bank_transfer: Option<EuBankTransferParams<'a>>, + /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. -#[serde(skip_serializing_if = "Option::is_none")] -pub requested_address_types: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, - /// The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. -#[serde(rename = "type")] -pub type_: ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, - + #[serde(skip_serializing_if = "Option::is_none")] + pub requested_address_types: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes]>, + /// The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransfer<'a> { - pub fn new( - type_: ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType, - ) -> Self { + pub fn new(type_: ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType) -> Self { Self { eu_bank_transfer: None, requested_address_types: None, type_ } } } @@ -17755,9 +15505,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequeste } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes::*; @@ -17773,24 +15521,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -19350,8 +17092,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsPromptpay { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage>, } impl ConfirmPaymentIntentPaymentMethodOptionsPromptpay { pub fn new() -> Self { @@ -19408,7 +17149,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsPromptpaySetup serializer.serialize_str(self.as_str()) } } -/// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. +/// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Demo Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsRevolutPay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -19418,8 +17159,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsRevolutPay { /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage>, } impl ConfirmPaymentIntentPaymentMethodOptionsRevolutPay { pub fn new() -> Self { @@ -19492,8 +17232,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsSepaDebit<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsSepaDebit<'a> { pub fn new() -> Self { @@ -19692,96 +17431,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsSofortSetupFut serializer.serialize_str(self.as_str()) } } -/// If this is a `Swish` PaymentMethod, this sub-hash contains details about the Swish payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsSwish<'a> { - /// The order ID displayed in the Swish app after the payment is authorized. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference: Option<&'a str>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - /// - /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage>, -} -impl<'a> ConfirmPaymentIntentPaymentMethodOptionsSwish<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -/// -/// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - None, -} -impl ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match self { - None => "none", - } - } -} - -impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match s { - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `us_bank_account` PaymentMethod, this sub-hash contains details about the US bank account payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, - /// Additional fields for Mandate creation - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions>, + pub financial_connections: Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Additional fields for network related functions #[serde(skip_serializing_if = "Option::is_none")] pub networks: Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a>>, /// Preferred transaction settlement speed #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_settlement_speed: - Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, + pub preferred_settlement_speed: Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -19791,12 +17452,10 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsUsBankAccount<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>, - /// Bank account verification method. + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>, + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -19806,19 +17465,18 @@ impl<'a> ConfirmPaymentIntentPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { - /// The list of permissions to request. + /// The list of permissions to request. /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. -#[serde(skip_serializing_if = "Option::is_none")] -pub permissions: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, + #[serde(skip_serializing_if = "Option::is_none")] + pub permissions: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. -#[serde(skip_serializing_if = "Option::is_none")] -pub prefetch: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, - /// For webview integrations only. + #[serde(skip_serializing_if = "Option::is_none")] + pub prefetch: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, + /// For webview integrations only. /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. -#[serde(skip_serializing_if = "Option::is_none")] -pub return_url: Option<&'a str>, - + #[serde(skip_serializing_if = "Option::is_none")] + pub return_url: Option<&'a str>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a> { pub fn new() -> Self { @@ -19847,9 +17505,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPe } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; @@ -19862,24 +17518,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -19891,113 +17541,38 @@ impl serde::Serialize #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } impl ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Additional fields for Mandate creation -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { - /// The method used to collect offline mandate customer acceptance. - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: - Option<ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod>, -} -impl ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { - pub fn new() -> Self { - Self::default() - } -} -/// The method used to collect offline mandate customer acceptance. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - Paper, -} -impl ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - pub fn as_str(self) -> &'static str { - use ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match self { - Paper => "paper", - } - } -} - -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match s { - "paper" => Ok(Paper), - _ => Err(()), - } - } -} -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -20010,8 +17585,7 @@ impl serde::Serialize pub struct ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { /// Triggers validations to run across the selected networks #[serde(skip_serializing_if = "Option::is_none")] - pub requested: - Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, + pub requested: Option<&'a [ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { pub fn new() -> Self { @@ -20080,9 +17654,7 @@ impl ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpe } } -impl std::str::FromStr - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::str::FromStr for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::*; @@ -20093,24 +17665,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::fmt::Display for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl std::fmt::Debug for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -20174,7 +17740,7 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountS serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, @@ -20240,8 +17806,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsWechatPay<'a> { /// /// If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: - Option<ConfirmPaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage>, + pub setup_future_usage: Option<ConfirmPaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage>, } impl<'a> ConfirmPaymentIntentPaymentMethodOptionsWechatPay<'a> { pub fn new(client: ConfirmPaymentIntentPaymentMethodOptionsWechatPayClient) -> Self { @@ -20504,16 +18069,146 @@ impl<'a> ConfirmPaymentIntent<'a> { /// attempt. /// Read the [expanded documentation](https://stripe.com/docs/payments/payment-intents/web-manual). /// to learn more about manual confirmation. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { - client.send_form( - &format!("/payment_intents/{intent}/confirm"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { + client.send_form(&format!("/payment_intents/{intent}/confirm"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CancelPaymentIntent<'a> { + /// Reason for canceling this PaymentIntent. + /// Possible values are: `duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`. + #[serde(skip_serializing_if = "Option::is_none")] + pub cancellation_reason: Option<CancelPaymentIntentCancellationReason>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> CancelPaymentIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Reason for canceling this PaymentIntent. +/// Possible values are: `duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CancelPaymentIntentCancellationReason { + Abandoned, + Duplicate, + Fraudulent, + RequestedByCustomer, +} +impl CancelPaymentIntentCancellationReason { + pub fn as_str(self) -> &'static str { + use CancelPaymentIntentCancellationReason::*; + match self { + Abandoned => "abandoned", + Duplicate => "duplicate", + Fraudulent => "fraudulent", + RequestedByCustomer => "requested_by_customer", + } + } +} + +impl std::str::FromStr for CancelPaymentIntentCancellationReason { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use CancelPaymentIntentCancellationReason::*; + match s { + "abandoned" => Ok(Abandoned), + "duplicate" => Ok(Duplicate), + "fraudulent" => Ok(Fraudulent), + "requested_by_customer" => Ok(RequestedByCustomer), + _ => Err(()), + } + } +} +impl std::fmt::Display for CancelPaymentIntentCancellationReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CancelPaymentIntentCancellationReason { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for CancelPaymentIntentCancellationReason { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> CancelPaymentIntent<'a> { + /// You can cancel a PaymentIntent object when it’s in one of these statuses: `requires_payment_method`, `requires_capture`, `requires_confirmation`, `requires_action` or, [in rare cases](https://stripe.com/docs/payments/intents), `processing`. + /// + /// + /// After it’s canceled, no additional charges are made by the PaymentIntent and any operations on the PaymentIntent fail with an error. + /// For PaymentIntents with a `status` of `requires_capture`, the remaining `amount_capturable` is automatically refunded. + /// + /// + /// You can’t cancel the PaymentIntent for a Checkout Session. + /// [Expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead. + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { + client.send_form(&format!("/payment_intents/{intent}/cancel"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CapturePaymentIntent<'a> { + /// The amount to capture from the PaymentIntent, which must be less than or equal to the original amount. + /// Any additional amount is automatically refunded. + /// Defaults to the full `amount_capturable` if it's not provided. + #[serde(skip_serializing_if = "Option::is_none")] + pub amount_to_capture: Option<i64>, + /// The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. + /// The amount of the application fee collected will be capped at the total payment amount. + /// For more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). + #[serde(skip_serializing_if = "Option::is_none")] + pub application_fee_amount: Option<i64>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Defaults to `true`. + /// When capturing a PaymentIntent, setting `final_capture` to `false` notifies Stripe to not release the remaining uncaptured funds to make sure that they're captured in future requests. + /// You can only use this setting when [multicapture](https://stripe.com/docs/payments/multicapture) is available for PaymentIntents. + #[serde(skip_serializing_if = "Option::is_none")] + pub final_capture: Option<bool>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// For non-card charges, you can use this value as the complete description that appears on your customers’ statements. + /// Must contain at least one letter, maximum 22 characters. + #[serde(skip_serializing_if = "Option::is_none")] + pub statement_descriptor: Option<&'a str>, + /// Provides information about a card payment that customers see on their statements. + /// Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. + /// The concatenated descriptor must be 1-22 characters long. + #[serde(skip_serializing_if = "Option::is_none")] + pub statement_descriptor_suffix: Option<&'a str>, + /// The parameters that you can use to automatically create a transfer after the payment + /// is captured. + /// Learn more about the [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). + #[serde(skip_serializing_if = "Option::is_none")] + pub transfer_data: Option<TransferDataUpdateParams>, +} +impl<'a> CapturePaymentIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> CapturePaymentIntent<'a> { + /// Capture the funds of an existing uncaptured PaymentIntent when its status is `requires_capture`. + /// + /// Uncaptured PaymentIntents are cancelled a set number of days (7 by default) after their creation. + /// + /// Learn more about [separate authorization and capture](https://stripe.com/docs/payments/capture-later). + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { + client.send_form(&format!("/payment_intents/{intent}/capture"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -20538,9 +18233,8 @@ pub struct IncrementAuthorizationPaymentIntent<'a> { /// All keys can be unset by posting an empty value to `metadata`. #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// For card charges, use [statement_descriptor_suffix](https://stripe.com/docs/payments/account/statement-descriptors#dynamic). - /// Otherwise, you can use this value as the complete description of a charge on your customers' statements. - /// It must contain at least one letter and be 1–22 characters long. + /// For non-card charges, you can use this value as the complete description that appears on your customers’ statements. + /// Must contain at least one letter, maximum 22 characters. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, /// The parameters used to automatically create a transfer after the payment is captured. @@ -20550,15 +18244,7 @@ pub struct IncrementAuthorizationPaymentIntent<'a> { } impl<'a> IncrementAuthorizationPaymentIntent<'a> { pub fn new(amount: i64) -> Self { - Self { - amount, - application_fee_amount: None, - description: None, - expand: None, - metadata: None, - statement_descriptor: None, - transfer_data: None, - } + Self { amount, application_fee_amount: None, description: None, expand: None, metadata: None, statement_descriptor: None, transfer_data: None } } } impl<'a> IncrementAuthorizationPaymentIntent<'a> { @@ -20586,16 +18272,8 @@ impl<'a> IncrementAuthorizationPaymentIntent<'a> { /// After it’s captured, a PaymentIntent can no longer be incremented. /// /// Learn more about [incremental authorizations](https://stripe.com/docs/terminal/features/incremental-authorizations). - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { - client.send_form( - &format!("/payment_intents/{intent}/increment_authorization"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { + client.send_form(&format!("/payment_intents/{intent}/increment_authorization"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -20617,16 +18295,38 @@ impl<'a> VerifyMicrodepositsPaymentIntent<'a> { } impl<'a> VerifyMicrodepositsPaymentIntent<'a> { /// Verifies microdeposits on a PaymentIntent object. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::PaymentIntentId, - ) -> stripe::Response<stripe_shared::PaymentIntent> { - client.send_form( - &format!("/payment_intents/{intent}/verify_microdeposits"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { + client.send_form(&format!("/payment_intents/{intent}/verify_microdeposits"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ApplyCustomerBalancePaymentIntent<'a> { + /// Amount that you intend to apply to this PaymentIntent from the customer’s cash balance. + /// + /// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (for example, 100 cents to charge 1 USD or 100 to charge 100 JPY, a zero-decimal currency). + /// + /// The maximum amount is the amount of the PaymentIntent. + /// + /// When you omit the amount, it defaults to the remaining amount requested on the PaymentIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub amount: Option<i64>, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + #[serde(skip_serializing_if = "Option::is_none")] + pub currency: Option<stripe_types::Currency>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> ApplyCustomerBalancePaymentIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ApplyCustomerBalancePaymentIntent<'a> { + /// Manually reconcile the remaining amount for a `customer_balance` PaymentIntent. + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::PaymentIntentId) -> stripe::Response<stripe_shared::PaymentIntent> { + client.send_form(&format!("/payment_intents/{intent}/apply_customer_balance"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -20651,11 +18351,7 @@ pub struct PaymentMethodParam<'a> { pub transit_number: &'a str, } impl<'a> PaymentMethodParam<'a> { - pub fn new( - account_number: &'a str, - institution_number: &'a str, - transit_number: &'a str, - ) -> Self { + pub fn new(account_number: &'a str, institution_number: &'a str, transit_number: &'a str) -> Self { Self { account_number, institution_number, transit_number } } } @@ -20674,6 +18370,18 @@ impl DateOfBirth { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct PaymentIntentPaymentMethodOptionsParam<'a> { + /// The 6-digit BLIK code that a customer has generated using their banking application. + /// Can only be set on confirmation. + #[serde(skip_serializing_if = "Option::is_none")] + pub code: Option<&'a str>, +} +impl<'a> PaymentIntentPaymentMethodOptionsParam<'a> { + pub fn new() -> Self { + Self::default() + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct PaymentMethodOptionsParam { /// Request ability to capture this payment beyond the standard [authorization validity window](https://stripe.com/docs/terminal/features/extended-authorizations#authorization-validity). #[serde(skip_serializing_if = "Option::is_none")] diff --git a/generated/stripe_core/src/payment_source/requests.rs b/generated/stripe_core/src/payment_source/requests.rs index 40402f3e8..e96c2a755 100644 --- a/generated/stripe_core/src/payment_source/requests.rs +++ b/generated/stripe_core/src/payment_source/requests.rs @@ -28,17 +28,10 @@ impl<'a> ListCustomerPaymentSource<'a> { } impl<'a> ListCustomerPaymentSource<'a> { /// List sources for a specified customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_types::List<stripe_shared::PaymentSource>> { + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_types::List<stripe_shared::PaymentSource>> { client.get_query(&format!("/customers/{customer}/sources"), self) } - pub fn paginate( - self, - customer: &stripe_shared::CustomerId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentSource>> { + pub fn paginate(self, customer: &stripe_shared::CustomerId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentSource>> { stripe::ListPaginator::from_list_params(&format!("/customers/{customer}/sources"), self) } } @@ -55,12 +48,7 @@ impl<'a> RetrievePaymentSource<'a> { } impl<'a> RetrievePaymentSource<'a> { /// Retrieve a specified source for a given customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<stripe_shared::PaymentSource> { + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<stripe_shared::PaymentSource> { client.get_query(&format!("/customers/{customer}/sources/{id}"), self) } } @@ -91,11 +79,7 @@ impl<'a> CreateCustomerPaymentSource<'a> { /// If the card’s owner has no default card, then the new card will become the default. /// However, if the owner already has a default, then it will not change. /// To change the default, you should [update the customer](https://stripe.com/docs/api#update_customer) to have a new `default_source`. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - ) -> stripe::Response<stripe_shared::PaymentSource> { + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId) -> stripe::Response<stripe_shared::PaymentSource> { client.send_form(&format!("/customers/{customer}/sources"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/src/payout/requests.rs b/generated/stripe_core/src/payout/requests.rs index 48cad35dd..97132d560 100644 --- a/generated/stripe_core/src/payout/requests.rs +++ b/generated/stripe_core/src/payout/requests.rs @@ -1,4 +1,23 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrievePayout<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrievePayout<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrievePayout<'a> { + /// Retrieves the details of an existing payout. + /// Supply the unique payout ID from either a payout creation request or the payout list. + /// Stripe returns the corresponding payout information. + pub fn send(&self, client: &stripe::Client, payout: &stripe_shared::PayoutId) -> stripe::Response<stripe_shared::Payout> { + client.get_query(&format!("/payouts/{payout}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListPayout<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub arrival_date: Option<stripe_types::RangeQueryTs>, @@ -36,39 +55,13 @@ impl<'a> ListPayout<'a> { impl<'a> ListPayout<'a> { /// Returns a list of existing payouts sent to third-party bank accounts or payouts that Stripe sent to you. /// The payouts return in sorted order, with the most recently created payouts appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Payout>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Payout>> { client.get_query("/payouts", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Payout>> { stripe::ListPaginator::from_list_params("/payouts", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrievePayout<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrievePayout<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrievePayout<'a> { - /// Retrieves the details of an existing payout. - /// Supply the unique payout ID from either a payout creation request or the payout list. - /// Stripe returns the corresponding payout information. - pub fn send( - &self, - client: &stripe::Client, - payout: &stripe_shared::PayoutId, - ) -> stripe::Response<stripe_shared::Payout> { - client.get_query(&format!("/payouts/{payout}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePayout<'a> { /// A positive integer in cents representing how much to payout. @@ -112,17 +105,7 @@ pub struct CreatePayout<'a> { } impl<'a> CreatePayout<'a> { pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { - Self { - amount, - currency, - description: None, - destination: None, - expand: None, - metadata: None, - method: None, - source_type: None, - statement_descriptor: None, - } + Self { amount, currency, description: None, destination: None, expand: None, metadata: None, method: None, source_type: None, statement_descriptor: None } } } /// The method used to send this payout, which is `standard` or `instant`. @@ -259,11 +242,7 @@ impl<'a> UpdatePayout<'a> { /// Updates the specified payout by setting the values of the parameters you pass. /// We don’t change parameters that you don’t provide. /// This request only accepts the metadata as arguments. - pub fn send( - &self, - client: &stripe::Client, - payout: &stripe_shared::PayoutId, - ) -> stripe::Response<stripe_shared::Payout> { + pub fn send(&self, client: &stripe::Client, payout: &stripe_shared::PayoutId) -> stripe::Response<stripe_shared::Payout> { client.send_form(&format!("/payouts/{payout}"), self, http_types::Method::Post) } } @@ -279,14 +258,10 @@ impl<'a> CancelPayout<'a> { } } impl<'a> CancelPayout<'a> { - /// You can cancel a previously created payout if its status is `pending`. + /// You can cancel a previously created payout if it hasn’t been paid out yet. /// Stripe refunds the funds to your available balance. /// You can’t cancel automatic Stripe payouts. - pub fn send( - &self, - client: &stripe::Client, - payout: &stripe_shared::PayoutId, - ) -> stripe::Response<stripe_shared::Payout> { + pub fn send(&self, client: &stripe::Client, payout: &stripe_shared::PayoutId) -> stripe::Response<stripe_shared::Payout> { client.send_form(&format!("/payouts/{payout}/cancel"), self, http_types::Method::Post) } } @@ -310,14 +285,10 @@ impl<'a> ReversePayout<'a> { impl<'a> ReversePayout<'a> { /// Reverses a payout by debiting the destination bank account. /// At this time, you can only reverse payouts for connected accounts to US bank accounts. - /// If the payout is manual and in the `pending` status, use `/v1/payouts/:id/cancel` instead. + /// If the payout is in the `pending` status, use `/v1/payouts/:id/cancel` instead. /// /// By requesting a reversal through `/v1/payouts/:id/reverse`, you confirm that the authorized signatory of the selected bank account authorizes the debit on the bank account and that no other authorization is required. - pub fn send( - &self, - client: &stripe::Client, - payout: &stripe_shared::PayoutId, - ) -> stripe::Response<stripe_shared::Payout> { + pub fn send(&self, client: &stripe::Client, payout: &stripe_shared::PayoutId) -> stripe::Response<stripe_shared::Payout> { client.send_form(&format!("/payouts/{payout}/reverse"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/src/refund/requests.rs b/generated/stripe_core/src/refund/requests.rs index da81c81d0..5620236f3 100644 --- a/generated/stripe_core/src/refund/requests.rs +++ b/generated/stripe_core/src/refund/requests.rs @@ -34,10 +34,7 @@ impl<'a> ListRefund<'a> { impl<'a> ListRefund<'a> { /// Returns a list of all refunds you created. /// We return the refunds in sorted order, with the most recent refunds appearing first The 10 most recent refunds are always available by default on the Charge object. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Refund>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Refund>> { client.get_query("/refunds", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Refund>> { @@ -45,27 +42,6 @@ impl<'a> ListRefund<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveRefund<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveRefund<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveRefund<'a> { - /// Retrieves the details of an existing refund. - pub fn send( - &self, - client: &stripe::Client, - refund: &stripe_shared::RefundId, - ) -> stripe::Response<stripe_shared::Refund> { - client.get_query(&format!("/refunds/{refund}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateRefund<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, @@ -231,6 +207,23 @@ impl<'a> CreateRefund<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveRefund<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveRefund<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveRefund<'a> { + /// Retrieves the details of an existing refund. + pub fn send(&self, client: &stripe::Client, refund: &stripe_shared::RefundId) -> stripe::Response<stripe_shared::Refund> { + client.get_query(&format!("/refunds/{refund}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateRefund<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -252,11 +245,7 @@ impl<'a> UpdateRefund<'a> { /// Any parameters that you don’t provide remain unchanged. /// /// This request only accepts `metadata` as an argument. - pub fn send( - &self, - client: &stripe::Client, - refund: &stripe_shared::RefundId, - ) -> stripe::Response<stripe_shared::Refund> { + pub fn send(&self, client: &stripe::Client, refund: &stripe_shared::RefundId) -> stripe::Response<stripe_shared::Refund> { client.send_form(&format!("/refunds/{refund}"), self, http_types::Method::Post) } } @@ -276,11 +265,7 @@ impl<'a> CancelRefund<'a> { /// /// You can’t cancel refunds in other states. /// Only refunds for payment methods that require customer action can enter the `requires_action` state. - pub fn send( - &self, - client: &stripe::Client, - refund: &stripe_shared::RefundId, - ) -> stripe::Response<stripe_shared::Refund> { + pub fn send(&self, client: &stripe::Client, refund: &stripe_shared::RefundId) -> stripe::Response<stripe_shared::Refund> { client.send_form(&format!("/refunds/{refund}/cancel"), self, http_types::Method::Post) } } @@ -297,15 +282,7 @@ impl<'a> ExpireRefund<'a> { } impl<'a> ExpireRefund<'a> { /// Expire a refund with a status of `requires_action`. - pub fn send( - &self, - client: &stripe::Client, - refund: &str, - ) -> stripe::Response<stripe_shared::Refund> { - client.send_form( - &format!("/test_helpers/refunds/{refund}/expire"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, refund: &str) -> stripe::Response<stripe_shared::Refund> { + client.send_form(&format!("/test_helpers/refunds/{refund}/expire"), self, http_types::Method::Post) } } diff --git a/generated/stripe_core/src/setup_attempt/requests.rs b/generated/stripe_core/src/setup_attempt/requests.rs index e570c255a..634a2f600 100644 --- a/generated/stripe_core/src/setup_attempt/requests.rs +++ b/generated/stripe_core/src/setup_attempt/requests.rs @@ -28,27 +28,15 @@ pub struct ListSetupAttempt<'a> { } impl<'a> ListSetupAttempt<'a> { pub fn new(setup_intent: &'a str) -> Self { - Self { - created: None, - ending_before: None, - expand: None, - limit: None, - setup_intent, - starting_after: None, - } + Self { created: None, ending_before: None, expand: None, limit: None, setup_intent, starting_after: None } } } impl<'a> ListSetupAttempt<'a> { /// Returns a list of SetupAttempts that associate with a provided SetupIntent. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::SetupAttempt>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::SetupAttempt>> { client.get_query("/setup_attempts", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SetupAttempt>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SetupAttempt>> { stripe::ListPaginator::from_list_params("/setup_attempts", self) } } diff --git a/generated/stripe_core/src/setup_intent/requests.rs b/generated/stripe_core/src/setup_intent/requests.rs index c1a6a0d16..70c51546e 100644 --- a/generated/stripe_core/src/setup_intent/requests.rs +++ b/generated/stripe_core/src/setup_intent/requests.rs @@ -1,88 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListSetupIntent<'a> { - /// If present, the SetupIntent's payment method will be attached to the in-context Stripe Account. - /// - /// It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. - /// It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub attach_to_self: Option<bool>, - /// A filter on the list, based on the object `created` field. - /// The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options. - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// Only return SetupIntents for the customer specified by this customer ID. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// Only return SetupIntents that associate with the specified payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method: Option<&'a str>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListSetupIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListSetupIntent<'a> { - /// Returns a list of SetupIntents. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::SetupIntent>> { - client.get_query("/setup_intents", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SetupIntent>> { - stripe::ListPaginator::from_list_params("/setup_intents", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveSetupIntent<'a> { - /// The client secret of the SetupIntent. - /// We require this string if you use a publishable key to retrieve the SetupIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub client_secret: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveSetupIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveSetupIntent<'a> { - /// Retrieves the details of a SetupIntent that has previously been created. - /// - /// Client-side retrieval using a publishable key is allowed when the `client_secret` is provided in the query string. - /// - /// - /// When retrieved with a publishable key, only a subset of properties will be returned. - /// Please refer to the [SetupIntent](https://stripe.com/docs/api#setup_intent_object) object reference for more details. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::SetupIntentId, - ) -> stripe::Response<stripe_shared::SetupIntent> { - client.get_query(&format!("/setup_intents/{intent}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntent<'a> { /// If present, the SetupIntent's payment method will be attached to the in-context Stripe Account. /// @@ -260,7 +176,7 @@ pub struct CreateSetupIntentMandateDataCustomerAcceptance<'a> { pub online: Option<OnlineParam<'a>>, /// The type of customer acceptance information included with the Mandate. /// One of `online` or `offline`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateSetupIntentMandateDataCustomerAcceptanceType, } impl<'a> CreateSetupIntentMandateDataCustomerAcceptance<'a> { @@ -419,13 +335,10 @@ pub struct CreateSetupIntentPaymentMethodData<'a> { /// If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<CreateSetupIntentPaymentMethodDataSofort>, - /// If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<&'a serde_json::Value>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateSetupIntentPaymentMethodDataType, /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. #[serde(skip_serializing_if = "Option::is_none")] @@ -472,7 +385,6 @@ impl<'a> CreateSetupIntentPaymentMethodData<'a> { revolut_pay: None, sepa_debit: None, sofort: None, - swish: None, type_, us_bank_account: None, wechat_pay: None, @@ -853,7 +765,6 @@ pub enum CreateSetupIntentPaymentMethodDataIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -876,7 +787,6 @@ impl CreateSetupIntentPaymentMethodDataIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -902,7 +812,6 @@ impl std::str::FromStr for CreateSetupIntentPaymentMethodDataIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -985,7 +894,6 @@ pub enum CreateSetupIntentPaymentMethodDataP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -1018,7 +926,6 @@ impl CreateSetupIntentPaymentMethodDataP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -1054,7 +961,6 @@ impl std::str::FromStr for CreateSetupIntentPaymentMethodDataP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -1193,7 +1099,6 @@ pub enum CreateSetupIntentPaymentMethodDataType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -1232,7 +1137,6 @@ impl CreateSetupIntentPaymentMethodDataType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -1274,7 +1178,6 @@ impl std::str::FromStr for CreateSetupIntentPaymentMethodDataType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -1306,8 +1209,7 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataType { pub struct CreateSetupIntentPaymentMethodDataUsBankAccount<'a> { /// Account holder type: individual or company. #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: - Option<CreateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType>, + pub account_holder_type: Option<CreateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType>, /// Account number of the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<&'a str>, @@ -1455,10 +1357,9 @@ pub struct CreateSetupIntentPaymentMethodOptionsAcssDebit<'a> { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option<CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a>>, - /// Bank account verification method. + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<CreateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } impl<'a> CreateSetupIntentPaymentMethodOptionsAcssDebit<'a> { pub fn new() -> Self { @@ -1522,20 +1423,17 @@ pub struct CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub custom_mandate_url: Option<&'a str>, /// List of Stripe products where this mandate can be selected automatically. #[serde(skip_serializing_if = "Option::is_none")] - pub default_for: - Option<&'a [CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, + pub default_for: Option<&'a [CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, /// Description of the mandate interval. /// Only required if 'payment_schedule' parameter is 'interval' or 'combined'. #[serde(skip_serializing_if = "Option::is_none")] pub interval_description: Option<&'a str>, /// Payment schedule for the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_schedule: - Option<CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, + pub payment_schedule: Option<CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: - Option<CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, + pub transaction_type: Option<CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl<'a> CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub fn new() -> Self { @@ -1606,9 +1504,7 @@ impl CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule } } -impl std::str::FromStr - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule::*; @@ -1620,24 +1516,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1661,9 +1551,7 @@ impl CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType } } -impl std::str::FromStr - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -1674,24 +1562,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1699,7 +1581,7 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { Automatic, @@ -1766,15 +1648,11 @@ pub struct CreateSetupIntentPaymentMethodOptionsCard<'a> { pub network: Option<CreateSetupIntentPaymentMethodOptionsCardNetwork>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<CreateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure>, - /// If 3D Secure authentication was performed with a third-party provider, - /// the authentication details to use for this setup. - #[serde(skip_serializing_if = "Option::is_none")] - pub three_d_secure: Option<CreateSetupIntentPaymentMethodOptionsCardThreeDSecure<'a>>, + pub request_three_d_secure: Option<CreateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure>, } impl<'a> CreateSetupIntentPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -1816,8 +1694,7 @@ pub struct CreateSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { pub start_date: stripe_types::Timestamp, /// Specifies the type of mandates supported. Possible values are `india`. #[serde(skip_serializing_if = "Option::is_none")] - pub supported_types: - Option<&'a [CreateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, + pub supported_types: Option<&'a [CreateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, } impl<'a> CreateSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { pub fn new( @@ -1828,18 +1705,7 @@ impl<'a> CreateSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { reference: &'a str, start_date: stripe_types::Timestamp, ) -> Self { - Self { - amount, - amount_type, - currency, - description: None, - end_date: None, - interval, - interval_count: None, - reference, - start_date, - supported_types: None, - } + Self { amount, amount_type, currency, description: None, end_date: None, interval, interval_count: None, reference, start_date, supported_types: None } } } /// One of `fixed` or `maximum`. @@ -2065,13 +1931,13 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardNetwork { } /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl CreateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -2079,7 +1945,6 @@ impl CreateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -2091,7 +1956,6 @@ impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsCardRequestThree match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -2115,333 +1979,6 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardRequestThreeD serializer.serialize_str(self.as_str()) } } -/// If 3D Secure authentication was performed with a third-party provider, -/// the authentication details to use for this setup. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSetupIntentPaymentMethodOptionsCardThreeDSecure<'a> { - /// The `transStatus` returned from the card Issuer’s ACS in the ARes. - #[serde(skip_serializing_if = "Option::is_none")] - pub ares_trans_status: - Option<CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus>, - /// The cryptogram, also known as the "authentication value" (AAV, CAVV or - /// AEVV). This value is 20 bytes, base64-encoded into a 28-character string. - /// (Most 3D Secure providers will return the base64-encoded version, which - /// is what you should specify here.) - #[serde(skip_serializing_if = "Option::is_none")] - pub cryptogram: Option<&'a str>, - /// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure - /// provider and indicates what degree of authentication was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub electronic_commerce_indicator: - Option<CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator>, - /// Network specific 3DS fields. Network specific arguments require an - /// explicit card brand choice. The parameter `payment_method_options.card.network`` - /// must be populated accordingly - #[serde(skip_serializing_if = "Option::is_none")] - pub network_options: - Option<CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a>>, - /// The challenge indicator (`threeDSRequestorChallengeInd`) which was requested in the - /// AReq sent to the card Issuer's ACS. A string containing 2 digits from 01-99. - #[serde(skip_serializing_if = "Option::is_none")] - pub requestor_challenge_indicator: Option<&'a str>, - /// For 3D Secure 1, the XID. For 3D Secure 2, the Directory Server - /// Transaction ID (dsTransID). - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_id: Option<&'a str>, - /// The version of 3D Secure that was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub version: Option<CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion>, -} -impl<'a> CreateSetupIntentPaymentMethodOptionsCardThreeDSecure<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The `transStatus` returned from the card Issuer’s ACS in the ARes. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - A, - C, - I, - N, - R, - U, - Y, -} -impl CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - pub fn as_str(self) -> &'static str { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match self { - A => "A", - C => "C", - I => "I", - N => "N", - R => "R", - U => "U", - Y => "Y", - } - } -} - -impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match s { - "A" => Ok(A), - "C" => Ok(C), - "I" => Ok(I), - "N" => Ok(N), - "R" => Ok(R), - "U" => Ok(U), - "Y" => Ok(Y), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure -/// provider and indicates what degree of authentication was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - pub fn as_str(self) -> &'static str { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", - } - } -} - -impl std::str::FromStr - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Network specific 3DS fields. Network specific arguments require an -/// explicit card brand choice. The parameter `payment_method_options.card.network`` -/// must be populated accordingly -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - /// Cartes Bancaires-specific 3DS fields. - #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option< - CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a>, - >, -} -impl<'a> CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Cartes Bancaires-specific 3DS fields. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - /// The cryptogram calculation algorithm used by the card Issuer's ACS - /// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. - /// messageExtension: CB-AVALGO - pub cb_avalgo: - CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - /// The exemption indicator returned from Cartes Bancaires in the ARes. - /// message extension: CB-EXEMPTION; string (4 characters) - /// This is a 3 byte bitmap (low significant byte first and most significant - /// bit first) that has been Base64 encoded - #[serde(skip_serializing_if = "Option::is_none")] - pub cb_exemption: Option<&'a str>, - /// The risk score returned from Cartes Bancaires in the ARes. - /// message extension: CB-SCORE; numeric value 0-99 - #[serde(skip_serializing_if = "Option::is_none")] - pub cb_score: Option<i64>, -} -impl<'a> CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - pub fn new( - cb_avalgo: CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - ) -> Self { - Self { cb_avalgo, cb_exemption: None, cb_score: None } - } -} -/// The cryptogram calculation algorithm used by the card Issuer's ACS -/// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. -/// messageExtension: CB-AVALGO -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - V0, - V1, - V2, - V3, - V4, - A, -} -impl CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - pub fn as_str(self) -> &'static str { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match self { - V0 => "0", - V1 => "1", - V2 => "2", - V3 => "3", - V4 => "4", - A => "A", - } - } -} - -impl std::str::FromStr - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match s { - "0" => Ok(V0), - "1" => Ok(V1), - "2" => Ok(V2), - "3" => Ok(V3), - "4" => Ok(V4), - "A" => Ok(A), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The version of 3D Secure that was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - V1_0_2, - V2_1_0, - V2_2_0, -} -impl CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - pub fn as_str(self) -> &'static str { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match self { - V1_0_2 => "1.0.2", - V2_1_0 => "2.1.0", - V2_2_0 => "2.2.0", - } - } -} - -impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match s { - "1.0.2" => Ok(V1_0_2), - "2.1.0" => Ok(V2_1_0), - "2.2.0" => Ok(V2_2_0), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodOptionsSepaDebit<'a> { @@ -2459,18 +1996,13 @@ impl<'a> CreateSetupIntentPaymentMethodOptionsSepaDebit<'a> { pub struct CreateSetupIntentPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, - /// Additional fields for Mandate creation - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions>, + pub financial_connections: Option<CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Additional fields for network related functions #[serde(skip_serializing_if = "Option::is_none")] pub networks: Option<CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a>>, - /// Bank account verification method. + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<CreateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<CreateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> CreateSetupIntentPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -2484,14 +2016,10 @@ pub struct CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnection /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[serde(skip_serializing_if = "Option::is_none")] - pub permissions: Option< - &'a [CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions], - >, + pub permissions: Option<&'a [CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. #[serde(skip_serializing_if = "Option::is_none")] - pub prefetch: Option< - &'a [CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch], - >, + pub prefetch: Option<&'a [CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, /// For webview integrations only. /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. #[serde(skip_serializing_if = "Option::is_none")] @@ -2524,9 +2052,7 @@ impl CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermi } } -impl std::str::FromStr - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; @@ -2539,24 +2065,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2568,49 +2088,38 @@ impl serde::Serialize #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } impl CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } -impl std::str::FromStr - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } } -impl std::fmt::Display - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2618,63 +2127,57 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Additional fields for Mandate creation +/// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { - /// The method used to collect offline mandate customer acceptance. +pub struct CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { + /// Triggers validations to run across the selected networks #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: - Option<CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod>, + pub requested: Option<&'a [CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, } -impl CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { +impl<'a> CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { pub fn new() -> Self { Self::default() } } -/// The method used to collect offline mandate customer acceptance. +/// Triggers validations to run across the selected networks #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - Paper, +pub enum CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { + Ach, + UsDomesticWire, } -impl CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { +impl CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { pub fn as_str(self) -> &'static str { - use CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; + use CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; match self { - Paper => "paper", + Ach => "ach", + UsDomesticWire => "us_domestic_wire", } } } -impl std::str::FromStr - for CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; + use CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; match s { - "paper" => Ok(Paper), + "ach" => Ok(Ach), + "us_domestic_wire" => Ok(UsDomesticWire), _ => Err(()), } } } -impl std::fmt::Display - for CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2682,66 +2185,7 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Additional fields for network related functions -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { - /// Triggers validations to run across the selected networks - #[serde(skip_serializing_if = "Option::is_none")] - pub requested: - Option<&'a [CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, -} -impl<'a> CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Triggers validations to run across the selected networks -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - Ach, - UsDomesticWire, -} -impl CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - pub fn as_str(self) -> &'static str { - use CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; - match self { - Ach => "ach", - UsDomesticWire => "us_domestic_wire", - } - } -} - -impl std::str::FromStr for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested::*; - match s { - "ach" => Ok(Ach), - "us_domestic_wire" => Ok(UsDomesticWire), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, @@ -2864,6 +2308,83 @@ impl<'a> CreateSetupIntent<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListSetupIntent<'a> { + /// If present, the SetupIntent's payment method will be attached to the in-context Stripe Account. + /// + /// It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. + /// It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer. + #[serde(skip_serializing_if = "Option::is_none")] + pub attach_to_self: Option<bool>, + /// A filter on the list, based on the object `created` field. + /// The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options. + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// Only return SetupIntents for the customer specified by this customer ID. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// Only return SetupIntents that associate with the specified payment method. + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_method: Option<&'a str>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListSetupIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListSetupIntent<'a> { + /// Returns a list of SetupIntents. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::SetupIntent>> { + client.get_query("/setup_intents", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SetupIntent>> { + stripe::ListPaginator::from_list_params("/setup_intents", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveSetupIntent<'a> { + /// The client secret of the SetupIntent. + /// We require this string if you use a publishable key to retrieve the SetupIntent. + #[serde(skip_serializing_if = "Option::is_none")] + pub client_secret: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveSetupIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveSetupIntent<'a> { + /// Retrieves the details of a SetupIntent that has previously been created. + /// + /// Client-side retrieval using a publishable key is allowed when the `client_secret` is provided in the query string. + /// + /// + /// When retrieved with a publishable key, only a subset of properties will be returned. + /// Please refer to the [SetupIntent](https://stripe.com/docs/api#setup_intent_object) object reference for more details. + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::SetupIntentId) -> stripe::Response<stripe_shared::SetupIntent> { + client.get_query(&format!("/setup_intents/{intent}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntent<'a> { /// If present, the SetupIntent's payment method will be attached to the in-context Stripe Account. /// @@ -3023,13 +2544,10 @@ pub struct UpdateSetupIntentPaymentMethodData<'a> { /// If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<UpdateSetupIntentPaymentMethodDataSofort>, - /// If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<&'a serde_json::Value>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: UpdateSetupIntentPaymentMethodDataType, /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. #[serde(skip_serializing_if = "Option::is_none")] @@ -3076,7 +2594,6 @@ impl<'a> UpdateSetupIntentPaymentMethodData<'a> { revolut_pay: None, sepa_debit: None, sofort: None, - swish: None, type_, us_bank_account: None, wechat_pay: None, @@ -3457,7 +2974,6 @@ pub enum UpdateSetupIntentPaymentMethodDataIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -3480,7 +2996,6 @@ impl UpdateSetupIntentPaymentMethodDataIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -3506,7 +3021,6 @@ impl std::str::FromStr for UpdateSetupIntentPaymentMethodDataIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -3589,7 +3103,6 @@ pub enum UpdateSetupIntentPaymentMethodDataP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -3622,7 +3135,6 @@ impl UpdateSetupIntentPaymentMethodDataP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -3658,7 +3170,6 @@ impl std::str::FromStr for UpdateSetupIntentPaymentMethodDataP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -3797,7 +3308,6 @@ pub enum UpdateSetupIntentPaymentMethodDataType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -3836,7 +3346,6 @@ impl UpdateSetupIntentPaymentMethodDataType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -3878,7 +3387,6 @@ impl std::str::FromStr for UpdateSetupIntentPaymentMethodDataType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -3910,8 +3418,7 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataType { pub struct UpdateSetupIntentPaymentMethodDataUsBankAccount<'a> { /// Account holder type: individual or company. #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: - Option<UpdateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType>, + pub account_holder_type: Option<UpdateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType>, /// Account number of the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<&'a str>, @@ -4059,10 +3566,9 @@ pub struct UpdateSetupIntentPaymentMethodOptionsAcssDebit<'a> { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option<UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a>>, - /// Bank account verification method. + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<UpdateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<UpdateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } impl<'a> UpdateSetupIntentPaymentMethodOptionsAcssDebit<'a> { pub fn new() -> Self { @@ -4126,20 +3632,17 @@ pub struct UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub custom_mandate_url: Option<&'a str>, /// List of Stripe products where this mandate can be selected automatically. #[serde(skip_serializing_if = "Option::is_none")] - pub default_for: - Option<&'a [UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, + pub default_for: Option<&'a [UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, /// Description of the mandate interval. /// Only required if 'payment_schedule' parameter is 'interval' or 'combined'. #[serde(skip_serializing_if = "Option::is_none")] pub interval_description: Option<&'a str>, /// Payment schedule for the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_schedule: - Option<UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, + pub payment_schedule: Option<UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: - Option<UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, + pub transaction_type: Option<UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl<'a> UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub fn new() -> Self { @@ -4210,9 +3713,7 @@ impl UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule } } -impl std::str::FromStr - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::str::FromStr for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule::*; @@ -4224,24 +3725,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Display for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Debug for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4265,9 +3760,7 @@ impl UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType } } -impl std::str::FromStr - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -4278,24 +3771,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4303,7 +3790,7 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { Automatic, @@ -4370,15 +3857,11 @@ pub struct UpdateSetupIntentPaymentMethodOptionsCard<'a> { pub network: Option<UpdateSetupIntentPaymentMethodOptionsCardNetwork>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<UpdateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure>, - /// If 3D Secure authentication was performed with a third-party provider, - /// the authentication details to use for this setup. - #[serde(skip_serializing_if = "Option::is_none")] - pub three_d_secure: Option<UpdateSetupIntentPaymentMethodOptionsCardThreeDSecure<'a>>, + pub request_three_d_secure: Option<UpdateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure>, } impl<'a> UpdateSetupIntentPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -4420,8 +3903,7 @@ pub struct UpdateSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { pub start_date: stripe_types::Timestamp, /// Specifies the type of mandates supported. Possible values are `india`. #[serde(skip_serializing_if = "Option::is_none")] - pub supported_types: - Option<&'a [UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, + pub supported_types: Option<&'a [UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, } impl<'a> UpdateSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { pub fn new( @@ -4432,18 +3914,7 @@ impl<'a> UpdateSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { reference: &'a str, start_date: stripe_types::Timestamp, ) -> Self { - Self { - amount, - amount_type, - currency, - description: None, - end_date: None, - interval, - interval_count: None, - reference, - start_date, - supported_types: None, - } + Self { amount, amount_type, currency, description: None, end_date: None, interval, interval_count: None, reference, start_date, supported_types: None } } } /// One of `fixed` or `maximum`. @@ -4669,13 +4140,13 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardNetwork { } /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl UpdateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -4683,7 +4154,6 @@ impl UpdateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -4695,7 +4165,6 @@ impl std::str::FromStr for UpdateSetupIntentPaymentMethodOptionsCardRequestThree match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -4719,333 +4188,6 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardRequestThreeD serializer.serialize_str(self.as_str()) } } -/// If 3D Secure authentication was performed with a third-party provider, -/// the authentication details to use for this setup. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateSetupIntentPaymentMethodOptionsCardThreeDSecure<'a> { - /// The `transStatus` returned from the card Issuer’s ACS in the ARes. - #[serde(skip_serializing_if = "Option::is_none")] - pub ares_trans_status: - Option<UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus>, - /// The cryptogram, also known as the "authentication value" (AAV, CAVV or - /// AEVV). This value is 20 bytes, base64-encoded into a 28-character string. - /// (Most 3D Secure providers will return the base64-encoded version, which - /// is what you should specify here.) - #[serde(skip_serializing_if = "Option::is_none")] - pub cryptogram: Option<&'a str>, - /// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure - /// provider and indicates what degree of authentication was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub electronic_commerce_indicator: - Option<UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator>, - /// Network specific 3DS fields. Network specific arguments require an - /// explicit card brand choice. The parameter `payment_method_options.card.network`` - /// must be populated accordingly - #[serde(skip_serializing_if = "Option::is_none")] - pub network_options: - Option<UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a>>, - /// The challenge indicator (`threeDSRequestorChallengeInd`) which was requested in the - /// AReq sent to the card Issuer's ACS. A string containing 2 digits from 01-99. - #[serde(skip_serializing_if = "Option::is_none")] - pub requestor_challenge_indicator: Option<&'a str>, - /// For 3D Secure 1, the XID. For 3D Secure 2, the Directory Server - /// Transaction ID (dsTransID). - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_id: Option<&'a str>, - /// The version of 3D Secure that was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub version: Option<UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion>, -} -impl<'a> UpdateSetupIntentPaymentMethodOptionsCardThreeDSecure<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The `transStatus` returned from the card Issuer’s ACS in the ARes. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - A, - C, - I, - N, - R, - U, - Y, -} -impl UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - pub fn as_str(self) -> &'static str { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match self { - A => "A", - C => "C", - I => "I", - N => "N", - R => "R", - U => "U", - Y => "Y", - } - } -} - -impl std::str::FromStr for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match s { - "A" => Ok(A), - "C" => Ok(C), - "I" => Ok(I), - "N" => Ok(N), - "R" => Ok(R), - "U" => Ok(U), - "Y" => Ok(Y), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure -/// provider and indicates what degree of authentication was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - pub fn as_str(self) -> &'static str { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", - } - } -} - -impl std::str::FromStr - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), - _ => Err(()), - } - } -} -impl std::fmt::Display - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Network specific 3DS fields. Network specific arguments require an -/// explicit card brand choice. The parameter `payment_method_options.card.network`` -/// must be populated accordingly -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - /// Cartes Bancaires-specific 3DS fields. - #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option< - UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a>, - >, -} -impl<'a> UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Cartes Bancaires-specific 3DS fields. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - /// The cryptogram calculation algorithm used by the card Issuer's ACS - /// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. - /// messageExtension: CB-AVALGO - pub cb_avalgo: - UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - /// The exemption indicator returned from Cartes Bancaires in the ARes. - /// message extension: CB-EXEMPTION; string (4 characters) - /// This is a 3 byte bitmap (low significant byte first and most significant - /// bit first) that has been Base64 encoded - #[serde(skip_serializing_if = "Option::is_none")] - pub cb_exemption: Option<&'a str>, - /// The risk score returned from Cartes Bancaires in the ARes. - /// message extension: CB-SCORE; numeric value 0-99 - #[serde(skip_serializing_if = "Option::is_none")] - pub cb_score: Option<i64>, -} -impl<'a> UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - pub fn new( - cb_avalgo: UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - ) -> Self { - Self { cb_avalgo, cb_exemption: None, cb_score: None } - } -} -/// The cryptogram calculation algorithm used by the card Issuer's ACS -/// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. -/// messageExtension: CB-AVALGO -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - V0, - V1, - V2, - V3, - V4, - A, -} -impl UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - pub fn as_str(self) -> &'static str { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match self { - V0 => "0", - V1 => "1", - V2 => "2", - V3 => "3", - V4 => "4", - A => "A", - } - } -} - -impl std::str::FromStr - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match s { - "0" => Ok(V0), - "1" => Ok(V1), - "2" => Ok(V2), - "3" => Ok(V3), - "4" => Ok(V4), - "A" => Ok(A), - _ => Err(()), - } - } -} -impl std::fmt::Display - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The version of 3D Secure that was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - V1_0_2, - V2_1_0, - V2_2_0, -} -impl UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - pub fn as_str(self) -> &'static str { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match self { - V1_0_2 => "1.0.2", - V2_1_0 => "2.1.0", - V2_2_0 => "2.2.0", - } - } -} - -impl std::str::FromStr for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match s { - "1.0.2" => Ok(V1_0_2), - "2.1.0" => Ok(V2_1_0), - "2.2.0" => Ok(V2_2_0), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodOptionsSepaDebit<'a> { @@ -5063,18 +4205,13 @@ impl<'a> UpdateSetupIntentPaymentMethodOptionsSepaDebit<'a> { pub struct UpdateSetupIntentPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, - /// Additional fields for Mandate creation - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions>, + pub financial_connections: Option<UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Additional fields for network related functions #[serde(skip_serializing_if = "Option::is_none")] pub networks: Option<UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a>>, - /// Bank account verification method. + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<UpdateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<UpdateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> UpdateSetupIntentPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -5088,14 +4225,10 @@ pub struct UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnection /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[serde(skip_serializing_if = "Option::is_none")] - pub permissions: Option< - &'a [UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions], - >, + pub permissions: Option<&'a [UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. #[serde(skip_serializing_if = "Option::is_none")] - pub prefetch: Option< - &'a [UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch], - >, + pub prefetch: Option<&'a [UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, /// For webview integrations only. /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. #[serde(skip_serializing_if = "Option::is_none")] @@ -5128,9 +4261,7 @@ impl UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermi } } -impl std::str::FromStr - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; @@ -5143,78 +4274,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// List of data features that you would like to retrieve upon account creation. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { - Balances, - Transactions, -} -impl UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { - pub fn as_str(self) -> &'static str { - use UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; - match self { - Balances => "balances", - Transactions => "transactions", - } - } -} - -impl std::str::FromStr - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; - match s { - "balances" => Ok(Balances), - "transactions" => Ok(Transactions), - _ => Err(()), - } - } -} -impl std::fmt::Display - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5222,63 +4293,42 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Additional fields for Mandate creation -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { - /// The method used to collect offline mandate customer acceptance. - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: - Option<UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod>, -} -impl UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { - pub fn new() -> Self { - Self::default() - } -} -/// The method used to collect offline mandate customer acceptance. +/// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - Paper, +pub enum UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { + Balances, } -impl UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { +impl UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { - use UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; + use UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { - Paper => "paper", + Balances => "balances", } } } -impl std::str::FromStr - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::str::FromStr for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; + use UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { - "paper" => Ok(Paper), + "balances" => Ok(Balances), _ => Err(()), } } } -impl std::fmt::Display - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Display for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl std::fmt::Debug for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5291,8 +4341,7 @@ impl serde::Serialize pub struct UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { /// Triggers validations to run across the selected networks #[serde(skip_serializing_if = "Option::is_none")] - pub requested: - Option<&'a [UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, + pub requested: Option<&'a [UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, } impl<'a> UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { pub fn new() -> Self { @@ -5345,7 +4394,7 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetw serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, @@ -5396,43 +4445,11 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsUsBankAccountVeri } impl<'a> UpdateSetupIntent<'a> { /// Updates a SetupIntent object. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::SetupIntentId, - ) -> stripe::Response<stripe_shared::SetupIntent> { + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::SetupIntentId) -> stripe::Response<stripe_shared::SetupIntent> { client.send_form(&format!("/setup_intents/{intent}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelSetupIntent<'a> { - /// Reason for canceling this SetupIntent. - /// Possible values are: `abandoned`, `requested_by_customer`, or `duplicate`. - #[serde(skip_serializing_if = "Option::is_none")] - pub cancellation_reason: Option<stripe_shared::SetupIntentCancellationReason>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CancelSetupIntent<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CancelSetupIntent<'a> { - /// You can cancel a SetupIntent object when it’s in one of these statuses: `requires_payment_method`, `requires_confirmation`, or `requires_action`. - /// - /// - /// After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::SetupIntentId, - ) -> stripe::Response<stripe_shared::SetupIntent> { - client.send_form(&format!("/setup_intents/{intent}/cancel"), self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntent<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -5475,9 +4492,7 @@ pub struct ConfirmSetupIntentSecretKeyParam<'a> { pub customer_acceptance: ConfirmSetupIntentSecretKeyParamCustomerAcceptance<'a>, } impl<'a> ConfirmSetupIntentSecretKeyParam<'a> { - pub fn new( - customer_acceptance: ConfirmSetupIntentSecretKeyParamCustomerAcceptance<'a>, - ) -> Self { + pub fn new(customer_acceptance: ConfirmSetupIntentSecretKeyParamCustomerAcceptance<'a>) -> Self { Self { customer_acceptance } } } @@ -5495,7 +4510,7 @@ pub struct ConfirmSetupIntentSecretKeyParamCustomerAcceptance<'a> { pub online: Option<OnlineParam<'a>>, /// The type of customer acceptance information included with the Mandate. /// One of `online` or `offline`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ConfirmSetupIntentSecretKeyParamCustomerAcceptanceType, } impl<'a> ConfirmSetupIntentSecretKeyParamCustomerAcceptance<'a> { @@ -5556,9 +4571,7 @@ pub struct ConfirmSetupIntentClientKeyParam<'a> { pub customer_acceptance: ConfirmSetupIntentClientKeyParamCustomerAcceptance<'a>, } impl<'a> ConfirmSetupIntentClientKeyParam<'a> { - pub fn new( - customer_acceptance: ConfirmSetupIntentClientKeyParamCustomerAcceptance<'a>, - ) -> Self { + pub fn new(customer_acceptance: ConfirmSetupIntentClientKeyParamCustomerAcceptance<'a>) -> Self { Self { customer_acceptance } } } @@ -5568,14 +4581,11 @@ pub struct ConfirmSetupIntentClientKeyParamCustomerAcceptance<'a> { /// If this is a Mandate accepted online, this hash contains details about the online acceptance. pub online: ConfirmSetupIntentClientKeyParamCustomerAcceptanceOnline<'a>, /// The type of customer acceptance information included with the Mandate. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ConfirmSetupIntentClientKeyParamCustomerAcceptanceType, } impl<'a> ConfirmSetupIntentClientKeyParamCustomerAcceptance<'a> { - pub fn new( - online: ConfirmSetupIntentClientKeyParamCustomerAcceptanceOnline<'a>, - type_: ConfirmSetupIntentClientKeyParamCustomerAcceptanceType, - ) -> Self { + pub fn new(online: ConfirmSetupIntentClientKeyParamCustomerAcceptanceOnline<'a>, type_: ConfirmSetupIntentClientKeyParamCustomerAcceptanceType) -> Self { Self { online, type_ } } } @@ -5741,13 +4751,10 @@ pub struct ConfirmSetupIntentPaymentMethodData<'a> { /// If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<ConfirmSetupIntentPaymentMethodDataSofort>, - /// If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<&'a serde_json::Value>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ConfirmSetupIntentPaymentMethodDataType, /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. #[serde(skip_serializing_if = "Option::is_none")] @@ -5794,7 +4801,6 @@ impl<'a> ConfirmSetupIntentPaymentMethodData<'a> { revolut_pay: None, sepa_debit: None, sofort: None, - swish: None, type_, us_bank_account: None, wechat_pay: None, @@ -6175,7 +5181,6 @@ pub enum ConfirmSetupIntentPaymentMethodDataIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -6198,7 +5203,6 @@ impl ConfirmSetupIntentPaymentMethodDataIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -6224,7 +5228,6 @@ impl std::str::FromStr for ConfirmSetupIntentPaymentMethodDataIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -6307,7 +5310,6 @@ pub enum ConfirmSetupIntentPaymentMethodDataP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -6340,7 +5342,6 @@ impl ConfirmSetupIntentPaymentMethodDataP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -6376,7 +5377,6 @@ impl std::str::FromStr for ConfirmSetupIntentPaymentMethodDataP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -6515,7 +5515,6 @@ pub enum ConfirmSetupIntentPaymentMethodDataType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -6554,7 +5553,6 @@ impl ConfirmSetupIntentPaymentMethodDataType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -6596,7 +5594,6 @@ impl std::str::FromStr for ConfirmSetupIntentPaymentMethodDataType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -6628,8 +5625,7 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataType { pub struct ConfirmSetupIntentPaymentMethodDataUsBankAccount<'a> { /// Account holder type: individual or company. #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: - Option<ConfirmSetupIntentPaymentMethodDataUsBankAccountAccountHolderType>, + pub account_holder_type: Option<ConfirmSetupIntentPaymentMethodDataUsBankAccountAccountHolderType>, /// Account number of the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<&'a str>, @@ -6777,10 +5773,9 @@ pub struct ConfirmSetupIntentPaymentMethodOptionsAcssDebit<'a> { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option<ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a>>, - /// Bank account verification method. + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<ConfirmSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>, + pub verification_method: Option<ConfirmSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } impl<'a> ConfirmSetupIntentPaymentMethodOptionsAcssDebit<'a> { pub fn new() -> Self { @@ -6844,20 +5839,17 @@ pub struct ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub custom_mandate_url: Option<&'a str>, /// List of Stripe products where this mandate can be selected automatically. #[serde(skip_serializing_if = "Option::is_none")] - pub default_for: - Option<&'a [ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, + pub default_for: Option<&'a [ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor]>, /// Description of the mandate interval. /// Only required if 'payment_schedule' parameter is 'interval' or 'combined'. #[serde(skip_serializing_if = "Option::is_none")] pub interval_description: Option<&'a str>, /// Payment schedule for the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub payment_schedule: - Option<ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, + pub payment_schedule: Option<ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule>, /// Transaction type of the mandate. #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_type: - Option<ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, + pub transaction_type: Option<ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } impl<'a> ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { pub fn new() -> Self { @@ -6928,9 +5920,7 @@ impl ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedul } } -impl std::str::FromStr - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::str::FromStr for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule::*; @@ -6942,24 +5932,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Display for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl std::fmt::Debug for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule -{ +impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -6983,9 +5967,7 @@ impl ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionTyp } } -impl std::str::FromStr - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::str::FromStr for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType::*; @@ -6996,24 +5978,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Display for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl std::fmt::Debug for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -7021,7 +5997,7 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { Automatic, @@ -7088,15 +6064,11 @@ pub struct ConfirmSetupIntentPaymentMethodOptionsCard<'a> { pub network: Option<ConfirmSetupIntentPaymentMethodOptionsCardNetwork>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[serde(skip_serializing_if = "Option::is_none")] - pub request_three_d_secure: - Option<ConfirmSetupIntentPaymentMethodOptionsCardRequestThreeDSecure>, - /// If 3D Secure authentication was performed with a third-party provider, - /// the authentication details to use for this setup. - #[serde(skip_serializing_if = "Option::is_none")] - pub three_d_secure: Option<ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecure<'a>>, + pub request_three_d_secure: Option<ConfirmSetupIntentPaymentMethodOptionsCardRequestThreeDSecure>, } impl<'a> ConfirmSetupIntentPaymentMethodOptionsCard<'a> { pub fn new() -> Self { @@ -7138,8 +6110,7 @@ pub struct ConfirmSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { pub start_date: stripe_types::Timestamp, /// Specifies the type of mandates supported. Possible values are `india`. #[serde(skip_serializing_if = "Option::is_none")] - pub supported_types: - Option<&'a [ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, + pub supported_types: Option<&'a [ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes]>, } impl<'a> ConfirmSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { pub fn new( @@ -7150,18 +6121,7 @@ impl<'a> ConfirmSetupIntentPaymentMethodOptionsCardMandateOptions<'a> { reference: &'a str, start_date: stripe_types::Timestamp, ) -> Self { - Self { - amount, - amount_type, - currency, - description: None, - end_date: None, - interval, - interval_count: None, - reference, - start_date, - supported_types: None, - } + Self { amount, amount_type, currency, description: None, end_date: None, interval, interval_count: None, reference, start_date, supported_types: None } } } /// One of `fixed` or `maximum`. @@ -7387,13 +6347,13 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardNetwork { } /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl ConfirmSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -7401,7 +6361,6 @@ impl ConfirmSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -7413,7 +6372,6 @@ impl std::str::FromStr for ConfirmSetupIntentPaymentMethodOptionsCardRequestThre match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -7437,333 +6395,6 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardRequestThree serializer.serialize_str(self.as_str()) } } -/// If 3D Secure authentication was performed with a third-party provider, -/// the authentication details to use for this setup. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecure<'a> { - /// The `transStatus` returned from the card Issuer’s ACS in the ARes. - #[serde(skip_serializing_if = "Option::is_none")] - pub ares_trans_status: - Option<ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus>, - /// The cryptogram, also known as the "authentication value" (AAV, CAVV or - /// AEVV). This value is 20 bytes, base64-encoded into a 28-character string. - /// (Most 3D Secure providers will return the base64-encoded version, which - /// is what you should specify here.) - #[serde(skip_serializing_if = "Option::is_none")] - pub cryptogram: Option<&'a str>, - /// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure - /// provider and indicates what degree of authentication was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub electronic_commerce_indicator: - Option<ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator>, - /// Network specific 3DS fields. Network specific arguments require an - /// explicit card brand choice. The parameter `payment_method_options.card.network`` - /// must be populated accordingly - #[serde(skip_serializing_if = "Option::is_none")] - pub network_options: - Option<ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a>>, - /// The challenge indicator (`threeDSRequestorChallengeInd`) which was requested in the - /// AReq sent to the card Issuer's ACS. A string containing 2 digits from 01-99. - #[serde(skip_serializing_if = "Option::is_none")] - pub requestor_challenge_indicator: Option<&'a str>, - /// For 3D Secure 1, the XID. For 3D Secure 2, the Directory Server - /// Transaction ID (dsTransID). - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_id: Option<&'a str>, - /// The version of 3D Secure that was performed. - #[serde(skip_serializing_if = "Option::is_none")] - pub version: Option<ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion>, -} -impl<'a> ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecure<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The `transStatus` returned from the card Issuer’s ACS in the ARes. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - A, - C, - I, - N, - R, - U, - Y, -} -impl ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - pub fn as_str(self) -> &'static str { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match self { - A => "A", - C => "C", - I => "I", - N => "N", - R => "R", - U => "U", - Y => "Y", - } - } -} - -impl std::str::FromStr for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus::*; - match s { - "A" => Ok(A), - "C" => Ok(C), - "I" => Ok(I), - "N" => Ok(N), - "R" => Ok(R), - "U" => Ok(U), - "Y" => Ok(Y), - _ => Err(()), - } - } -} -impl std::fmt::Display for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The Electronic Commerce Indicator (ECI) is returned by your 3D Secure -/// provider and indicates what degree of authentication was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator { - pub fn as_str(self) -> &'static str { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", - } - } -} - -impl std::str::FromStr - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator::*; - match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), - _ => Err(()), - } - } -} -impl std::fmt::Display - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Network specific 3DS fields. Network specific arguments require an -/// explicit card brand choice. The parameter `payment_method_options.card.network`` -/// must be populated accordingly -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - /// Cartes Bancaires-specific 3DS fields. - #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option< - ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a>, - >, -} -impl<'a> ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptions<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Cartes Bancaires-specific 3DS fields. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - /// The cryptogram calculation algorithm used by the card Issuer's ACS - /// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. - /// messageExtension: CB-AVALGO - pub cb_avalgo: - ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - /// The exemption indicator returned from Cartes Bancaires in the ARes. - /// message extension: CB-EXEMPTION; string (4 characters) - /// This is a 3 byte bitmap (low significant byte first and most significant - /// bit first) that has been Base64 encoded - #[serde(skip_serializing_if = "Option::is_none")] - pub cb_exemption: Option<&'a str>, - /// The risk score returned from Cartes Bancaires in the ARes. - /// message extension: CB-SCORE; numeric value 0-99 - #[serde(skip_serializing_if = "Option::is_none")] - pub cb_score: Option<i64>, -} -impl<'a> ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancaires<'a> { - pub fn new( - cb_avalgo: ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo, - ) -> Self { - Self { cb_avalgo, cb_exemption: None, cb_score: None } - } -} -/// The cryptogram calculation algorithm used by the card Issuer's ACS -/// to calculate the Authentication cryptogram. Also known as `cavvAlgorithm`. -/// messageExtension: CB-AVALGO -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - V0, - V1, - V2, - V3, - V4, - A, -} -impl ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { - pub fn as_str(self) -> &'static str { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match self { - V0 => "0", - V1 => "1", - V2 => "2", - V3 => "3", - V4 => "4", - A => "A", - } - } -} - -impl std::str::FromStr - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo::*; - match s { - "0" => Ok(V0), - "1" => Ok(V1), - "2" => Ok(V2), - "3" => Ok(V3), - "4" => Ok(V4), - "A" => Ok(A), - _ => Err(()), - } - } -} -impl std::fmt::Display - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// The version of 3D Secure that was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - V1_0_2, - V2_1_0, - V2_2_0, -} -impl ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - pub fn as_str(self) -> &'static str { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match self { - V1_0_2 => "1.0.2", - V2_1_0 => "2.1.0", - V2_2_0 => "2.2.0", - } - } -} - -impl std::str::FromStr for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion::*; - match s { - "1.0.2" => Ok(V1_0_2), - "2.1.0" => Ok(V2_1_0), - "2.2.0" => Ok(V2_2_0), - _ => Err(()), - } - } -} -impl std::fmt::Display for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodOptionsSepaDebit<'a> { @@ -7781,18 +6412,13 @@ impl<'a> ConfirmSetupIntentPaymentMethodOptionsSepaDebit<'a> { pub struct ConfirmSetupIntentPaymentMethodOptionsUsBankAccount<'a> { /// Additional fields for Financial Connections Session creation #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, - /// Additional fields for Mandate creation - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions>, + pub financial_connections: Option<ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnections<'a>>, /// Additional fields for network related functions #[serde(skip_serializing_if = "Option::is_none")] pub networks: Option<ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a>>, - /// Bank account verification method. + /// Verification method for the intent #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<ConfirmSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<ConfirmSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } impl<'a> ConfirmSetupIntentPaymentMethodOptionsUsBankAccount<'a> { pub fn new() -> Self { @@ -7806,14 +6432,10 @@ pub struct ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectio /// If this parameter is passed, the `payment_method` permission must be included. /// Valid permissions include: `balances`, `ownership`, `payment_method`, and `transactions`. #[serde(skip_serializing_if = "Option::is_none")] - pub permissions: Option< - &'a [ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions], - >, + pub permissions: Option<&'a [ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions]>, /// List of data features that you would like to retrieve upon account creation. #[serde(skip_serializing_if = "Option::is_none")] - pub prefetch: Option< - &'a [ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch], - >, + pub prefetch: Option<&'a [ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch]>, /// For webview integrations only. /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. #[serde(skip_serializing_if = "Option::is_none")] @@ -7846,9 +6468,7 @@ impl ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPerm } } -impl std::str::FromStr - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::str::FromStr for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions::*; @@ -7861,24 +6481,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Display for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl std::fmt::Debug for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions -{ +impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -7890,113 +6504,38 @@ impl serde::Serialize #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { Balances, - Transactions, } impl ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { pub fn as_str(self) -> &'static str { use ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } -impl std::str::FromStr - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::str::FromStr for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } } -impl std::fmt::Display - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Display for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ +impl std::fmt::Debug for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Additional fields for Mandate creation -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { - /// The method used to collect offline mandate customer acceptance. - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: - Option<ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod>, -} -impl ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { - pub fn new() -> Self { - Self::default() - } -} -/// The method used to collect offline mandate customer acceptance. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - Paper, -} -impl ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - pub fn as_str(self) -> &'static str { - use ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match self { - Paper => "paper", - } - } -} - -impl std::str::FromStr - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match s { - "paper" => Ok(Paper), - _ => Err(()), - } - } -} -impl std::fmt::Display - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ +impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -8009,8 +6548,7 @@ impl serde::Serialize pub struct ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { /// Triggers validations to run across the selected networks #[serde(skip_serializing_if = "Option::is_none")] - pub requested: - Option<&'a [ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, + pub requested: Option<&'a [ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested]>, } impl<'a> ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { pub fn new() -> Self { @@ -8063,7 +6601,7 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNet serializer.serialize_str(self.as_str()) } } -/// Bank account verification method. +/// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { Automatic, @@ -8127,16 +6665,32 @@ impl<'a> ConfirmSetupIntent<'a> { /// the SetupIntent will transition to the /// `requires_payment_method` status or the `canceled` status if the /// confirmation limit is reached. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::SetupIntentId, - ) -> stripe::Response<stripe_shared::SetupIntent> { - client.send_form( - &format!("/setup_intents/{intent}/confirm"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::SetupIntentId) -> stripe::Response<stripe_shared::SetupIntent> { + client.send_form(&format!("/setup_intents/{intent}/confirm"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CancelSetupIntent<'a> { + /// Reason for canceling this SetupIntent. + /// Possible values are: `abandoned`, `requested_by_customer`, or `duplicate`. + #[serde(skip_serializing_if = "Option::is_none")] + pub cancellation_reason: Option<stripe_shared::SetupIntentCancellationReason>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> CancelSetupIntent<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> CancelSetupIntent<'a> { + /// You can cancel a SetupIntent object when it’s in one of these statuses: `requires_payment_method`, `requires_confirmation`, or `requires_action`. + /// + /// + /// After you cancel it, setup is abandoned and any operations on the SetupIntent fail with an error. + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::SetupIntentId) -> stripe::Response<stripe_shared::SetupIntent> { + client.send_form(&format!("/setup_intents/{intent}/cancel"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -8158,16 +6712,8 @@ impl<'a> VerifyMicrodepositsSetupIntent<'a> { } impl<'a> VerifyMicrodepositsSetupIntent<'a> { /// Verifies microdeposits on a SetupIntent object. - pub fn send( - &self, - client: &stripe::Client, - intent: &stripe_shared::SetupIntentId, - ) -> stripe::Response<stripe_shared::SetupIntent> { - client.send_form( - &format!("/setup_intents/{intent}/verify_microdeposits"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, intent: &stripe_shared::SetupIntentId) -> stripe::Response<stripe_shared::SetupIntent> { + client.send_form(&format!("/setup_intents/{intent}/verify_microdeposits"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -8192,11 +6738,7 @@ pub struct PaymentMethodParam<'a> { pub transit_number: &'a str, } impl<'a> PaymentMethodParam<'a> { - pub fn new( - account_number: &'a str, - institution_number: &'a str, - transit_number: &'a str, - ) -> Self { + pub fn new(account_number: &'a str, institution_number: &'a str, transit_number: &'a str) -> Self { Self { account_number, institution_number, transit_number } } } diff --git a/generated/stripe_core/src/token/requests.rs b/generated/stripe_core/src/token/requests.rs index 6271ce0f9..634c70d35 100644 --- a/generated/stripe_core/src/token/requests.rs +++ b/generated/stripe_core/src/token/requests.rs @@ -11,11 +11,7 @@ impl<'a> RetrieveToken<'a> { } impl<'a> RetrieveToken<'a> { /// Retrieves the token with the given ID. - pub fn send( - &self, - client: &stripe::Client, - token: &stripe_core::TokenId, - ) -> stripe::Response<stripe_core::Token> { + pub fn send(&self, client: &stripe::Client, token: &stripe_core::TokenId) -> stripe::Response<stripe_core::Token> { client.get_query(&format!("/tokens/{token}"), self) } } @@ -184,7 +180,6 @@ pub struct CreateTokenAccountCompany<'a> { pub registration_number: Option<&'a str>, /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. - /// Pass an empty string to unset this value. #[serde(skip_serializing_if = "Option::is_none")] pub structure: Option<CreateTokenAccountCompanyStructure>, /// The business ID number of the company, as appropriate for the company’s country. @@ -286,7 +281,6 @@ impl<'a> CreateTokenAccountCompanyOwnershipDeclaration<'a> { } /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. -/// Pass an empty string to unset this value. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum CreateTokenAccountCompanyStructure { @@ -305,7 +299,6 @@ pub enum CreateTokenAccountCompanyStructure { PublicCompany, PublicCorporation, PublicPartnership, - RegisteredCharity, SingleMemberLlc, SoleEstablishment, SoleProprietorship, @@ -335,7 +328,6 @@ impl CreateTokenAccountCompanyStructure { PublicCompany => "public_company", PublicCorporation => "public_corporation", PublicPartnership => "public_partnership", - RegisteredCharity => "registered_charity", SingleMemberLlc => "single_member_llc", SoleEstablishment => "sole_establishment", SoleProprietorship => "sole_proprietorship", @@ -368,7 +360,6 @@ impl std::str::FromStr for CreateTokenAccountCompanyStructure { "public_company" => Ok(PublicCompany), "public_corporation" => Ok(PublicCorporation), "public_partnership" => Ok(PublicPartnership), - "registered_charity" => Ok(RegisteredCharity), "single_member_llc" => Ok(SingleMemberLlc), "sole_establishment" => Ok(SoleEstablishment), "sole_proprietorship" => Ok(SoleProprietorship), @@ -498,9 +489,6 @@ pub struct CreateTokenAccountIndividual<'a> { /// The individual's registered address. #[serde(skip_serializing_if = "Option::is_none")] pub registered_address: Option<AddressSpecs<'a>>, - /// Describes the person’s relationship to the account. - #[serde(skip_serializing_if = "Option::is_none")] - pub relationship: Option<CreateTokenAccountIndividualRelationship<'a>>, /// The last four digits of the individual's Social Security Number (U.S. only). #[serde(skip_serializing_if = "Option::is_none")] pub ssn_last_4: Option<&'a str>, @@ -619,31 +607,6 @@ impl serde::Serialize for CreateTokenAccountIndividualPoliticalExposure { serializer.serialize_str(self.as_str()) } } -/// Describes the person’s relationship to the account. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateTokenAccountIndividualRelationship<'a> { - /// Whether the person is a director of the account's legal entity. - /// Directors are typically members of the governing board of the company, or responsible for ensuring the company meets its regulatory obligations. - #[serde(skip_serializing_if = "Option::is_none")] - pub director: Option<bool>, - /// Whether the person has significant responsibility to control, manage, or direct the organization. - #[serde(skip_serializing_if = "Option::is_none")] - pub executive: Option<bool>, - /// Whether the person is an owner of the account’s legal entity. - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<bool>, - /// The percent owned by the person of the account's legal entity. - #[serde(skip_serializing_if = "Option::is_none")] - pub percent_ownership: Option<f64>, - /// The person's title (e.g., CEO, Support Engineer). - #[serde(skip_serializing_if = "Option::is_none")] - pub title: Option<&'a str>, -} -impl<'a> CreateTokenAccountIndividualRelationship<'a> { - pub fn new() -> Self { - Self::default() - } -} /// The bank account this token will represent. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTokenBankAccount<'a> { @@ -676,15 +639,7 @@ pub struct CreateTokenBankAccount<'a> { } impl<'a> CreateTokenBankAccount<'a> { pub fn new(account_number: &'a str, country: &'a str) -> Self { - Self { - account_holder_name: None, - account_holder_type: None, - account_number, - account_type: None, - country, - currency: None, - routing_number: None, - } + Self { account_holder_name: None, account_holder_type: None, account_number, account_type: None, country, currency: None, routing_number: None } } } /// The type of entity that holds the account. diff --git a/generated/stripe_core/src/token/types.rs b/generated/stripe_core/src/token/types.rs index 384f47e6c..16e8a43ef 100644 --- a/generated/stripe_core/src/token/types.rs +++ b/generated/stripe_core/src/token/types.rs @@ -20,11 +20,11 @@ /// performs best with integrations that use client-side tokenization. /// /// For more details see <<https://stripe.com/docs/api/tokens/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Token { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_account: Option<stripe_shared::BankAccount>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::Card>, /// IP address of the client that generates the token. pub client_ip: Option<String>, @@ -35,11 +35,134 @@ pub struct Token { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Type of the token: `account`, `bank_account`, `card`, or `pii`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, /// Determines if you have already used this token (you can only use tokens once). pub used: bool, } +#[cfg(feature = "min-ser")] +pub struct TokenBuilder { + bank_account: Option<Option<stripe_shared::BankAccount>>, + card: Option<Option<stripe_shared::Card>>, + client_ip: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + id: Option<stripe_core::TokenId>, + livemode: Option<bool>, + type_: Option<String>, + used: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Token { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Token>, + builder: TokenBuilder, + } + + impl Visitor for Place<Token> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TokenBuilder::deser_default() })) + } + } + + impl MapBuilder for TokenBuilder { + type Out = Token; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_account" => Deserialize::begin(&mut self.bank_account), + "card" => Deserialize::begin(&mut self.card), + "client_ip" => Deserialize::begin(&mut self.client_ip), + "created" => Deserialize::begin(&mut self.created), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "type" => Deserialize::begin(&mut self.type_), + "used" => Deserialize::begin(&mut self.used), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_account: Deserialize::default(), + card: Deserialize::default(), + client_ip: Deserialize::default(), + created: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + type_: Deserialize::default(), + used: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_account = self.bank_account.take()?; + let card = self.card.take()?; + let client_ip = self.client_ip.take()?; + let created = self.created.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let type_ = self.type_.take()?; + let used = self.used.take()?; + + Some(Self::Out { bank_account, card, client_ip, created, id, livemode, type_, used }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Token { + type Builder = TokenBuilder; + } + + impl FromValueOpt for Token { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TokenBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_account" => b.bank_account = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "client_ip" => b.client_ip = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "used" => b.used = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Token { type Id = stripe_core::TokenId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_fraud/.rustfmt.toml b/generated/stripe_fraud/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_fraud/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_fraud/Cargo.toml b/generated/stripe_fraud/Cargo.toml index 98787509d..0bec38e92 100644 --- a/generated/stripe_fraud/Cargo.toml +++ b/generated/stripe_fraud/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_fraud/src/deleted_radar_value_list.rs b/generated/stripe_fraud/src/deleted_radar_value_list.rs index ea2008599..f898e5b36 100644 --- a/generated/stripe_fraud/src/deleted_radar_value_list.rs +++ b/generated/stripe_fraud/src/deleted_radar_value_list.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedRadarValueList { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_fraud::RadarValueListId, } +#[cfg(feature = "min-ser")] +pub struct DeletedRadarValueListBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_fraud::RadarValueListId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedRadarValueList { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedRadarValueList>, + builder: DeletedRadarValueListBuilder, + } + + impl Visitor for Place<DeletedRadarValueList> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedRadarValueListBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedRadarValueListBuilder { + type Out = DeletedRadarValueList; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedRadarValueList { + type Builder = DeletedRadarValueListBuilder; + } + + impl FromValueOpt for DeletedRadarValueList { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedRadarValueListBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedRadarValueList { type Id = stripe_fraud::RadarValueListId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_fraud/src/deleted_radar_value_list_item.rs b/generated/stripe_fraud/src/deleted_radar_value_list_item.rs index 970a1e13a..5f9e09935 100644 --- a/generated/stripe_fraud/src/deleted_radar_value_list_item.rs +++ b/generated/stripe_fraud/src/deleted_radar_value_list_item.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedRadarValueListItem { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_fraud::RadarValueListItemId, } +#[cfg(feature = "min-ser")] +pub struct DeletedRadarValueListItemBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_fraud::RadarValueListItemId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedRadarValueListItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedRadarValueListItem>, + builder: DeletedRadarValueListItemBuilder, + } + + impl Visitor for Place<DeletedRadarValueListItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedRadarValueListItemBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedRadarValueListItemBuilder { + type Out = DeletedRadarValueListItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedRadarValueListItem { + type Builder = DeletedRadarValueListItemBuilder; + } + + impl FromValueOpt for DeletedRadarValueListItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedRadarValueListItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedRadarValueListItem { type Id = stripe_fraud::RadarValueListItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_fraud/src/mod.rs b/generated/stripe_fraud/src/mod.rs index a578f3a4e..80ce863f8 100644 --- a/generated/stripe_fraud/src/mod.rs +++ b/generated/stripe_fraud/src/mod.rs @@ -7,6 +7,9 @@ //! for requests mentioned in the `Fraud` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_fraud; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); #[doc(hidden)] pub mod deleted_radar_value_list; #[doc(inline)] diff --git a/generated/stripe_fraud/src/radar_early_fraud_warning/requests.rs b/generated/stripe_fraud/src/radar_early_fraud_warning/requests.rs index c98fb6961..d7d2a3864 100644 --- a/generated/stripe_fraud/src/radar_early_fraud_warning/requests.rs +++ b/generated/stripe_fraud/src/radar_early_fraud_warning/requests.rs @@ -3,9 +3,6 @@ pub struct ListRadarEarlyFraudWarning<'a> { /// Only return early fraud warnings for the charge specified by this charge ID. #[serde(skip_serializing_if = "Option::is_none")] pub charge: Option<&'a str>, - /// Only return early fraud warnings that were created during the given date interval. - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. @@ -34,15 +31,10 @@ impl<'a> ListRadarEarlyFraudWarning<'a> { } impl<'a> ListRadarEarlyFraudWarning<'a> { /// Returns a list of early fraud warnings. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_fraud::RadarEarlyFraudWarning>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_fraud::RadarEarlyFraudWarning>> { client.get_query("/radar/early_fraud_warnings", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_fraud::RadarEarlyFraudWarning>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_fraud::RadarEarlyFraudWarning>> { stripe::ListPaginator::from_list_params("/radar/early_fraud_warnings", self) } } @@ -61,11 +53,7 @@ impl<'a> RetrieveRadarEarlyFraudWarning<'a> { /// Retrieves the details of an early fraud warning that has previously been created. /// /// Please refer to the [early fraud warning](https://stripe.com/docs/api#early_fraud_warning_object) object reference for more details. - pub fn send( - &self, - client: &stripe::Client, - early_fraud_warning: &stripe_fraud::RadarEarlyFraudWarningId, - ) -> stripe::Response<stripe_fraud::RadarEarlyFraudWarning> { + pub fn send(&self, client: &stripe::Client, early_fraud_warning: &stripe_fraud::RadarEarlyFraudWarningId) -> stripe::Response<stripe_fraud::RadarEarlyFraudWarning> { client.get_query(&format!("/radar/early_fraud_warnings/{early_fraud_warning}"), self) } } diff --git a/generated/stripe_fraud/src/radar_early_fraud_warning/types.rs b/generated/stripe_fraud/src/radar_early_fraud_warning/types.rs index 2c4a2aac7..0856be8ff 100644 --- a/generated/stripe_fraud/src/radar_early_fraud_warning/types.rs +++ b/generated/stripe_fraud/src/radar_early_fraud_warning/types.rs @@ -2,7 +2,9 @@ /// charge may be fraudulent. /// /// Related guide: [Early fraud warnings](https://stripe.com/docs/disputes/measuring#early-fraud-warnings). -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RadarEarlyFraudWarning { /// An EFW is actionable if it has not received a dispute and has not been fully refunded. /// You may wish to proactively refund a charge that receives an EFW, in order to avoid receiving a dispute later. @@ -19,9 +21,126 @@ pub struct RadarEarlyFraudWarning { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// ID of the Payment Intent this early fraud warning is for, optionally expanded. - #[serde(skip_serializing_if = "Option::is_none")] pub payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, } +#[cfg(feature = "min-ser")] +pub struct RadarEarlyFraudWarningBuilder { + actionable: Option<bool>, + charge: Option<stripe_types::Expandable<stripe_shared::Charge>>, + created: Option<stripe_types::Timestamp>, + fraud_type: Option<String>, + id: Option<stripe_fraud::RadarEarlyFraudWarningId>, + livemode: Option<bool>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RadarEarlyFraudWarning { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RadarEarlyFraudWarning>, + builder: RadarEarlyFraudWarningBuilder, + } + + impl Visitor for Place<RadarEarlyFraudWarning> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RadarEarlyFraudWarningBuilder::deser_default() })) + } + } + + impl MapBuilder for RadarEarlyFraudWarningBuilder { + type Out = RadarEarlyFraudWarning; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "actionable" => Deserialize::begin(&mut self.actionable), + "charge" => Deserialize::begin(&mut self.charge), + "created" => Deserialize::begin(&mut self.created), + "fraud_type" => Deserialize::begin(&mut self.fraud_type), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + actionable: Deserialize::default(), + charge: Deserialize::default(), + created: Deserialize::default(), + fraud_type: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + payment_intent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let actionable = self.actionable.take()?; + let charge = self.charge.take()?; + let created = self.created.take()?; + let fraud_type = self.fraud_type.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let payment_intent = self.payment_intent.take()?; + + Some(Self::Out { actionable, charge, created, fraud_type, id, livemode, payment_intent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RadarEarlyFraudWarning { + type Builder = RadarEarlyFraudWarningBuilder; + } + + impl FromValueOpt for RadarEarlyFraudWarning { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RadarEarlyFraudWarningBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "actionable" => b.actionable = Some(FromValueOpt::from_value(v)?), + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "fraud_type" => b.fraud_type = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for RadarEarlyFraudWarning { type Id = stripe_fraud::RadarEarlyFraudWarningId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_fraud/src/radar_value_list/requests.rs b/generated/stripe_fraud/src/radar_value_list/requests.rs index a6655f0d3..b244f504d 100644 --- a/generated/stripe_fraud/src/radar_value_list/requests.rs +++ b/generated/stripe_fraud/src/radar_value_list/requests.rs @@ -1,26 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteRadarValueList {} -impl DeleteRadarValueList { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteRadarValueList { - /// Deletes a `ValueList` object, also deleting any items contained within the value list. - /// To be deleted, a value list must not be referenced in any rules. - pub fn send( - &self, - client: &stripe::Client, - value_list: &stripe_fraud::RadarValueListId, - ) -> stripe::Response<stripe_fraud::DeletedRadarValueList> { - client.send_form( - &format!("/radar/value_lists/{value_list}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListRadarValueList<'a> { /// The alias used to reference the value list when writing rules. #[serde(skip_serializing_if = "Option::is_none")] @@ -56,15 +34,10 @@ impl<'a> ListRadarValueList<'a> { impl<'a> ListRadarValueList<'a> { /// Returns a list of `ValueList` objects. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_fraud::RadarValueList>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_fraud::RadarValueList>> { client.get_query("/radar/value_lists", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_fraud::RadarValueList>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_fraud::RadarValueList>> { stripe::ListPaginator::from_list_params("/radar/value_lists", self) } } @@ -81,11 +54,7 @@ impl<'a> RetrieveRadarValueList<'a> { } impl<'a> RetrieveRadarValueList<'a> { /// Retrieves a `ValueList` object. - pub fn send( - &self, - client: &stripe::Client, - value_list: &stripe_fraud::RadarValueListId, - ) -> stripe::Response<stripe_fraud::RadarValueList> { + pub fn send(&self, client: &stripe::Client, value_list: &stripe_fraud::RadarValueListId) -> stripe::Response<stripe_fraud::RadarValueList> { client.get_query(&format!("/radar/value_lists/{value_list}"), self) } } @@ -148,15 +117,21 @@ impl<'a> UpdateRadarValueList<'a> { /// Updates a `ValueList` object by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. /// Note that `item_type` is immutable. - pub fn send( - &self, - client: &stripe::Client, - value_list: &stripe_fraud::RadarValueListId, - ) -> stripe::Response<stripe_fraud::RadarValueList> { - client.send_form( - &format!("/radar/value_lists/{value_list}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, value_list: &stripe_fraud::RadarValueListId) -> stripe::Response<stripe_fraud::RadarValueList> { + client.send_form(&format!("/radar/value_lists/{value_list}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteRadarValueList {} +impl DeleteRadarValueList { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteRadarValueList { + /// Deletes a `ValueList` object, also deleting any items contained within the value list. + /// To be deleted, a value list must not be referenced in any rules. + pub fn send(&self, client: &stripe::Client, value_list: &stripe_fraud::RadarValueListId) -> stripe::Response<stripe_fraud::DeletedRadarValueList> { + client.send_form(&format!("/radar/value_lists/{value_list}"), self, http_types::Method::Delete) } } diff --git a/generated/stripe_fraud/src/radar_value_list/types.rs b/generated/stripe_fraud/src/radar_value_list/types.rs index 0039ce9cf..127df0b4e 100644 --- a/generated/stripe_fraud/src/radar_value_list/types.rs +++ b/generated/stripe_fraud/src/radar_value_list/types.rs @@ -3,7 +3,9 @@ /// Related guide: [Default Stripe lists](https://stripe.com/docs/radar/lists#managing-list-items) /// /// For more details see <<https://stripe.com/docs/api/radar/value_lists/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RadarValueList { /// The name of the value list for use in rules. pub alias: String, @@ -26,6 +28,134 @@ pub struct RadarValueList { /// The name of the value list. pub name: String, } +#[cfg(feature = "min-ser")] +pub struct RadarValueListBuilder { + alias: Option<String>, + created: Option<stripe_types::Timestamp>, + created_by: Option<String>, + id: Option<stripe_fraud::RadarValueListId>, + item_type: Option<stripe_fraud::RadarValueListItemType>, + list_items: Option<stripe_types::List<stripe_fraud::RadarValueListItem>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + name: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RadarValueList { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RadarValueList>, + builder: RadarValueListBuilder, + } + + impl Visitor for Place<RadarValueList> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RadarValueListBuilder::deser_default() })) + } + } + + impl MapBuilder for RadarValueListBuilder { + type Out = RadarValueList; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alias" => Deserialize::begin(&mut self.alias), + "created" => Deserialize::begin(&mut self.created), + "created_by" => Deserialize::begin(&mut self.created_by), + "id" => Deserialize::begin(&mut self.id), + "item_type" => Deserialize::begin(&mut self.item_type), + "list_items" => Deserialize::begin(&mut self.list_items), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "name" => Deserialize::begin(&mut self.name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alias: Deserialize::default(), + created: Deserialize::default(), + created_by: Deserialize::default(), + id: Deserialize::default(), + item_type: Deserialize::default(), + list_items: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alias = self.alias.take()?; + let created = self.created.take()?; + let created_by = self.created_by.take()?; + let id = self.id.take()?; + let item_type = self.item_type.take()?; + let list_items = self.list_items.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let name = self.name.take()?; + + Some(Self::Out { alias, created, created_by, id, item_type, list_items, livemode, metadata, name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RadarValueList { + type Builder = RadarValueListBuilder; + } + + impl FromValueOpt for RadarValueList { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RadarValueListBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alias" => b.alias = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "created_by" => b.created_by = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "item_type" => b.item_type = Some(FromValueOpt::from_value(v)?), + "list_items" => b.list_items = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for RadarValueList { type Id = stripe_fraud::RadarValueListId; fn id(&self) -> &Self::Id { @@ -106,7 +236,24 @@ impl<'de> serde::Deserialize<'de> for RadarValueListItemType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for RadarValueListItemType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for RadarValueListItemType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for RadarValueListItemType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<RadarValueListItemType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RadarValueListItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(RadarValueListItemType); diff --git a/generated/stripe_fraud/src/radar_value_list_item/requests.rs b/generated/stripe_fraud/src/radar_value_list_item/requests.rs index d422febbb..65d6d75b9 100644 --- a/generated/stripe_fraud/src/radar_value_list_item/requests.rs +++ b/generated/stripe_fraud/src/radar_value_list_item/requests.rs @@ -1,24 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteRadarValueListItem {} -impl DeleteRadarValueListItem { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteRadarValueListItem { - /// Deletes a `ValueListItem` object, removing it from its parent value list. - pub fn send( - &self, - client: &stripe::Client, - item: &stripe_fraud::RadarValueListItemId, - ) -> stripe::Response<stripe_fraud::DeletedRadarValueListItem> { - client.send_form( - &format!("/radar/value_list_items/{item}"), - self, - http_types::Method::Delete, - ) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ListRadarValueListItem<'a> { #[serde(skip_serializing_if = "Option::is_none")] @@ -48,29 +27,16 @@ pub struct ListRadarValueListItem<'a> { } impl<'a> ListRadarValueListItem<'a> { pub fn new(value_list: &'a str) -> Self { - Self { - created: None, - ending_before: None, - expand: None, - limit: None, - starting_after: None, - value: None, - value_list, - } + Self { created: None, ending_before: None, expand: None, limit: None, starting_after: None, value: None, value_list } } } impl<'a> ListRadarValueListItem<'a> { /// Returns a list of `ValueListItem` objects. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_fraud::RadarValueListItem>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_fraud::RadarValueListItem>> { client.get_query("/radar/value_list_items", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_fraud::RadarValueListItem>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_fraud::RadarValueListItem>> { stripe::ListPaginator::from_list_params("/radar/value_list_items", self) } } @@ -87,11 +53,7 @@ impl<'a> RetrieveRadarValueListItem<'a> { } impl<'a> RetrieveRadarValueListItem<'a> { /// Retrieves a `ValueListItem` object. - pub fn send( - &self, - client: &stripe::Client, - item: &stripe_fraud::RadarValueListItemId, - ) -> stripe::Response<stripe_fraud::RadarValueListItem> { + pub fn send(&self, client: &stripe::Client, item: &stripe_fraud::RadarValueListItemId) -> stripe::Response<stripe_fraud::RadarValueListItem> { client.get_query(&format!("/radar/value_list_items/{item}"), self) } } @@ -112,10 +74,20 @@ impl<'a> CreateRadarValueListItem<'a> { } impl<'a> CreateRadarValueListItem<'a> { /// Creates a new `ValueListItem` object, which is added to the specified parent value list. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_fraud::RadarValueListItem> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_fraud::RadarValueListItem> { client.send_form("/radar/value_list_items", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteRadarValueListItem {} +impl DeleteRadarValueListItem { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteRadarValueListItem { + /// Deletes a `ValueListItem` object, removing it from its parent value list. + pub fn send(&self, client: &stripe::Client, item: &stripe_fraud::RadarValueListItemId) -> stripe::Response<stripe_fraud::DeletedRadarValueListItem> { + client.send_form(&format!("/radar/value_list_items/{item}"), self, http_types::Method::Delete) + } +} diff --git a/generated/stripe_fraud/src/radar_value_list_item/types.rs b/generated/stripe_fraud/src/radar_value_list_item/types.rs index e8bcb6533..38fe980b4 100644 --- a/generated/stripe_fraud/src/radar_value_list_item/types.rs +++ b/generated/stripe_fraud/src/radar_value_list_item/types.rs @@ -3,7 +3,9 @@ /// Related guide: [Managing list items](https://stripe.com/docs/radar/lists#managing-list-items) /// /// For more details see <<https://stripe.com/docs/api/radar/value_list_items/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RadarValueListItem { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -18,6 +20,119 @@ pub struct RadarValueListItem { /// The identifier of the value list this item belongs to. pub value_list: String, } +#[cfg(feature = "min-ser")] +pub struct RadarValueListItemBuilder { + created: Option<stripe_types::Timestamp>, + created_by: Option<String>, + id: Option<stripe_fraud::RadarValueListItemId>, + livemode: Option<bool>, + value: Option<String>, + value_list: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RadarValueListItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RadarValueListItem>, + builder: RadarValueListItemBuilder, + } + + impl Visitor for Place<RadarValueListItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RadarValueListItemBuilder::deser_default() })) + } + } + + impl MapBuilder for RadarValueListItemBuilder { + type Out = RadarValueListItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "created_by" => Deserialize::begin(&mut self.created_by), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "value" => Deserialize::begin(&mut self.value), + "value_list" => Deserialize::begin(&mut self.value_list), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + created_by: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + value: Deserialize::default(), + value_list: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let created_by = self.created_by.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let value = self.value.take()?; + let value_list = self.value_list.take()?; + + Some(Self::Out { created, created_by, id, livemode, value, value_list }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RadarValueListItem { + type Builder = RadarValueListItemBuilder; + } + + impl FromValueOpt for RadarValueListItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RadarValueListItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "created_by" => b.created_by = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + "value_list" => b.value_list = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for RadarValueListItem { type Id = stripe_fraud::RadarValueListItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_fraud/src/review/requests.rs b/generated/stripe_fraud/src/review/requests.rs index 310572897..faf6ee269 100644 --- a/generated/stripe_fraud/src/review/requests.rs +++ b/generated/stripe_fraud/src/review/requests.rs @@ -28,10 +28,7 @@ impl<'a> ListReview<'a> { impl<'a> ListReview<'a> { /// Returns a list of `Review` objects that have `open` set to `true`. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Review>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Review>> { client.get_query("/reviews", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Review>> { @@ -51,11 +48,7 @@ impl<'a> RetrieveReview<'a> { } impl<'a> RetrieveReview<'a> { /// Retrieves a `Review` object. - pub fn send( - &self, - client: &stripe::Client, - review: &stripe_shared::ReviewId, - ) -> stripe::Response<stripe_shared::Review> { + pub fn send(&self, client: &stripe::Client, review: &stripe_shared::ReviewId) -> stripe::Response<stripe_shared::Review> { client.get_query(&format!("/reviews/{review}"), self) } } @@ -72,11 +65,7 @@ impl<'a> ApproveReview<'a> { } impl<'a> ApproveReview<'a> { /// Approves a `Review` object, closing it and removing it from the list of reviews. - pub fn send( - &self, - client: &stripe::Client, - review: &stripe_shared::ReviewId, - ) -> stripe::Response<stripe_shared::Review> { + pub fn send(&self, client: &stripe::Client, review: &stripe_shared::ReviewId) -> stripe::Response<stripe_shared::Review> { client.send_form(&format!("/reviews/{review}/approve"), self, http_types::Method::Post) } } diff --git a/generated/stripe_issuing/.rustfmt.toml b/generated/stripe_issuing/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_issuing/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_issuing/Cargo.toml b/generated/stripe_issuing/Cargo.toml index 30e00b043..ba6a354ca 100644 --- a/generated/stripe_issuing/Cargo.toml +++ b/generated/stripe_issuing/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_issuing/src/issuing_authorization/requests.rs b/generated/stripe_issuing/src/issuing_authorization/requests.rs index 8e7337656..be188ff78 100644 --- a/generated/stripe_issuing/src/issuing_authorization/requests.rs +++ b/generated/stripe_issuing/src/issuing_authorization/requests.rs @@ -38,15 +38,10 @@ impl<'a> ListIssuingAuthorization<'a> { impl<'a> ListIssuingAuthorization<'a> { /// Returns a list of Issuing `Authorization` objects. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::IssuingAuthorization>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::IssuingAuthorization>> { client.get_query("/issuing/authorizations", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingAuthorization>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingAuthorization>> { stripe::ListPaginator::from_list_params("/issuing/authorizations", self) } } @@ -63,11 +58,7 @@ impl<'a> RetrieveIssuingAuthorization<'a> { } impl<'a> RetrieveIssuingAuthorization<'a> { /// Retrieves an Issuing `Authorization` object. - pub fn send( - &self, - client: &stripe::Client, - authorization: &stripe_shared::IssuingAuthorizationId, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { + pub fn send(&self, client: &stripe::Client, authorization: &stripe_shared::IssuingAuthorizationId) -> stripe::Response<stripe_shared::IssuingAuthorization> { client.get_query(&format!("/issuing/authorizations/{authorization}"), self) } } @@ -91,16 +82,8 @@ impl<'a> UpdateIssuingAuthorization<'a> { impl<'a> UpdateIssuingAuthorization<'a> { /// Updates the specified Issuing `Authorization` object by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - authorization: &stripe_shared::IssuingAuthorizationId, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { - client.send_form( - &format!("/issuing/authorizations/{authorization}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, authorization: &stripe_shared::IssuingAuthorizationId) -> stripe::Response<stripe_shared::IssuingAuthorization> { + client.send_form(&format!("/issuing/authorizations/{authorization}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -130,16 +113,8 @@ impl<'a> ApproveIssuingAuthorization<'a> { /// /// This method is deprecated. /// Instead, [respond directly to the webhook request to approve an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). - pub fn send( - &self, - client: &stripe::Client, - authorization: &stripe_shared::IssuingAuthorizationId, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { - client.send_form( - &format!("/issuing/authorizations/{authorization}/approve"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, authorization: &stripe_shared::IssuingAuthorizationId) -> stripe::Response<stripe_shared::IssuingAuthorization> { + client.send_form(&format!("/issuing/authorizations/{authorization}/approve"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -164,22 +139,14 @@ impl<'a> DeclineIssuingAuthorization<'a> { /// This request should be made within the timeout window of the [real time authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations) flow. /// This method is deprecated. /// Instead, [respond directly to the webhook request to decline an authorization](https://stripe.com/docs/issuing/controls/real-time-authorizations#authorization-handling). - pub fn send( - &self, - client: &stripe::Client, - authorization: &stripe_shared::IssuingAuthorizationId, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { - client.send_form( - &format!("/issuing/authorizations/{authorization}/decline"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, authorization: &stripe_shared::IssuingAuthorizationId) -> stripe::Response<stripe_shared::IssuingAuthorization> { + client.send_form(&format!("/issuing/authorizations/{authorization}/decline"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingAuthorization<'a> { /// The total amount to attempt to authorize. - /// This amount is in the provided currency, or defaults to the card's currency, and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// This amount is in the provided currency, or defaults to the cards currency, and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub amount: i64, /// Detailed breakdown of amount components. /// These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). @@ -632,9 +599,7 @@ impl CreateIssuingAuthorizationMerchantDataCategory { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -644,9 +609,7 @@ impl CreateIssuingAuthorizationMerchantDataCategory { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -688,9 +651,7 @@ impl CreateIssuingAuthorizationMerchantDataCategory { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -700,14 +661,10 @@ impl CreateIssuingAuthorizationMerchantDataCategory { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -728,18 +685,14 @@ impl CreateIssuingAuthorizationMerchantDataCategory { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -747,12 +700,8 @@ impl CreateIssuingAuthorizationMerchantDataCategory { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -772,9 +721,7 @@ impl CreateIssuingAuthorizationMerchantDataCategory { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -787,14 +734,10 @@ impl CreateIssuingAuthorizationMerchantDataCategory { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", MiscellaneousApparelAndAccessoryShops => "miscellaneous_apparel_and_accessory_shops", @@ -803,9 +746,7 @@ impl CreateIssuingAuthorizationMerchantDataCategory { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -817,9 +758,7 @@ impl CreateIssuingAuthorizationMerchantDataCategory { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -839,18 +778,14 @@ impl CreateIssuingAuthorizationMerchantDataCategory { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -864,9 +799,7 @@ impl CreateIssuingAuthorizationMerchantDataCategory { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -878,21 +811,15 @@ impl CreateIssuingAuthorizationMerchantDataCategory { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -908,13 +835,9 @@ impl CreateIssuingAuthorizationMerchantDataCategory { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -980,9 +903,7 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -992,9 +913,7 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -1036,9 +955,7 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -1048,14 +965,10 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -1076,20 +989,14 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -1097,12 +1004,8 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -1122,9 +1025,7 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -1137,27 +1038,19 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -1169,9 +1062,7 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -1191,18 +1082,14 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -1216,9 +1103,7 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -1230,21 +1115,15 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -1260,13 +1139,9 @@ impl std::str::FromStr for CreateIssuingAuthorizationMerchantDataCategory { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1327,12 +1202,10 @@ pub struct CreateIssuingAuthorizationVerificationData { pub address_line1_check: Option<CreateIssuingAuthorizationVerificationDataAddressLine1Check>, /// Whether the cardholder provided a postal code and if it matched the cardholder’s `billing.address.postal_code`. #[serde(skip_serializing_if = "Option::is_none")] - pub address_postal_code_check: - Option<CreateIssuingAuthorizationVerificationDataAddressPostalCodeCheck>, + pub address_postal_code_check: Option<CreateIssuingAuthorizationVerificationDataAddressPostalCodeCheck>, /// The exemption applied to this authorization. #[serde(skip_serializing_if = "Option::is_none")] - pub authentication_exemption: - Option<CreateIssuingAuthorizationVerificationDataAuthenticationExemption>, + pub authentication_exemption: Option<CreateIssuingAuthorizationVerificationDataAuthenticationExemption>, /// Whether the cardholder provided a CVC and if it matched Stripe’s record. #[serde(skip_serializing_if = "Option::is_none")] pub cvc_check: Option<CreateIssuingAuthorizationVerificationDataCvcCheck>, @@ -1452,14 +1325,11 @@ pub struct CreateIssuingAuthorizationVerificationDataAuthenticationExemption { /// The entity that requested the exemption, either the acquiring merchant or the Issuing user. pub claimed_by: CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy, /// The specific exemption claimed for this authorization. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType, } impl CreateIssuingAuthorizationVerificationDataAuthenticationExemption { - pub fn new( - claimed_by: CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy, - type_: CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType, - ) -> Self { + pub fn new(claimed_by: CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy, type_: CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType) -> Self { Self { claimed_by, type_ } } } @@ -1479,9 +1349,7 @@ impl CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy } } -impl std::str::FromStr - for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy -{ +impl std::str::FromStr for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy::*; @@ -1492,24 +1360,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy -{ +impl std::fmt::Display for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy -{ +impl std::fmt::Debug for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy -{ +impl serde::Serialize for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1522,7 +1384,6 @@ impl serde::Serialize pub enum CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType { LowValueTransaction, TransactionRiskAnalysis, - Unknown, } impl CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType { pub fn as_str(self) -> &'static str { @@ -1530,7 +1391,6 @@ impl CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType { match self { LowValueTransaction => "low_value_transaction", TransactionRiskAnalysis => "transaction_risk_analysis", - Unknown => "unknown", } } } @@ -1542,7 +1402,6 @@ impl std::str::FromStr for CreateIssuingAuthorizationVerificationDataAuthenticat match s { "low_value_transaction" => Ok(LowValueTransaction), "transaction_risk_analysis" => Ok(TransactionRiskAnalysis), - "unknown" => Ok(Unknown), _ => Err(()), } } @@ -1780,13 +1639,72 @@ impl serde::Serialize for CreateIssuingAuthorizationWallet { } impl<'a> CreateIssuingAuthorization<'a> { /// Create a test-mode authorization. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::IssuingAuthorization> { client.send_form("/test_helpers/issuing/authorizations", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct IncrementIssuingAuthorization<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// The amount to increment the authorization by. + /// This amount is in the authorization currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + pub increment_amount: i64, + /// If set `true`, you may provide [amount](https://stripe.com/docs/api/issuing/authorizations/approve#approve_issuing_authorization-amount) to control how much to hold for the authorization. + #[serde(skip_serializing_if = "Option::is_none")] + pub is_amount_controllable: Option<bool>, +} +impl<'a> IncrementIssuingAuthorization<'a> { + pub fn new(increment_amount: i64) -> Self { + Self { expand: None, increment_amount, is_amount_controllable: None } + } +} +impl<'a> IncrementIssuingAuthorization<'a> { + /// Increment a test-mode Authorization. + pub fn send(&self, client: &stripe::Client, authorization: &str) -> stripe::Response<stripe_shared::IssuingAuthorization> { + client.send_form(&format!("/test_helpers/issuing/authorizations/{authorization}/increment"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ReverseIssuingAuthorization<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// The amount to reverse from the authorization. + /// If not provided, the full amount of the authorization will be reversed. + /// This amount is in the authorization currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + #[serde(skip_serializing_if = "Option::is_none")] + pub reverse_amount: Option<i64>, +} +impl<'a> ReverseIssuingAuthorization<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ReverseIssuingAuthorization<'a> { + /// Reverse a test-mode Authorization. + pub fn send(&self, client: &stripe::Client, authorization: &str) -> stripe::Response<stripe_shared::IssuingAuthorization> { + client.send_form(&format!("/test_helpers/issuing/authorizations/{authorization}/reverse"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ExpireIssuingAuthorization<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> ExpireIssuingAuthorization<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ExpireIssuingAuthorization<'a> { + /// Expire a test-mode Authorization. + pub fn send(&self, client: &stripe::Client, authorization: &str) -> stripe::Response<stripe_shared::IssuingAuthorization> { + client.send_form(&format!("/test_helpers/issuing/authorizations/{authorization}/expire"), self, http_types::Method::Post) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CaptureIssuingAuthorization<'a> { /// The amount to capture from the authorization. @@ -1891,7 +1809,7 @@ impl<'a> CaptureIssuingAuthorizationPurchaseDetailsFlightSegments<'a> { pub struct CaptureIssuingAuthorizationPurchaseDetailsFuel<'a> { /// The type of fuel that was purchased. /// One of `diesel`, `unleaded_plus`, `unleaded_regular`, `unleaded_super`, or `other`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CaptureIssuingAuthorizationPurchaseDetailsFuelType>, /// The units for `volume_decimal`. One of `us_gallon` or `liter`. @@ -2045,101 +1963,7 @@ impl<'a> CaptureIssuingAuthorizationPurchaseDetailsReceipt<'a> { } impl<'a> CaptureIssuingAuthorization<'a> { /// Capture a test-mode authorization. - pub fn send( - &self, - client: &stripe::Client, - authorization: &str, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { - client.send_form( - &format!("/test_helpers/issuing/authorizations/{authorization}/capture"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ExpireIssuingAuthorization<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> ExpireIssuingAuthorization<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ExpireIssuingAuthorization<'a> { - /// Expire a test-mode Authorization. - pub fn send( - &self, - client: &stripe::Client, - authorization: &str, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { - client.send_form( - &format!("/test_helpers/issuing/authorizations/{authorization}/expire"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct IncrementIssuingAuthorization<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// The amount to increment the authorization by. - /// This amount is in the authorization currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). - pub increment_amount: i64, - /// If set `true`, you may provide [amount](https://stripe.com/docs/api/issuing/authorizations/approve#approve_issuing_authorization-amount) to control how much to hold for the authorization. - #[serde(skip_serializing_if = "Option::is_none")] - pub is_amount_controllable: Option<bool>, -} -impl<'a> IncrementIssuingAuthorization<'a> { - pub fn new(increment_amount: i64) -> Self { - Self { expand: None, increment_amount, is_amount_controllable: None } - } -} -impl<'a> IncrementIssuingAuthorization<'a> { - /// Increment a test-mode Authorization. - pub fn send( - &self, - client: &stripe::Client, - authorization: &str, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { - client.send_form( - &format!("/test_helpers/issuing/authorizations/{authorization}/increment"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ReverseIssuingAuthorization<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// The amount to reverse from the authorization. - /// If not provided, the full amount of the authorization will be reversed. - /// This amount is in the authorization currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). - #[serde(skip_serializing_if = "Option::is_none")] - pub reverse_amount: Option<i64>, -} -impl<'a> ReverseIssuingAuthorization<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ReverseIssuingAuthorization<'a> { - /// Reverse a test-mode Authorization. - pub fn send( - &self, - client: &stripe::Client, - authorization: &str, - ) -> stripe::Response<stripe_shared::IssuingAuthorization> { - client.send_form( - &format!("/test_helpers/issuing/authorizations/{authorization}/reverse"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, authorization: &str) -> stripe::Response<stripe_shared::IssuingAuthorization> { + client.send_form(&format!("/test_helpers/issuing/authorizations/{authorization}/capture"), self, http_types::Method::Post) } } diff --git a/generated/stripe_issuing/src/issuing_card/requests.rs b/generated/stripe_issuing/src/issuing_card/requests.rs index fc21ffa15..be21164bb 100644 --- a/generated/stripe_issuing/src/issuing_card/requests.rs +++ b/generated/stripe_issuing/src/issuing_card/requests.rs @@ -36,7 +36,7 @@ pub struct ListIssuingCard<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub status: Option<stripe_shared::IssuingCardStatus>, /// Only return cards that have the given type. One of `virtual` or `physical`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_shared::IssuingCardType>, } @@ -48,37 +48,13 @@ impl<'a> ListIssuingCard<'a> { impl<'a> ListIssuingCard<'a> { /// Returns a list of Issuing `Card` objects. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::IssuingCard>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::IssuingCard>> { client.get_query("/issuing/cards", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingCard>> { stripe::ListPaginator::from_list_params("/issuing/cards", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveIssuingCard<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveIssuingCard<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveIssuingCard<'a> { - /// Retrieves an Issuing `Card` object. - pub fn send( - &self, - client: &stripe::Client, - card: &stripe_shared::IssuingCardId, - ) -> stripe::Response<stripe_shared::IssuingCard> { - client.get_query(&format!("/issuing/cards/{card}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingCard<'a> { /// The [Cardholder](https://stripe.com/docs/api#issuing_cardholder_object) object with which the card will be associated. @@ -97,9 +73,6 @@ pub struct CreateIssuingCard<'a> { /// All keys can be unset by posting an empty value to `metadata`. #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// The desired PIN for this card. - #[serde(skip_serializing_if = "Option::is_none")] - pub pin: Option<EncryptedPinParam<'a>>, /// The card this is meant to be a replacement for (if any). #[serde(skip_serializing_if = "Option::is_none")] pub replacement_for: Option<&'a str>, @@ -119,7 +92,7 @@ pub struct CreateIssuingCard<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub status: Option<CreateIssuingCardStatus>, /// The type of card to issue. Possible values are `physical` or `virtual`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_shared::IssuingCardType, } impl<'a> CreateIssuingCard<'a> { @@ -130,7 +103,6 @@ impl<'a> CreateIssuingCard<'a> { expand: None, financial_account: None, metadata: None, - pin: None, replacement_for: None, replacement_reason: None, shipping: None, @@ -160,21 +132,13 @@ pub struct CreateIssuingCardShipping<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub service: Option<CreateIssuingCardShippingService>, /// Packaging options. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CreateIssuingCardShippingType>, } impl<'a> CreateIssuingCardShipping<'a> { pub fn new(address: CreateIssuingCardShippingAddress<'a>, name: &'a str) -> Self { - Self { - address, - customs: None, - name, - phone_number: None, - require_signature: None, - service: None, - type_: None, - } + Self { address, customs: None, name, phone_number: None, require_signature: None, service: None, type_: None } } } /// The address that the card is shipped to. @@ -677,9 +641,7 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -689,9 +651,7 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -733,9 +693,7 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -745,14 +703,10 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -773,18 +727,14 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -792,12 +742,8 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -817,9 +763,7 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -832,14 +776,10 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -849,9 +789,7 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -863,9 +801,7 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -885,18 +821,14 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -910,9 +842,7 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -924,21 +854,15 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -954,13 +878,9 @@ impl CreateIssuingCardSpendingControlsAllowedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -1026,9 +946,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -1038,9 +956,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -1082,9 +998,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -1094,14 +1008,10 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -1122,20 +1032,14 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -1143,12 +1047,8 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -1168,9 +1068,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -1183,28 +1081,20 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -1216,9 +1106,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -1238,18 +1126,14 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -1263,9 +1147,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -1277,21 +1159,15 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -1307,13 +1183,9 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsAllowedCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1700,9 +1572,7 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -1712,9 +1582,7 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -1756,9 +1624,7 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -1768,14 +1634,10 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -1796,18 +1658,14 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -1815,12 +1673,8 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -1840,9 +1694,7 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -1855,14 +1707,10 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -1872,9 +1720,7 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -1886,9 +1732,7 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -1908,18 +1752,14 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -1933,9 +1773,7 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -1947,21 +1785,15 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -1977,13 +1809,9 @@ impl CreateIssuingCardSpendingControlsBlockedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -2049,9 +1877,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -2061,9 +1887,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -2105,9 +1929,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -2117,14 +1939,10 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -2145,20 +1963,14 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -2166,12 +1978,8 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -2191,9 +1999,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -2206,28 +2012,20 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -2239,9 +2037,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -2261,18 +2057,14 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -2286,9 +2078,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -2300,21 +2090,15 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -2330,13 +2114,9 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsBlockedCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -2390,10 +2170,7 @@ pub struct CreateIssuingCardSpendingControlsSpendingLimits<'a> { pub interval: CreateIssuingCardSpendingControlsSpendingLimitsInterval, } impl<'a> CreateIssuingCardSpendingControlsSpendingLimits<'a> { - pub fn new( - amount: i64, - interval: CreateIssuingCardSpendingControlsSpendingLimitsInterval, - ) -> Self { + pub fn new(amount: i64, interval: CreateIssuingCardSpendingControlsSpendingLimitsInterval) -> Self { Self { amount, categories: None, interval } } } @@ -2742,9 +2519,7 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -2754,9 +2529,7 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -2798,9 +2571,7 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -2810,14 +2581,10 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -2838,18 +2605,14 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -2857,12 +2620,8 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -2882,9 +2641,7 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -2897,14 +2654,10 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -2914,9 +2667,7 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -2928,9 +2679,7 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -2950,18 +2699,14 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -2975,9 +2720,7 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -2989,21 +2732,15 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -3019,13 +2756,9 @@ impl CreateIssuingCardSpendingControlsSpendingLimitsCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -3091,9 +2824,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -3103,9 +2834,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -3147,9 +2876,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -3159,14 +2886,10 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -3187,20 +2910,14 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -3208,12 +2925,8 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -3233,9 +2946,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -3248,28 +2959,20 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -3281,9 +2984,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -3303,18 +3004,14 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -3328,9 +3025,7 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -3342,21 +3037,15 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -3372,13 +3061,9 @@ impl std::str::FromStr for CreateIssuingCardSpendingControlsSpendingLimitsCatego "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -3532,6 +3217,23 @@ impl<'a> CreateIssuingCard<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveIssuingCard<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveIssuingCard<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveIssuingCard<'a> { + /// Retrieves an Issuing `Card` object. + pub fn send(&self, client: &stripe::Client, card: &stripe_shared::IssuingCardId) -> stripe::Response<stripe_shared::IssuingCard> { + client.get_query(&format!("/issuing/cards/{card}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateIssuingCard<'a> { /// Reason why the `status` of this card is `canceled`. #[serde(skip_serializing_if = "Option::is_none")] @@ -3547,7 +3249,7 @@ pub struct UpdateIssuingCard<'a> { pub metadata: Option<&'a std::collections::HashMap<String, String>>, /// The desired new PIN for this card. #[serde(skip_serializing_if = "Option::is_none")] - pub pin: Option<EncryptedPinParam<'a>>, + pub pin: Option<UpdateIssuingCardPin<'a>>, /// Rules that control spending for this card. /// Refer to our [documentation](https://stripe.com/docs/issuing/controls/spending-controls) for more details. #[serde(skip_serializing_if = "Option::is_none")] @@ -3610,6 +3312,18 @@ impl serde::Serialize for UpdateIssuingCardCancellationReason { serializer.serialize_str(self.as_str()) } } +/// The desired new PIN for this card. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateIssuingCardPin<'a> { + /// The card's desired new PIN, encrypted under Stripe's public key. + #[serde(skip_serializing_if = "Option::is_none")] + pub encrypted_number: Option<&'a str>, +} +impl<'a> UpdateIssuingCardPin<'a> { + pub fn new() -> Self { + Self::default() + } +} /// Rules that control spending for this card. /// Refer to our [documentation](https://stripe.com/docs/issuing/controls/spending-controls) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -3979,9 +3693,7 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -3991,9 +3703,7 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -4035,9 +3745,7 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -4047,14 +3755,10 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -4075,18 +3779,14 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -4094,12 +3794,8 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -4119,9 +3815,7 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -4134,14 +3828,10 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -4151,9 +3841,7 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -4165,9 +3853,7 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -4187,18 +3873,14 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -4212,9 +3894,7 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -4226,21 +3906,15 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -4256,13 +3930,9 @@ impl UpdateIssuingCardSpendingControlsAllowedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -4328,9 +3998,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -4340,9 +4008,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -4384,9 +4050,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -4396,14 +4060,10 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -4424,20 +4084,14 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -4445,12 +4099,8 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -4470,9 +4120,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -4485,28 +4133,20 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -4518,9 +4158,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -4540,18 +4178,14 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -4565,9 +4199,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -4579,21 +4211,15 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -4609,13 +4235,9 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsAllowedCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -5002,9 +4624,7 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -5014,9 +4634,7 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -5058,9 +4676,7 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -5070,14 +4686,10 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -5098,18 +4710,14 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -5117,12 +4725,8 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -5142,9 +4746,7 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -5157,14 +4759,10 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -5174,9 +4772,7 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -5188,9 +4784,7 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -5210,18 +4804,14 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -5235,9 +4825,7 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -5249,21 +4837,15 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -5279,13 +4861,9 @@ impl UpdateIssuingCardSpendingControlsBlockedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -5351,9 +4929,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -5363,9 +4939,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -5407,9 +4981,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -5419,14 +4991,10 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -5447,20 +5015,14 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -5468,12 +5030,8 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -5493,9 +5051,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -5508,28 +5064,20 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -5541,9 +5089,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -5563,18 +5109,14 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -5588,9 +5130,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -5602,21 +5142,15 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -5632,13 +5166,9 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsBlockedCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -5692,10 +5222,7 @@ pub struct UpdateIssuingCardSpendingControlsSpendingLimits<'a> { pub interval: UpdateIssuingCardSpendingControlsSpendingLimitsInterval, } impl<'a> UpdateIssuingCardSpendingControlsSpendingLimits<'a> { - pub fn new( - amount: i64, - interval: UpdateIssuingCardSpendingControlsSpendingLimitsInterval, - ) -> Self { + pub fn new(amount: i64, interval: UpdateIssuingCardSpendingControlsSpendingLimitsInterval) -> Self { Self { amount, categories: None, interval } } } @@ -6044,9 +5571,7 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -6056,9 +5581,7 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -6100,9 +5623,7 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -6112,14 +5633,10 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -6140,18 +5657,14 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -6159,12 +5672,8 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -6184,9 +5693,7 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -6199,14 +5706,10 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -6216,9 +5719,7 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -6230,9 +5731,7 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -6252,18 +5751,14 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -6277,9 +5772,7 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -6291,21 +5784,15 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -6321,13 +5808,9 @@ impl UpdateIssuingCardSpendingControlsSpendingLimitsCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -6393,9 +5876,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -6405,9 +5886,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -6449,9 +5928,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -6461,14 +5938,10 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -6489,20 +5962,14 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -6510,12 +5977,8 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -6535,9 +5998,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -6550,28 +6011,20 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -6583,9 +6036,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -6605,18 +6056,14 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -6630,9 +6077,7 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -6644,21 +6089,15 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -6674,13 +6113,9 @@ impl std::str::FromStr for UpdateIssuingCardSpendingControlsSpendingLimitsCatego "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -6782,11 +6217,7 @@ impl serde::Serialize for UpdateIssuingCardSpendingControlsSpendingLimitsInterva impl<'a> UpdateIssuingCard<'a> { /// Updates the specified Issuing `Card` object by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - card: &stripe_shared::IssuingCardId, - ) -> stripe::Response<stripe_shared::IssuingCard> { + pub fn send(&self, client: &stripe::Client, card: &stripe_shared::IssuingCardId) -> stripe::Response<stripe_shared::IssuingCard> { client.send_form(&format!("/issuing/cards/{card}"), self, http_types::Method::Post) } } @@ -6803,41 +6234,25 @@ impl<'a> DeliverCardIssuingCard<'a> { } impl<'a> DeliverCardIssuingCard<'a> { /// Updates the shipping status of the specified Issuing `Card` object to `delivered`. - pub fn send( - &self, - client: &stripe::Client, - card: &str, - ) -> stripe::Response<stripe_shared::IssuingCard> { - client.send_form( - &format!("/test_helpers/issuing/cards/{card}/shipping/deliver"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, card: &str) -> stripe::Response<stripe_shared::IssuingCard> { + client.send_form(&format!("/test_helpers/issuing/cards/{card}/shipping/deliver"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct FailCardIssuingCard<'a> { +pub struct ShipCardIssuingCard<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> FailCardIssuingCard<'a> { +impl<'a> ShipCardIssuingCard<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> FailCardIssuingCard<'a> { - /// Updates the shipping status of the specified Issuing `Card` object to `failure`. - pub fn send( - &self, - client: &stripe::Client, - card: &str, - ) -> stripe::Response<stripe_shared::IssuingCard> { - client.send_form( - &format!("/test_helpers/issuing/cards/{card}/shipping/fail"), - self, - http_types::Method::Post, - ) +impl<'a> ShipCardIssuingCard<'a> { + /// Updates the shipping status of the specified Issuing `Card` object to `shipped`. + pub fn send(&self, client: &stripe::Client, card: &str) -> stripe::Response<stripe_shared::IssuingCard> { + client.send_form(&format!("/test_helpers/issuing/cards/{card}/shipping/ship"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -6853,51 +6268,24 @@ impl<'a> ReturnCardIssuingCard<'a> { } impl<'a> ReturnCardIssuingCard<'a> { /// Updates the shipping status of the specified Issuing `Card` object to `returned`. - pub fn send( - &self, - client: &stripe::Client, - card: &str, - ) -> stripe::Response<stripe_shared::IssuingCard> { - client.send_form( - &format!("/test_helpers/issuing/cards/{card}/shipping/return"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, card: &str) -> stripe::Response<stripe_shared::IssuingCard> { + client.send_form(&format!("/test_helpers/issuing/cards/{card}/shipping/return"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ShipCardIssuingCard<'a> { +pub struct FailCardIssuingCard<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> ShipCardIssuingCard<'a> { +impl<'a> FailCardIssuingCard<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> ShipCardIssuingCard<'a> { - /// Updates the shipping status of the specified Issuing `Card` object to `shipped`. - pub fn send( - &self, - client: &stripe::Client, - card: &str, - ) -> stripe::Response<stripe_shared::IssuingCard> { - client.send_form( - &format!("/test_helpers/issuing/cards/{card}/shipping/ship"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct EncryptedPinParam<'a> { - /// The card's desired new PIN, encrypted under Stripe's public key. - #[serde(skip_serializing_if = "Option::is_none")] - pub encrypted_number: Option<&'a str>, -} -impl<'a> EncryptedPinParam<'a> { - pub fn new() -> Self { - Self::default() +impl<'a> FailCardIssuingCard<'a> { + /// Updates the shipping status of the specified Issuing `Card` object to `failure`. + pub fn send(&self, client: &stripe::Client, card: &str) -> stripe::Response<stripe_shared::IssuingCard> { + client.send_form(&format!("/test_helpers/issuing/cards/{card}/shipping/fail"), self, http_types::Method::Post) } } diff --git a/generated/stripe_issuing/src/issuing_cardholder/requests.rs b/generated/stripe_issuing/src/issuing_cardholder/requests.rs index fe09025bd..9dad0e144 100644 --- a/generated/stripe_issuing/src/issuing_cardholder/requests.rs +++ b/generated/stripe_issuing/src/issuing_cardholder/requests.rs @@ -30,7 +30,7 @@ pub struct ListIssuingCardholder<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub status: Option<stripe_shared::IssuingCardholderStatus>, /// Only return cardholders that have the given type. One of `individual` or `company`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_shared::IssuingCardholderType>, } @@ -42,39 +42,13 @@ impl<'a> ListIssuingCardholder<'a> { impl<'a> ListIssuingCardholder<'a> { /// Returns a list of Issuing `Cardholder` objects. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::IssuingCardholder>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::IssuingCardholder>> { client.get_query("/issuing/cardholders", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingCardholder>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingCardholder>> { stripe::ListPaginator::from_list_params("/issuing/cardholders", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveIssuingCardholder<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveIssuingCardholder<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveIssuingCardholder<'a> { - /// Retrieves an Issuing `Cardholder` object. - pub fn send( - &self, - client: &stripe::Client, - cardholder: &stripe_shared::IssuingCardholderId, - ) -> stripe::Response<stripe_shared::IssuingCardholder> { - client.get_query(&format!("/issuing/cardholders/{cardholder}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingCardholder<'a> { /// The cardholder's billing address. @@ -122,7 +96,7 @@ pub struct CreateIssuingCardholder<'a> { pub status: Option<CreateIssuingCardholderStatus>, /// One of `individual` or `company`. /// See [Choose a cardholder type](https://stripe.com/docs/issuing/other/choose-cardholder) for more details. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_shared::IssuingCardholderType>, } @@ -516,9 +490,7 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -528,9 +500,7 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -572,9 +542,7 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -584,14 +552,10 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -612,18 +576,14 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -631,12 +591,8 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -656,9 +612,7 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -671,14 +625,10 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -688,9 +638,7 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -702,9 +650,7 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -724,18 +670,14 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -749,9 +691,7 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -763,21 +703,15 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -793,13 +727,9 @@ impl CreateIssuingCardholderSpendingControlsAllowedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -865,9 +795,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -877,9 +805,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -921,9 +847,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -933,14 +857,10 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -961,20 +881,14 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -982,12 +896,8 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -1007,9 +917,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -1022,28 +930,20 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -1055,9 +955,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -1077,18 +975,14 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -1102,9 +996,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -1116,21 +1008,15 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -1146,13 +1032,9 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsAllowedCategor "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1539,9 +1421,7 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -1551,9 +1431,7 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -1595,9 +1473,7 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -1607,14 +1483,10 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -1635,18 +1507,14 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -1654,12 +1522,8 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -1679,9 +1543,7 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -1694,14 +1556,10 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -1711,9 +1569,7 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -1725,9 +1581,7 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -1747,18 +1601,14 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -1772,9 +1622,7 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -1786,21 +1634,15 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -1816,13 +1658,9 @@ impl CreateIssuingCardholderSpendingControlsBlockedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -1888,9 +1726,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -1900,9 +1736,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -1944,9 +1778,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -1956,14 +1788,10 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -1984,20 +1812,14 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -2005,12 +1827,8 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -2030,9 +1848,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -2045,28 +1861,20 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -2078,9 +1886,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -2100,18 +1906,14 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -2125,9 +1927,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -2139,21 +1939,15 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -2169,13 +1963,9 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsBlockedCategor "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -2229,10 +2019,7 @@ pub struct CreateIssuingCardholderSpendingControlsSpendingLimits<'a> { pub interval: CreateIssuingCardholderSpendingControlsSpendingLimitsInterval, } impl<'a> CreateIssuingCardholderSpendingControlsSpendingLimits<'a> { - pub fn new( - amount: i64, - interval: CreateIssuingCardholderSpendingControlsSpendingLimitsInterval, - ) -> Self { + pub fn new(amount: i64, interval: CreateIssuingCardholderSpendingControlsSpendingLimitsInterval) -> Self { Self { amount, categories: None, interval } } } @@ -2581,9 +2368,7 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -2593,9 +2378,7 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -2637,9 +2420,7 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -2649,14 +2430,10 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -2677,18 +2454,14 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -2696,12 +2469,8 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -2721,9 +2490,7 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -2736,14 +2503,10 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -2753,9 +2516,7 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -2767,9 +2528,7 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -2789,18 +2548,14 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -2814,9 +2569,7 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -2828,21 +2581,15 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -2858,13 +2605,9 @@ impl CreateIssuingCardholderSpendingControlsSpendingLimitsCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -2930,9 +2673,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -2942,9 +2683,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -2986,9 +2725,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -2998,14 +2735,10 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -3026,20 +2759,14 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -3047,12 +2774,8 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -3072,9 +2795,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -3087,28 +2808,20 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -3120,9 +2833,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -3142,18 +2853,14 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -3167,9 +2874,7 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -3181,21 +2886,15 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -3211,13 +2910,9 @@ impl std::str::FromStr for CreateIssuingCardholderSpendingControlsSpendingLimits "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -3364,14 +3059,28 @@ impl serde::Serialize for CreateIssuingCardholderStatus { } impl<'a> CreateIssuingCardholder<'a> { /// Creates a new Issuing `Cardholder` object that can be issued cards. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_shared::IssuingCardholder> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::IssuingCardholder> { client.send_form("/issuing/cardholders", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveIssuingCardholder<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveIssuingCardholder<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveIssuingCardholder<'a> { + /// Retrieves an Issuing `Cardholder` object. + pub fn send(&self, client: &stripe::Client, cardholder: &stripe_shared::IssuingCardholderId) -> stripe::Response<stripe_shared::IssuingCardholder> { + client.get_query(&format!("/issuing/cardholders/{cardholder}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateIssuingCardholder<'a> { /// The cardholder's billing address. #[serde(skip_serializing_if = "Option::is_none")] @@ -3789,9 +3498,7 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -3801,9 +3508,7 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -3845,9 +3550,7 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -3857,14 +3560,10 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -3885,18 +3584,14 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -3904,12 +3599,8 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -3929,9 +3620,7 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -3944,14 +3633,10 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -3961,9 +3646,7 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -3975,9 +3658,7 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -3997,18 +3678,14 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -4022,9 +3699,7 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -4036,21 +3711,15 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -4066,13 +3735,9 @@ impl UpdateIssuingCardholderSpendingControlsAllowedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -4138,9 +3803,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -4150,9 +3813,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -4194,9 +3855,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -4206,14 +3865,10 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -4234,20 +3889,14 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -4255,12 +3904,8 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -4280,9 +3925,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -4295,28 +3938,20 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -4328,9 +3963,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -4350,18 +3983,14 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -4375,9 +4004,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -4389,21 +4016,15 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -4419,13 +4040,9 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsAllowedCategor "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -4812,9 +4429,7 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -4824,9 +4439,7 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -4868,9 +4481,7 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -4880,14 +4491,10 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -4908,18 +4515,14 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -4927,12 +4530,8 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -4952,9 +4551,7 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -4967,14 +4564,10 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -4984,9 +4577,7 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -4998,9 +4589,7 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -5020,18 +4609,14 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -5045,9 +4630,7 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -5059,21 +4642,15 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -5089,13 +4666,9 @@ impl UpdateIssuingCardholderSpendingControlsBlockedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -5161,9 +4734,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -5173,9 +4744,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -5217,9 +4786,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -5229,14 +4796,10 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -5257,20 +4820,14 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -5278,12 +4835,8 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -5303,9 +4856,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -5318,28 +4869,20 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -5351,9 +4894,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -5373,18 +4914,14 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -5398,9 +4935,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -5412,21 +4947,15 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -5442,13 +4971,9 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsBlockedCategor "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -5502,10 +5027,7 @@ pub struct UpdateIssuingCardholderSpendingControlsSpendingLimits<'a> { pub interval: UpdateIssuingCardholderSpendingControlsSpendingLimitsInterval, } impl<'a> UpdateIssuingCardholderSpendingControlsSpendingLimits<'a> { - pub fn new( - amount: i64, - interval: UpdateIssuingCardholderSpendingControlsSpendingLimitsInterval, - ) -> Self { + pub fn new(amount: i64, interval: UpdateIssuingCardholderSpendingControlsSpendingLimitsInterval) -> Self { Self { amount, categories: None, interval } } } @@ -5854,9 +5376,7 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -5866,9 +5386,7 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -5910,9 +5428,7 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -5922,14 +5438,10 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -5950,18 +5462,14 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -5969,12 +5477,8 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -5994,9 +5498,7 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -6009,14 +5511,10 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -6026,9 +5524,7 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -6040,9 +5536,7 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -6062,18 +5556,14 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -6087,9 +5577,7 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -6101,21 +5589,15 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -6131,13 +5613,9 @@ impl UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -6203,9 +5681,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -6215,9 +5691,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -6259,9 +5733,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -6271,14 +5743,10 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -6299,20 +5767,14 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -6320,12 +5782,8 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -6345,9 +5803,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -6360,28 +5816,20 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -6393,9 +5841,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -6415,18 +5861,14 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -6440,9 +5882,7 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -6454,21 +5894,15 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -6484,13 +5918,9 @@ impl std::str::FromStr for UpdateIssuingCardholderSpendingControlsSpendingLimits "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -6638,16 +6068,8 @@ impl serde::Serialize for UpdateIssuingCardholderStatus { impl<'a> UpdateIssuingCardholder<'a> { /// Updates the specified Issuing `Cardholder` object by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - cardholder: &stripe_shared::IssuingCardholderId, - ) -> stripe::Response<stripe_shared::IssuingCardholder> { - client.send_form( - &format!("/issuing/cardholders/{cardholder}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, cardholder: &stripe_shared::IssuingCardholderId) -> stripe::Response<stripe_shared::IssuingCardholder> { + client.send_form(&format!("/issuing/cardholders/{cardholder}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -6742,8 +6164,7 @@ impl<'a> BillingSpecs<'a> { } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CardIssuingParam<'a> { - /// Information about cardholder acceptance of Celtic [Authorized User Terms](https://stripe.com/docs/issuing/cards#accept-authorized-user-terms). - /// Required for cards backed by a Celtic program. + /// Information about cardholder acceptance of [Authorized User Terms](https://stripe.com/docs/issuing/cards). #[serde(skip_serializing_if = "Option::is_none")] pub user_terms_acceptance: Option<TermsAcceptanceParam<'a>>, } diff --git a/generated/stripe_issuing/src/issuing_dispute/requests.rs b/generated/stripe_issuing/src/issuing_dispute/requests.rs index 7d993bcb9..24213978b 100644 --- a/generated/stripe_issuing/src/issuing_dispute/requests.rs +++ b/generated/stripe_issuing/src/issuing_dispute/requests.rs @@ -35,40 +35,14 @@ impl<'a> ListIssuingDispute<'a> { impl<'a> ListIssuingDispute<'a> { /// Returns a list of Issuing `Dispute` objects. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::IssuingDispute>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::IssuingDispute>> { client.get_query("/issuing/disputes", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingDispute>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingDispute>> { stripe::ListPaginator::from_list_params("/issuing/disputes", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveIssuingDispute<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveIssuingDispute<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveIssuingDispute<'a> { - /// Retrieves an Issuing `Dispute` object. - pub fn send( - &self, - client: &stripe::Client, - dispute: &stripe_shared::IssuingDisputeId, - ) -> stripe::Response<stripe_shared::IssuingDispute> { - client.get_query(&format!("/issuing/disputes/{dispute}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateIssuingDispute<'a> { /// The dispute amount in the card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// If not set, defaults to the full transaction amount. @@ -113,8 +87,7 @@ pub struct CreateIssuingDisputeEvidence<'a> { pub fraudulent: Option<Fraudulent<'a>>, /// Evidence provided when `reason` is 'merchandise_not_as_described'. #[serde(skip_serializing_if = "Option::is_none")] - pub merchandise_not_as_described: - Option<CreateIssuingDisputeEvidenceMerchandiseNotAsDescribed<'a>>, + pub merchandise_not_as_described: Option<CreateIssuingDisputeEvidenceMerchandiseNotAsDescribed<'a>>, /// Evidence provided when `reason` is 'not_received'. #[serde(skip_serializing_if = "Option::is_none")] pub not_received: Option<CreateIssuingDisputeEvidenceNotReceived<'a>>, @@ -592,8 +565,7 @@ pub struct UpdateIssuingDisputeEvidence<'a> { pub fraudulent: Option<Fraudulent<'a>>, /// Evidence provided when `reason` is 'merchandise_not_as_described'. #[serde(skip_serializing_if = "Option::is_none")] - pub merchandise_not_as_described: - Option<UpdateIssuingDisputeEvidenceMerchandiseNotAsDescribed<'a>>, + pub merchandise_not_as_described: Option<UpdateIssuingDisputeEvidenceMerchandiseNotAsDescribed<'a>>, /// Evidence provided when `reason` is 'not_received'. #[serde(skip_serializing_if = "Option::is_none")] pub not_received: Option<UpdateIssuingDisputeEvidenceNotReceived<'a>>, @@ -1018,15 +990,28 @@ impl<'a> UpdateIssuingDispute<'a> { /// Updates the specified Issuing `Dispute` object by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. /// Properties on the `evidence` object can be unset by passing in an empty string. - pub fn send( - &self, - client: &stripe::Client, - dispute: &stripe_shared::IssuingDisputeId, - ) -> stripe::Response<stripe_shared::IssuingDispute> { + pub fn send(&self, client: &stripe::Client, dispute: &stripe_shared::IssuingDisputeId) -> stripe::Response<stripe_shared::IssuingDispute> { client.send_form(&format!("/issuing/disputes/{dispute}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveIssuingDispute<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveIssuingDispute<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveIssuingDispute<'a> { + /// Retrieves an Issuing `Dispute` object. + pub fn send(&self, client: &stripe::Client, dispute: &stripe_shared::IssuingDisputeId) -> stripe::Response<stripe_shared::IssuingDispute> { + client.get_query(&format!("/issuing/disputes/{dispute}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct SubmitIssuingDispute<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -1047,16 +1032,8 @@ impl<'a> SubmitIssuingDispute<'a> { /// Submits an Issuing `Dispute` to the card network. /// Stripe validates that all evidence fields required for the dispute’s reason are present. /// For more details, see [Dispute reasons and evidence](https://stripe.com/docs/issuing/purchases/disputes#dispute-reasons-and-evidence). - pub fn send( - &self, - client: &stripe::Client, - dispute: &stripe_shared::IssuingDisputeId, - ) -> stripe::Response<stripe_shared::IssuingDispute> { - client.send_form( - &format!("/issuing/disputes/{dispute}/submit"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, dispute: &stripe_shared::IssuingDisputeId) -> stripe::Response<stripe_shared::IssuingDispute> { + client.send_form(&format!("/issuing/disputes/{dispute}/submit"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_issuing/src/issuing_token/requests.rs b/generated/stripe_issuing/src/issuing_token/requests.rs index cb01672aa..865b22434 100644 --- a/generated/stripe_issuing/src/issuing_token/requests.rs +++ b/generated/stripe_issuing/src/issuing_token/requests.rs @@ -28,28 +28,15 @@ pub struct ListIssuingToken<'a> { } impl<'a> ListIssuingToken<'a> { pub fn new(card: &'a str) -> Self { - Self { - card, - created: None, - ending_before: None, - expand: None, - limit: None, - starting_after: None, - status: None, - } + Self { card, created: None, ending_before: None, expand: None, limit: None, starting_after: None, status: None } } } impl<'a> ListIssuingToken<'a> { /// Lists all Issuing `Token` objects for a given card. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::IssuingToken>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::IssuingToken>> { client.get_query("/issuing/tokens", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingToken>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingToken>> { stripe::ListPaginator::from_list_params("/issuing/tokens", self) } } @@ -66,11 +53,7 @@ impl<'a> RetrieveIssuingToken<'a> { } impl<'a> RetrieveIssuingToken<'a> { /// Retrieves an Issuing `Token` object. - pub fn send( - &self, - client: &stripe::Client, - token: &stripe_shared::IssuingTokenId, - ) -> stripe::Response<stripe_shared::IssuingToken> { + pub fn send(&self, client: &stripe::Client, token: &stripe_shared::IssuingTokenId) -> stripe::Response<stripe_shared::IssuingToken> { client.get_query(&format!("/issuing/tokens/{token}"), self) } } @@ -138,11 +121,7 @@ impl serde::Serialize for UpdateIssuingTokenStatus { } impl<'a> UpdateIssuingToken<'a> { /// Attempts to update the specified Issuing `Token` object to the status specified. - pub fn send( - &self, - client: &stripe::Client, - token: &stripe_shared::IssuingTokenId, - ) -> stripe::Response<stripe_shared::IssuingToken> { + pub fn send(&self, client: &stripe::Client, token: &stripe_shared::IssuingTokenId) -> stripe::Response<stripe_shared::IssuingToken> { client.send_form(&format!("/issuing/tokens/{token}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_issuing/src/issuing_transaction/requests.rs b/generated/stripe_issuing/src/issuing_transaction/requests.rs index d4381d15b..cefffceda 100644 --- a/generated/stripe_issuing/src/issuing_transaction/requests.rs +++ b/generated/stripe_issuing/src/issuing_transaction/requests.rs @@ -27,7 +27,7 @@ pub struct ListIssuingTransaction<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, /// Only return transactions that have the given type. One of `capture` or `refund`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_shared::IssuingTransactionType>, } @@ -39,15 +39,10 @@ impl<'a> ListIssuingTransaction<'a> { impl<'a> ListIssuingTransaction<'a> { /// Returns a list of Issuing `Transaction` objects. /// The objects are sorted in descending order by creation date, with the most recently created object appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::IssuingTransaction>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::IssuingTransaction>> { client.get_query("/issuing/transactions", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingTransaction>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::IssuingTransaction>> { stripe::ListPaginator::from_list_params("/issuing/transactions", self) } } @@ -64,11 +59,7 @@ impl<'a> RetrieveIssuingTransaction<'a> { } impl<'a> RetrieveIssuingTransaction<'a> { /// Retrieves an Issuing `Transaction` object. - pub fn send( - &self, - client: &stripe::Client, - transaction: &stripe_shared::IssuingTransactionId, - ) -> stripe::Response<stripe_shared::IssuingTransaction> { + pub fn send(&self, client: &stripe::Client, transaction: &stripe_shared::IssuingTransactionId) -> stripe::Response<stripe_shared::IssuingTransaction> { client.get_query(&format!("/issuing/transactions/{transaction}"), self) } } @@ -92,45 +83,8 @@ impl<'a> UpdateIssuingTransaction<'a> { impl<'a> UpdateIssuingTransaction<'a> { /// Updates the specified Issuing `Transaction` object by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - transaction: &stripe_shared::IssuingTransactionId, - ) -> stripe::Response<stripe_shared::IssuingTransaction> { - client.send_form( - &format!("/issuing/transactions/{transaction}"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RefundIssuingTransaction<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// The total amount to attempt to refund. - /// This amount is in the provided currency, or defaults to the cards currency, and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). - #[serde(skip_serializing_if = "Option::is_none")] - pub refund_amount: Option<i64>, -} -impl<'a> RefundIssuingTransaction<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RefundIssuingTransaction<'a> { - /// Refund a test-mode Transaction. - pub fn send( - &self, - client: &stripe::Client, - transaction: &str, - ) -> stripe::Response<stripe_shared::IssuingTransaction> { - client.send_form( - &format!("/test_helpers/issuing/transactions/{transaction}/refund"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, transaction: &stripe_shared::IssuingTransactionId) -> stripe::Response<stripe_shared::IssuingTransaction> { + client.send_form(&format!("/issuing/transactions/{transaction}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -158,14 +112,7 @@ pub struct CreateForceCaptureIssuingTransaction<'a> { } impl<'a> CreateForceCaptureIssuingTransaction<'a> { pub fn new(amount: i64, card: &'a str) -> Self { - Self { - amount, - card, - currency: None, - expand: None, - merchant_data: None, - purchase_details: None, - } + Self { amount, card, currency: None, expand: None, merchant_data: None, purchase_details: None } } } /// Details about the seller (grocery store, e-commerce website, etc.) where the card authorization happened. @@ -550,9 +497,7 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -562,9 +507,7 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -606,9 +549,7 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -618,14 +559,10 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -646,18 +583,14 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -665,12 +598,8 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -690,9 +619,7 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -705,14 +632,10 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", MiscellaneousApparelAndAccessoryShops => "miscellaneous_apparel_and_accessory_shops", @@ -721,9 +644,7 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -735,9 +656,7 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -757,18 +676,14 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -782,9 +697,7 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -796,21 +709,15 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -826,13 +733,9 @@ impl CreateForceCaptureIssuingTransactionMerchantDataCategory { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -898,9 +801,7 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -910,9 +811,7 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -954,9 +853,7 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -966,14 +863,10 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -994,20 +887,14 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -1015,12 +902,8 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -1040,9 +923,7 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -1055,27 +936,19 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -1087,9 +960,7 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -1109,18 +980,14 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -1134,9 +1001,7 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -1148,21 +1013,15 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -1178,13 +1037,9 @@ impl std::str::FromStr for CreateForceCaptureIssuingTransactionMerchantDataCateg "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1254,7 +1109,7 @@ impl<'a> CreateForceCaptureIssuingTransactionPurchaseDetails<'a> { pub struct CreateForceCaptureIssuingTransactionPurchaseDetailsFuel<'a> { /// The type of fuel that was purchased. /// One of `diesel`, `unleaded_plus`, `unleaded_regular`, `unleaded_super`, or `other`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CreateForceCaptureIssuingTransactionPurchaseDetailsFuelType>, /// The units for `volume_decimal`. One of `us_gallon` or `liter`. @@ -1376,15 +1231,8 @@ impl serde::Serialize for CreateForceCaptureIssuingTransactionPurchaseDetailsFue } impl<'a> CreateForceCaptureIssuingTransaction<'a> { /// Allows the user to capture an arbitrary amount, also known as a forced capture. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_shared::IssuingTransaction> { - client.send_form( - "/test_helpers/issuing/transactions/create_force_capture", - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::IssuingTransaction> { + client.send_form("/test_helpers/issuing/transactions/create_force_capture", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -1412,14 +1260,7 @@ pub struct CreateUnlinkedRefundIssuingTransaction<'a> { } impl<'a> CreateUnlinkedRefundIssuingTransaction<'a> { pub fn new(amount: i64, card: &'a str) -> Self { - Self { - amount, - card, - currency: None, - expand: None, - merchant_data: None, - purchase_details: None, - } + Self { amount, card, currency: None, expand: None, merchant_data: None, purchase_details: None } } } /// Details about the seller (grocery store, e-commerce website, etc.) where the card authorization happened. @@ -1804,9 +1645,7 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -1816,9 +1655,7 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -1860,9 +1697,7 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -1872,14 +1707,10 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -1900,18 +1731,14 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -1919,12 +1746,8 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -1944,9 +1767,7 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -1959,14 +1780,10 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", MiscellaneousApparelAndAccessoryShops => "miscellaneous_apparel_and_accessory_shops", @@ -1975,9 +1792,7 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -1989,9 +1804,7 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -2011,18 +1824,14 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -2036,9 +1845,7 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -2050,21 +1857,15 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -2080,13 +1881,9 @@ impl CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -2152,9 +1949,7 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -2164,9 +1959,7 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -2208,9 +2001,7 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -2220,14 +2011,10 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -2248,20 +2035,14 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -2269,12 +2050,8 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -2294,9 +2071,7 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -2309,27 +2084,19 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -2341,9 +2108,7 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -2363,18 +2128,14 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -2388,9 +2149,7 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -2402,21 +2161,15 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -2432,13 +2185,9 @@ impl std::str::FromStr for CreateUnlinkedRefundIssuingTransactionMerchantDataCat "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -2508,7 +2257,7 @@ impl<'a> CreateUnlinkedRefundIssuingTransactionPurchaseDetails<'a> { pub struct CreateUnlinkedRefundIssuingTransactionPurchaseDetailsFuel<'a> { /// The type of fuel that was purchased. /// One of `diesel`, `unleaded_plus`, `unleaded_regular`, `unleaded_super`, or `other`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CreateUnlinkedRefundIssuingTransactionPurchaseDetailsFuelType>, /// The units for `volume_decimal`. One of `us_gallon` or `liter`. @@ -2630,15 +2379,29 @@ impl serde::Serialize for CreateUnlinkedRefundIssuingTransactionPurchaseDetailsF } impl<'a> CreateUnlinkedRefundIssuingTransaction<'a> { /// Allows the user to refund an arbitrary amount, also known as a unlinked refund. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_shared::IssuingTransaction> { - client.send_form( - "/test_helpers/issuing/transactions/create_unlinked_refund", - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_shared::IssuingTransaction> { + client.send_form("/test_helpers/issuing/transactions/create_unlinked_refund", self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RefundIssuingTransaction<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// The total amount to attempt to refund. + /// This amount is in the provided currency, or defaults to the cards currency, and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + #[serde(skip_serializing_if = "Option::is_none")] + pub refund_amount: Option<i64>, +} +impl<'a> RefundIssuingTransaction<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RefundIssuingTransaction<'a> { + /// Refund a test-mode Transaction. + pub fn send(&self, client: &stripe::Client, transaction: &str) -> stripe::Response<stripe_shared::IssuingTransaction> { + client.send_form(&format!("/test_helpers/issuing/transactions/{transaction}/refund"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_issuing/src/mod.rs b/generated/stripe_issuing/src/mod.rs index 4d3172cd4..04459293a 100644 --- a/generated/stripe_issuing/src/mod.rs +++ b/generated/stripe_issuing/src/mod.rs @@ -7,6 +7,9 @@ //! for requests mentioned in the `Issuing` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_issuing; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub use stripe_shared::funding_instructions::*; pub use stripe_shared::funding_instructions_bank_transfer::*; pub use stripe_shared::funding_instructions_bank_transfer_aba_record::*; diff --git a/generated/stripe_misc/.rustfmt.toml b/generated/stripe_misc/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_misc/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_misc/Cargo.toml b/generated/stripe_misc/Cargo.toml index 6d58514f3..8b4853e4e 100644 --- a/generated/stripe_misc/Cargo.toml +++ b/generated/stripe_misc/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] @@ -37,14 +39,10 @@ runtime-blocking-rustls-webpki = ["async-stripe/runtime-blocking-rustls-webpki"] runtime-async-std-surf = ["async-stripe/runtime-async-std-surf"] apple_pay_domain = [] -climate_order = [] -climate_product = [] -climate_supplier = [] ephemeral_key = [] exchange_rate = [] financial_connections_account = [] financial_connections_session = [] -financial_connections_transaction = [] identity_verification_report = [] identity_verification_session = [] reporting_report_run = [] @@ -57,14 +55,10 @@ tax_transaction = [] webhook_endpoint = [] full = ["apple_pay_domain", -"climate_order", -"climate_product", -"climate_supplier", "ephemeral_key", "exchange_rate", "financial_connections_account", "financial_connections_session", -"financial_connections_transaction", "identity_verification_report", "identity_verification_session", "reporting_report_run", diff --git a/generated/stripe_misc/src/apple_pay_domain/requests.rs b/generated/stripe_misc/src/apple_pay_domain/requests.rs index 7c2460d5f..58043c1ce 100644 --- a/generated/stripe_misc/src/apple_pay_domain/requests.rs +++ b/generated/stripe_misc/src/apple_pay_domain/requests.rs @@ -1,21 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteApplePayDomain {} -impl DeleteApplePayDomain { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteApplePayDomain { - /// Delete an apple pay domain. - pub fn send( - &self, - client: &stripe::Client, - domain: &str, - ) -> stripe::Response<stripe_misc::DeletedApplePayDomain> { - client.send_form(&format!("/apple_pay/domains/{domain}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListApplePayDomain<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub domain_name: Option<&'a str>, @@ -44,18 +27,31 @@ impl<'a> ListApplePayDomain<'a> { } impl<'a> ListApplePayDomain<'a> { /// List apple pay domains. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ApplePayDomain>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::ApplePayDomain>> { client.get_query("/apple_pay/domains", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ApplePayDomain>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ApplePayDomain>> { stripe::ListPaginator::from_list_params("/apple_pay/domains", self) } } +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct CreateApplePayDomain<'a> { + pub domain_name: &'a str, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> CreateApplePayDomain<'a> { + pub fn new(domain_name: &'a str) -> Self { + Self { domain_name, expand: None } + } +} +impl<'a> CreateApplePayDomain<'a> { + /// Create an apple pay domain. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::ApplePayDomain> { + client.send_form("/apple_pay/domains", self, http_types::Method::Post) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveApplePayDomain<'a> { /// Specifies which fields in the response should be expanded. @@ -69,29 +65,20 @@ impl<'a> RetrieveApplePayDomain<'a> { } impl<'a> RetrieveApplePayDomain<'a> { /// Retrieve an apple pay domain. - pub fn send( - &self, - client: &stripe::Client, - domain: &str, - ) -> stripe::Response<stripe_misc::ApplePayDomain> { + pub fn send(&self, client: &stripe::Client, domain: &str) -> stripe::Response<stripe_misc::ApplePayDomain> { client.get_query(&format!("/apple_pay/domains/{domain}"), self) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateApplePayDomain<'a> { - pub domain_name: &'a str, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CreateApplePayDomain<'a> { - pub fn new(domain_name: &'a str) -> Self { - Self { domain_name, expand: None } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteApplePayDomain {} +impl DeleteApplePayDomain { + pub fn new() -> Self { + Self::default() } } -impl<'a> CreateApplePayDomain<'a> { - /// Create an apple pay domain. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::ApplePayDomain> { - client.send_form("/apple_pay/domains", self, http_types::Method::Post) +impl DeleteApplePayDomain { + /// Delete an apple pay domain. + pub fn send(&self, client: &stripe::Client, domain: &str) -> stripe::Response<stripe_misc::DeletedApplePayDomain> { + client.send_form(&format!("/apple_pay/domains/{domain}"), self, http_types::Method::Delete) } } diff --git a/generated/stripe_misc/src/apple_pay_domain/types.rs b/generated/stripe_misc/src/apple_pay_domain/types.rs index d7f2f4fab..9f3b22847 100644 --- a/generated/stripe_misc/src/apple_pay_domain/types.rs +++ b/generated/stripe_misc/src/apple_pay_domain/types.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ApplePayDomain { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -8,6 +10,104 @@ pub struct ApplePayDomain { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, } +#[cfg(feature = "min-ser")] +pub struct ApplePayDomainBuilder { + created: Option<stripe_types::Timestamp>, + domain_name: Option<String>, + id: Option<stripe_misc::ApplePayDomainId>, + livemode: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ApplePayDomain { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ApplePayDomain>, + builder: ApplePayDomainBuilder, + } + + impl Visitor for Place<ApplePayDomain> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ApplePayDomainBuilder::deser_default() })) + } + } + + impl MapBuilder for ApplePayDomainBuilder { + type Out = ApplePayDomain; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "domain_name" => Deserialize::begin(&mut self.domain_name), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { created: Deserialize::default(), domain_name: Deserialize::default(), id: Deserialize::default(), livemode: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let domain_name = self.domain_name.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + + Some(Self::Out { created, domain_name, id, livemode }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ApplePayDomain { + type Builder = ApplePayDomainBuilder; + } + + impl FromValueOpt for ApplePayDomain { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ApplePayDomainBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "domain_name" => b.domain_name = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ApplePayDomain { type Id = stripe_misc::ApplePayDomainId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/bank_connections_resource_accountholder.rs b/generated/stripe_misc/src/bank_connections_resource_accountholder.rs index c66ab8910..c4af0fbcb 100644 --- a/generated/stripe_misc/src/bank_connections_resource_accountholder.rs +++ b/generated/stripe_misc/src/bank_connections_resource_accountholder.rs @@ -1,17 +1,111 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankConnectionsResourceAccountholder { /// The ID of the Stripe account this account belongs to. /// Should only be present if `account_holder.type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option<stripe_types::Expandable<stripe_shared::Account>>, /// ID of the Stripe customer this account belongs to. /// Present if and only if `account_holder.type` is `customer`. - #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, /// Type of account holder that this account belongs to. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: BankConnectionsResourceAccountholderType, } +#[cfg(feature = "min-ser")] +pub struct BankConnectionsResourceAccountholderBuilder { + account: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + type_: Option<BankConnectionsResourceAccountholderType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceAccountholder { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankConnectionsResourceAccountholder>, + builder: BankConnectionsResourceAccountholderBuilder, + } + + impl Visitor for Place<BankConnectionsResourceAccountholder> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankConnectionsResourceAccountholderBuilder::deser_default() })) + } + } + + impl MapBuilder for BankConnectionsResourceAccountholderBuilder { + type Out = BankConnectionsResourceAccountholder; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "customer" => Deserialize::begin(&mut self.customer), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account: Deserialize::default(), customer: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let customer = self.customer.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { account, customer, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankConnectionsResourceAccountholder { + type Builder = BankConnectionsResourceAccountholderBuilder; + } + + impl FromValueOpt for BankConnectionsResourceAccountholder { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceAccountholderBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of account holder that this account belongs to. #[derive(Copy, Clone, Eq, PartialEq)] pub enum BankConnectionsResourceAccountholderType { @@ -62,8 +156,24 @@ impl<'de> serde::Deserialize<'de> for BankConnectionsResourceAccountholderType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for BankConnectionsResourceAccountholderType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for BankConnectionsResourceAccountholderType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for BankConnectionsResourceAccountholderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<BankConnectionsResourceAccountholderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BankConnectionsResourceAccountholderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceAccountholderType); diff --git a/generated/stripe_misc/src/bank_connections_resource_balance.rs b/generated/stripe_misc/src/bank_connections_resource_balance.rs index b7c084010..27d1854d6 100644 --- a/generated/stripe_misc/src/bank_connections_resource_balance.rs +++ b/generated/stripe_misc/src/bank_connections_resource_balance.rs @@ -1,11 +1,11 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankConnectionsResourceBalance { /// The time that the external institution calculated this balance. /// Measured in seconds since the Unix epoch. pub as_of: stripe_types::Timestamp, - #[serde(skip_serializing_if = "Option::is_none")] pub cash: Option<stripe_misc::BankConnectionsResourceBalanceApiResourceCashBalance>, - #[serde(skip_serializing_if = "Option::is_none")] pub credit: Option<stripe_misc::BankConnectionsResourceBalanceApiResourceCreditBalance>, /// The balances owed to (or by) the account holder. /// @@ -17,9 +17,111 @@ pub struct BankConnectionsResourceBalance { pub current: std::collections::HashMap<String, i64>, /// The `type` of the balance. /// An additional hash is included on the balance with a name matching this value. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: BankConnectionsResourceBalanceType, } +#[cfg(feature = "min-ser")] +pub struct BankConnectionsResourceBalanceBuilder { + as_of: Option<stripe_types::Timestamp>, + cash: Option<Option<stripe_misc::BankConnectionsResourceBalanceApiResourceCashBalance>>, + credit: Option<Option<stripe_misc::BankConnectionsResourceBalanceApiResourceCreditBalance>>, + current: Option<std::collections::HashMap<String, i64>>, + type_: Option<BankConnectionsResourceBalanceType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankConnectionsResourceBalance>, + builder: BankConnectionsResourceBalanceBuilder, + } + + impl Visitor for Place<BankConnectionsResourceBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankConnectionsResourceBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for BankConnectionsResourceBalanceBuilder { + type Out = BankConnectionsResourceBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "as_of" => Deserialize::begin(&mut self.as_of), + "cash" => Deserialize::begin(&mut self.cash), + "credit" => Deserialize::begin(&mut self.credit), + "current" => Deserialize::begin(&mut self.current), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { as_of: Deserialize::default(), cash: Deserialize::default(), credit: Deserialize::default(), current: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let as_of = self.as_of.take()?; + let cash = self.cash.take()?; + let credit = self.credit.take()?; + let current = self.current.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { as_of, cash, credit, current, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankConnectionsResourceBalance { + type Builder = BankConnectionsResourceBalanceBuilder; + } + + impl FromValueOpt for BankConnectionsResourceBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "as_of" => b.as_of = Some(FromValueOpt::from_value(v)?), + "cash" => b.cash = Some(FromValueOpt::from_value(v)?), + "credit" => b.credit = Some(FromValueOpt::from_value(v)?), + "current" => b.current = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The `type` of the balance. /// An additional hash is included on the balance with a name matching this value. #[derive(Copy, Clone, Eq, PartialEq)] @@ -71,8 +173,24 @@ impl<'de> serde::Deserialize<'de> for BankConnectionsResourceBalanceType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for BankConnectionsResourceBalanceType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for BankConnectionsResourceBalanceType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for BankConnectionsResourceBalanceType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<BankConnectionsResourceBalanceType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BankConnectionsResourceBalanceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceBalanceType); diff --git a/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_cash_balance.rs b/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_cash_balance.rs index b7d15dbe1..b5626cdba 100644 --- a/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_cash_balance.rs +++ b/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_cash_balance.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankConnectionsResourceBalanceApiResourceCashBalance { /// The funds available to the account holder. Typically this is the current balance less any holds. /// @@ -9,3 +11,89 @@ pub struct BankConnectionsResourceBalanceApiResourceCashBalance { /// A negative amount indicates money owed by the account holder. pub available: Option<std::collections::HashMap<String, i64>>, } +#[cfg(feature = "min-ser")] +pub struct BankConnectionsResourceBalanceApiResourceCashBalanceBuilder { + available: Option<Option<std::collections::HashMap<String, i64>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceBalanceApiResourceCashBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankConnectionsResourceBalanceApiResourceCashBalance>, + builder: BankConnectionsResourceBalanceApiResourceCashBalanceBuilder, + } + + impl Visitor for Place<BankConnectionsResourceBalanceApiResourceCashBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankConnectionsResourceBalanceApiResourceCashBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for BankConnectionsResourceBalanceApiResourceCashBalanceBuilder { + type Out = BankConnectionsResourceBalanceApiResourceCashBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available" => Deserialize::begin(&mut self.available), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available = self.available.take()?; + + Some(Self::Out { available }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankConnectionsResourceBalanceApiResourceCashBalance { + type Builder = BankConnectionsResourceBalanceApiResourceCashBalanceBuilder; + } + + impl FromValueOpt for BankConnectionsResourceBalanceApiResourceCashBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceBalanceApiResourceCashBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available" => b.available = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_credit_balance.rs b/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_credit_balance.rs index e021be313..56a568e2f 100644 --- a/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_credit_balance.rs +++ b/generated/stripe_misc/src/bank_connections_resource_balance_api_resource_credit_balance.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankConnectionsResourceBalanceApiResourceCreditBalance { /// The credit that has been used by the account holder. /// @@ -9,3 +11,89 @@ pub struct BankConnectionsResourceBalanceApiResourceCreditBalance { /// A negative amount indicates money owed by the account holder. pub used: Option<std::collections::HashMap<String, i64>>, } +#[cfg(feature = "min-ser")] +pub struct BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder { + used: Option<Option<std::collections::HashMap<String, i64>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceBalanceApiResourceCreditBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankConnectionsResourceBalanceApiResourceCreditBalance>, + builder: BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder, + } + + impl Visitor for Place<BankConnectionsResourceBalanceApiResourceCreditBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder { + type Out = BankConnectionsResourceBalanceApiResourceCreditBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "used" => Deserialize::begin(&mut self.used), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { used: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let used = self.used.take()?; + + Some(Self::Out { used }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankConnectionsResourceBalanceApiResourceCreditBalance { + type Builder = BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder; + } + + impl FromValueOpt for BankConnectionsResourceBalanceApiResourceCreditBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "used" => b.used = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/bank_connections_resource_balance_refresh.rs b/generated/stripe_misc/src/bank_connections_resource_balance_refresh.rs index e745207aa..c5649280f 100644 --- a/generated/stripe_misc/src/bank_connections_resource_balance_refresh.rs +++ b/generated/stripe_misc/src/bank_connections_resource_balance_refresh.rs @@ -1,14 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankConnectionsResourceBalanceRefresh { /// The time at which the last refresh attempt was initiated. Measured in seconds since the Unix epoch. pub last_attempted_at: stripe_types::Timestamp, - /// Time at which the next balance refresh can be initiated. - /// This value will be `null` when `status` is `pending`. - /// Measured in seconds since the Unix epoch. - pub next_refresh_available_at: Option<stripe_types::Timestamp>, /// The status of the last refresh attempt. pub status: BankConnectionsResourceBalanceRefreshStatus, } +#[cfg(feature = "min-ser")] +pub struct BankConnectionsResourceBalanceRefreshBuilder { + last_attempted_at: Option<stripe_types::Timestamp>, + status: Option<BankConnectionsResourceBalanceRefreshStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceBalanceRefresh { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankConnectionsResourceBalanceRefresh>, + builder: BankConnectionsResourceBalanceRefreshBuilder, + } + + impl Visitor for Place<BankConnectionsResourceBalanceRefresh> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankConnectionsResourceBalanceRefreshBuilder::deser_default() })) + } + } + + impl MapBuilder for BankConnectionsResourceBalanceRefreshBuilder { + type Out = BankConnectionsResourceBalanceRefresh; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "last_attempted_at" => Deserialize::begin(&mut self.last_attempted_at), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { last_attempted_at: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let last_attempted_at = self.last_attempted_at.take()?; + let status = self.status.take()?; + + Some(Self::Out { last_attempted_at, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankConnectionsResourceBalanceRefresh { + type Builder = BankConnectionsResourceBalanceRefreshBuilder; + } + + impl FromValueOpt for BankConnectionsResourceBalanceRefresh { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceBalanceRefreshBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "last_attempted_at" => b.last_attempted_at = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the last refresh attempt. #[derive(Copy, Clone, Eq, PartialEq)] pub enum BankConnectionsResourceBalanceRefreshStatus { @@ -62,10 +150,24 @@ impl<'de> serde::Deserialize<'de> for BankConnectionsResourceBalanceRefreshStatu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for BankConnectionsResourceBalanceRefreshStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for BankConnectionsResourceBalanceRefreshStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for BankConnectionsResourceBalanceRefreshStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<BankConnectionsResourceBalanceRefreshStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BankConnectionsResourceBalanceRefreshStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceBalanceRefreshStatus); diff --git a/generated/stripe_misc/src/bank_connections_resource_link_account_session_filters.rs b/generated/stripe_misc/src/bank_connections_resource_link_account_session_filters.rs index 6e0c82fac..e465d1293 100644 --- a/generated/stripe_misc/src/bank_connections_resource_link_account_session_filters.rs +++ b/generated/stripe_misc/src/bank_connections_resource_link_account_session_filters.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankConnectionsResourceLinkAccountSessionFilters { /// List of countries from which to filter accounts. pub countries: Option<Vec<String>>, } +#[cfg(feature = "min-ser")] +pub struct BankConnectionsResourceLinkAccountSessionFiltersBuilder { + countries: Option<Option<Vec<String>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceLinkAccountSessionFilters { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankConnectionsResourceLinkAccountSessionFilters>, + builder: BankConnectionsResourceLinkAccountSessionFiltersBuilder, + } + + impl Visitor for Place<BankConnectionsResourceLinkAccountSessionFilters> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankConnectionsResourceLinkAccountSessionFiltersBuilder::deser_default() })) + } + } + + impl MapBuilder for BankConnectionsResourceLinkAccountSessionFiltersBuilder { + type Out = BankConnectionsResourceLinkAccountSessionFilters; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "countries" => Deserialize::begin(&mut self.countries), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { countries: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let countries = self.countries.take()?; + + Some(Self::Out { countries }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankConnectionsResourceLinkAccountSessionFilters { + type Builder = BankConnectionsResourceLinkAccountSessionFiltersBuilder; + } + + impl FromValueOpt for BankConnectionsResourceLinkAccountSessionFilters { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceLinkAccountSessionFiltersBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "countries" => b.countries = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/bank_connections_resource_ownership_refresh.rs b/generated/stripe_misc/src/bank_connections_resource_ownership_refresh.rs index 65566c6ca..fa50c8a08 100644 --- a/generated/stripe_misc/src/bank_connections_resource_ownership_refresh.rs +++ b/generated/stripe_misc/src/bank_connections_resource_ownership_refresh.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankConnectionsResourceOwnershipRefresh { /// The time at which the last refresh attempt was initiated. Measured in seconds since the Unix epoch. pub last_attempted_at: stripe_types::Timestamp, /// The status of the last refresh attempt. pub status: BankConnectionsResourceOwnershipRefreshStatus, } +#[cfg(feature = "min-ser")] +pub struct BankConnectionsResourceOwnershipRefreshBuilder { + last_attempted_at: Option<stripe_types::Timestamp>, + status: Option<BankConnectionsResourceOwnershipRefreshStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceOwnershipRefresh { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankConnectionsResourceOwnershipRefresh>, + builder: BankConnectionsResourceOwnershipRefreshBuilder, + } + + impl Visitor for Place<BankConnectionsResourceOwnershipRefresh> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankConnectionsResourceOwnershipRefreshBuilder::deser_default() })) + } + } + + impl MapBuilder for BankConnectionsResourceOwnershipRefreshBuilder { + type Out = BankConnectionsResourceOwnershipRefresh; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "last_attempted_at" => Deserialize::begin(&mut self.last_attempted_at), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { last_attempted_at: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let last_attempted_at = self.last_attempted_at.take()?; + let status = self.status.take()?; + + Some(Self::Out { last_attempted_at, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankConnectionsResourceOwnershipRefresh { + type Builder = BankConnectionsResourceOwnershipRefreshBuilder; + } + + impl FromValueOpt for BankConnectionsResourceOwnershipRefresh { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceOwnershipRefreshBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "last_attempted_at" => b.last_attempted_at = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the last refresh attempt. #[derive(Copy, Clone, Eq, PartialEq)] pub enum BankConnectionsResourceOwnershipRefreshStatus { @@ -58,10 +150,24 @@ impl<'de> serde::Deserialize<'de> for BankConnectionsResourceOwnershipRefreshSta fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for BankConnectionsResourceOwnershipRefreshStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for BankConnectionsResourceOwnershipRefreshStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for BankConnectionsResourceOwnershipRefreshStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<BankConnectionsResourceOwnershipRefreshStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BankConnectionsResourceOwnershipRefreshStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceOwnershipRefreshStatus); diff --git a/generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs b/generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs deleted file mode 100644 index f42f5591a..000000000 --- a/generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs +++ /dev/null @@ -1,80 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct BankConnectionsResourceTransactionRefresh { - /// Unique identifier for the object. - pub id: stripe_misc::BankConnectionsResourceTransactionRefreshId, - /// The time at which the last refresh attempt was initiated. Measured in seconds since the Unix epoch. - pub last_attempted_at: stripe_types::Timestamp, - /// Time at which the next transaction refresh can be initiated. - /// This value will be `null` when `status` is `pending`. - /// Measured in seconds since the Unix epoch. - pub next_refresh_available_at: Option<stripe_types::Timestamp>, - /// The status of the last refresh attempt. - pub status: BankConnectionsResourceTransactionRefreshStatus, -} -/// The status of the last refresh attempt. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum BankConnectionsResourceTransactionRefreshStatus { - Failed, - Pending, - Succeeded, -} -impl BankConnectionsResourceTransactionRefreshStatus { - pub fn as_str(self) -> &'static str { - use BankConnectionsResourceTransactionRefreshStatus::*; - match self { - Failed => "failed", - Pending => "pending", - Succeeded => "succeeded", - } - } -} - -impl std::str::FromStr for BankConnectionsResourceTransactionRefreshStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use BankConnectionsResourceTransactionRefreshStatus::*; - match s { - "failed" => Ok(Failed), - "pending" => Ok(Pending), - "succeeded" => Ok(Succeeded), - _ => Err(()), - } - } -} -impl std::fmt::Display for BankConnectionsResourceTransactionRefreshStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for BankConnectionsResourceTransactionRefreshStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for BankConnectionsResourceTransactionRefreshStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for BankConnectionsResourceTransactionRefreshStatus { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for BankConnectionsResourceTransactionRefreshStatus", - ) - }) - } -} -impl stripe_types::Object for BankConnectionsResourceTransactionRefresh { - type Id = stripe_misc::BankConnectionsResourceTransactionRefreshId; - fn id(&self) -> &Self::Id { - &self.id - } -} -stripe_types::def_id!(BankConnectionsResourceTransactionRefreshId); diff --git a/generated/stripe_misc/src/bank_connections_resource_transaction_resource_status_transitions.rs b/generated/stripe_misc/src/bank_connections_resource_transaction_resource_status_transitions.rs deleted file mode 100644 index cfbe46044..000000000 --- a/generated/stripe_misc/src/bank_connections_resource_transaction_resource_status_transitions.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct BankConnectionsResourceTransactionResourceStatusTransitions { - /// Time at which this transaction posted. Measured in seconds since the Unix epoch. - pub posted_at: Option<stripe_types::Timestamp>, - /// Time at which this transaction was voided. Measured in seconds since the Unix epoch. - pub void_at: Option<stripe_types::Timestamp>, -} diff --git a/generated/stripe_misc/src/climate_order/mod.rs b/generated/stripe_misc/src/climate_order/mod.rs deleted file mode 100644 index 0c0680d82..000000000 --- a/generated/stripe_misc/src/climate_order/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "climate_order")] -mod requests; -pub(crate) mod types; -#[cfg(feature = "climate_order")] -pub use requests::*; diff --git a/generated/stripe_misc/src/climate_order/requests.rs b/generated/stripe_misc/src/climate_order/requests.rs deleted file mode 100644 index 7487dc31f..000000000 --- a/generated/stripe_misc/src/climate_order/requests.rs +++ /dev/null @@ -1,173 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListClimateOrder<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListClimateOrder<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListClimateOrder<'a> { - /// Lists all Climate order objects. The orders are returned sorted by creation date, with the - /// most recently created orders appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ClimateOrder>> { - client.get_query("/climate/orders", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ClimateOrder>> { - stripe::ListPaginator::from_list_params("/climate/orders", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveClimateOrder<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveClimateOrder<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveClimateOrder<'a> { - /// Retrieves the details of a Climate order object with the given ID. - pub fn send( - &self, - client: &stripe::Client, - order: &stripe_misc::ClimateOrderId, - ) -> stripe::Response<stripe_misc::ClimateOrder> { - client.get_query(&format!("/climate/orders/{order}"), self) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateClimateOrder<'a> { - /// Requested amount of carbon removal units. Either this or `metric_tons` must be specified. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option<i64>, - /// Publicly sharable reference for the end beneficiary of carbon removal. - /// Assumed to be the Stripe account if not set. - #[serde(skip_serializing_if = "Option::is_none")] - pub beneficiary: Option<BeneficiaryParams<'a>>, - /// Request currency for the order as a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a supported [settlement currency for your account](https://stripe.com/docs/currencies). - /// If omitted, the account's default currency will be used. - #[serde(skip_serializing_if = "Option::is_none")] - pub currency: Option<stripe_types::Currency>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Requested number of tons for the order. Either this or `amount` must be specified. - #[serde(skip_serializing_if = "Option::is_none")] - pub metric_tons: Option<&'a str>, - /// Unique identifier of the Climate product. - pub product: &'a str, -} -impl<'a> CreateClimateOrder<'a> { - pub fn new(product: &'a str) -> Self { - Self { - amount: None, - beneficiary: None, - currency: None, - expand: None, - metadata: None, - metric_tons: None, - product, - } - } -} -impl<'a> CreateClimateOrder<'a> { - /// Creates a Climate order object for a given Climate product. The order will be processed immediately - /// after creation and payment will be deducted your Stripe balance. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::ClimateOrder> { - client.send_form("/climate/orders", self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateClimateOrder<'a> { - /// Publicly sharable reference for the end beneficiary of carbon removal. - /// Assumed to be the Stripe account if not set. - #[serde(skip_serializing_if = "Option::is_none")] - pub beneficiary: Option<BeneficiaryParams<'a>>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, -} -impl<'a> UpdateClimateOrder<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> UpdateClimateOrder<'a> { - /// Updates the specified order by setting the values of the parameters passed. - pub fn send( - &self, - client: &stripe::Client, - order: &stripe_misc::ClimateOrderId, - ) -> stripe::Response<stripe_misc::ClimateOrder> { - client.send_form(&format!("/climate/orders/{order}"), self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelClimateOrder<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CancelClimateOrder<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CancelClimateOrder<'a> { - /// Cancels a Climate order. You can cancel an order within 30 days of creation. Stripe refunds the - /// reservation `amount_subtotal`, but not the `amount_fees` for user-triggered cancellations. Frontier - /// might cancel reservations if suppliers fail to deliver. If Frontier cancels the reservation, Stripe - /// provides 90 days advance notice and refunds the `amount_total`. - pub fn send( - &self, - client: &stripe::Client, - order: &stripe_misc::ClimateOrderId, - ) -> stripe::Response<stripe_misc::ClimateOrder> { - client.send_form(&format!("/climate/orders/{order}/cancel"), self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct BeneficiaryParams<'a> { - /// Publicly displayable name for the end beneficiary of carbon removal. - pub public_name: &'a str, -} -impl<'a> BeneficiaryParams<'a> { - pub fn new(public_name: &'a str) -> Self { - Self { public_name } - } -} diff --git a/generated/stripe_misc/src/climate_order/types.rs b/generated/stripe_misc/src/climate_order/types.rs deleted file mode 100644 index bf65955ee..000000000 --- a/generated/stripe_misc/src/climate_order/types.rs +++ /dev/null @@ -1,179 +0,0 @@ -/// Orders represent your intent to purchase a particular Climate product. -/// When you create an order, the. -/// payment is deducted from your merchant balance. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClimateOrder { - /// Total amount of [Frontier](https://frontierclimate.com/)'s service fees in the currency's smallest unit. - pub amount_fees: i64, - /// Total amount of the carbon removal in the currency's smallest unit. - pub amount_subtotal: i64, - /// Total amount of the order including fees in the currency's smallest unit. - pub amount_total: i64, - #[serde(skip_serializing_if = "Option::is_none")] - pub beneficiary: Option<stripe_misc::ClimateRemovalsBeneficiary>, - /// Time at which the order was canceled. Measured in seconds since the Unix epoch. - pub canceled_at: Option<stripe_types::Timestamp>, - /// Reason for the cancellation of this order. - pub cancellation_reason: Option<ClimateOrderCancellationReason>, - /// For delivered orders, a URL to a delivery certificate for the order. - pub certificate: Option<String>, - /// Time at which the order was confirmed. Measured in seconds since the Unix epoch. - pub confirmed_at: Option<stripe_types::Timestamp>, - /// Time at which the object was created. Measured in seconds since the Unix epoch. - pub created: stripe_types::Timestamp, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase, representing the currency for this order. - pub currency: stripe_types::Currency, - /// Time at which the order's expected_delivery_year was delayed. - /// Measured in seconds since the Unix epoch. - pub delayed_at: Option<stripe_types::Timestamp>, - /// Time at which the order was delivered. Measured in seconds since the Unix epoch. - pub delivered_at: Option<stripe_types::Timestamp>, - /// Details about the delivery of carbon removal for this order. - pub delivery_details: Vec<stripe_misc::ClimateRemovalsOrderDeliveries>, - /// The year this order is expected to be delivered. - pub expected_delivery_year: i64, - /// Unique identifier for the object. - pub id: stripe_misc::ClimateOrderId, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - pub livemode: bool, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - pub metadata: std::collections::HashMap<String, String>, - /// Quantity of carbon removal that is included in this order. - pub metric_tons: String, - /// Unique ID for the Climate `Product` this order is purchasing. - pub product: stripe_types::Expandable<stripe_misc::ClimateProduct>, - /// Time at which the order's product was substituted for a different product. - /// Measured in seconds since the Unix epoch. - pub product_substituted_at: Option<stripe_types::Timestamp>, - /// The current status of this order. - pub status: ClimateOrderStatus, -} -/// Reason for the cancellation of this order. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ClimateOrderCancellationReason { - Expired, - ProductUnavailable, - Requested, -} -impl ClimateOrderCancellationReason { - pub fn as_str(self) -> &'static str { - use ClimateOrderCancellationReason::*; - match self { - Expired => "expired", - ProductUnavailable => "product_unavailable", - Requested => "requested", - } - } -} - -impl std::str::FromStr for ClimateOrderCancellationReason { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ClimateOrderCancellationReason::*; - match s { - "expired" => Ok(Expired), - "product_unavailable" => Ok(ProductUnavailable), - "requested" => Ok(Requested), - _ => Err(()), - } - } -} -impl std::fmt::Display for ClimateOrderCancellationReason { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ClimateOrderCancellationReason { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ClimateOrderCancellationReason { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for ClimateOrderCancellationReason { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ClimateOrderCancellationReason") - }) - } -} -/// The current status of this order. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ClimateOrderStatus { - AwaitingFunds, - Canceled, - Confirmed, - Delivered, - Open, -} -impl ClimateOrderStatus { - pub fn as_str(self) -> &'static str { - use ClimateOrderStatus::*; - match self { - AwaitingFunds => "awaiting_funds", - Canceled => "canceled", - Confirmed => "confirmed", - Delivered => "delivered", - Open => "open", - } - } -} - -impl std::str::FromStr for ClimateOrderStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ClimateOrderStatus::*; - match s { - "awaiting_funds" => Ok(AwaitingFunds), - "canceled" => Ok(Canceled), - "confirmed" => Ok(Confirmed), - "delivered" => Ok(Delivered), - "open" => Ok(Open), - _ => Err(()), - } - } -} -impl std::fmt::Display for ClimateOrderStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ClimateOrderStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ClimateOrderStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for ClimateOrderStatus { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ClimateOrderStatus")) - } -} -impl stripe_types::Object for ClimateOrder { - type Id = stripe_misc::ClimateOrderId; - fn id(&self) -> &Self::Id { - &self.id - } -} -stripe_types::def_id!(ClimateOrderId); diff --git a/generated/stripe_misc/src/climate_product/mod.rs b/generated/stripe_misc/src/climate_product/mod.rs deleted file mode 100644 index 855638012..000000000 --- a/generated/stripe_misc/src/climate_product/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "climate_product")] -mod requests; -pub(crate) mod types; -#[cfg(feature = "climate_product")] -pub use requests::*; diff --git a/generated/stripe_misc/src/climate_product/requests.rs b/generated/stripe_misc/src/climate_product/requests.rs deleted file mode 100644 index fe787ea90..000000000 --- a/generated/stripe_misc/src/climate_product/requests.rs +++ /dev/null @@ -1,60 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListClimateProduct<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListClimateProduct<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListClimateProduct<'a> { - /// Lists all available Climate product objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ClimateProduct>> { - client.get_query("/climate/products", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ClimateProduct>> { - stripe::ListPaginator::from_list_params("/climate/products", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveClimateProduct<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveClimateProduct<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveClimateProduct<'a> { - /// Retrieves the details of a Climate product with the given ID. - pub fn send( - &self, - client: &stripe::Client, - product: &stripe_misc::ClimateProductId, - ) -> stripe::Response<stripe_misc::ClimateProduct> { - client.get_query(&format!("/climate/products/{product}"), self) - } -} diff --git a/generated/stripe_misc/src/climate_product/types.rs b/generated/stripe_misc/src/climate_product/types.rs deleted file mode 100644 index dd2efbada..000000000 --- a/generated/stripe_misc/src/climate_product/types.rs +++ /dev/null @@ -1,32 +0,0 @@ -/// A Climate product represents a type of carbon removal unit available for reservation. -/// You can retrieve it to see the current price and availability. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClimateProduct { - /// Time at which the object was created. Measured in seconds since the Unix epoch. - pub created: stripe_types::Timestamp, - /// Current prices for a metric ton of carbon removal in a currency's smallest unit. - pub current_prices_per_metric_ton: - std::collections::HashMap<String, stripe_misc::ClimateRemovalsProductsPrice>, - /// The year in which the carbon removal is expected to be delivered. - pub delivery_year: Option<i64>, - /// Unique identifier for the object. For convenience, Climate product IDs are human-readable strings - /// that start with `climsku_`. - /// See [carbon removal inventory](https://stripe.com/docs/climate/orders/carbon-removal-inventory). - /// for a list of available carbon removal products. - pub id: stripe_misc::ClimateProductId, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - pub livemode: bool, - /// The quantity of metric tons available for reservation. - pub metric_tons_available: String, - /// The Climate product's name. - pub name: String, - /// The carbon removal suppliers that fulfill orders for this Climate product. - pub suppliers: Vec<stripe_misc::ClimateSupplier>, -} -impl stripe_types::Object for ClimateProduct { - type Id = stripe_misc::ClimateProductId; - fn id(&self) -> &Self::Id { - &self.id - } -} -stripe_types::def_id!(ClimateProductId); diff --git a/generated/stripe_misc/src/climate_removals_beneficiary.rs b/generated/stripe_misc/src/climate_removals_beneficiary.rs deleted file mode 100644 index f0860a5fc..000000000 --- a/generated/stripe_misc/src/climate_removals_beneficiary.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClimateRemovalsBeneficiary { - /// Publicly displayable name for the end beneficiary of carbon removal. - pub public_name: String, -} diff --git a/generated/stripe_misc/src/climate_removals_location.rs b/generated/stripe_misc/src/climate_removals_location.rs deleted file mode 100644 index 7fa39bc14..000000000 --- a/generated/stripe_misc/src/climate_removals_location.rs +++ /dev/null @@ -1,13 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClimateRemovalsLocation { - /// The city where the supplier is located. - pub city: Option<String>, - /// Two-letter ISO code representing the country where the supplier is located. - pub country: String, - /// The geographic latitude where the supplier is located. - pub latitude: Option<f64>, - /// The geographic longitude where the supplier is located. - pub longitude: Option<f64>, - /// The state/county/province/region where the supplier is located. - pub region: Option<String>, -} diff --git a/generated/stripe_misc/src/climate_removals_order_deliveries.rs b/generated/stripe_misc/src/climate_removals_order_deliveries.rs deleted file mode 100644 index 5dab0ff00..000000000 --- a/generated/stripe_misc/src/climate_removals_order_deliveries.rs +++ /dev/null @@ -1,13 +0,0 @@ -/// The delivery of a specified quantity of carbon for an order. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClimateRemovalsOrderDeliveries { - /// Time at which the delivery occurred. Measured in seconds since the Unix epoch. - pub delivered_at: stripe_types::Timestamp, - /// Specific location of this delivery. - pub location: Option<stripe_misc::ClimateRemovalsLocation>, - /// Quantity of carbon removal supplied by this delivery. - pub metric_tons: String, - /// Once retired, a URL to the registry entry for the tons from this delivery. - pub registry_url: Option<String>, - pub supplier: stripe_misc::ClimateSupplier, -} diff --git a/generated/stripe_misc/src/climate_removals_products_price.rs b/generated/stripe_misc/src/climate_removals_products_price.rs deleted file mode 100644 index 13fb83ed5..000000000 --- a/generated/stripe_misc/src/climate_removals_products_price.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClimateRemovalsProductsPrice { - /// Fees for one metric ton of carbon removal in the currency's smallest unit. - pub amount_fees: i64, - /// Subtotal for one metric ton of carbon removal (excluding fees) in the currency's smallest unit. - pub amount_subtotal: i64, - /// Total for one metric ton of carbon removal (including fees) in the currency's smallest unit. - pub amount_total: i64, -} diff --git a/generated/stripe_misc/src/climate_supplier/mod.rs b/generated/stripe_misc/src/climate_supplier/mod.rs deleted file mode 100644 index d334a4cd5..000000000 --- a/generated/stripe_misc/src/climate_supplier/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "climate_supplier")] -mod requests; -pub(crate) mod types; -#[cfg(feature = "climate_supplier")] -pub use requests::*; diff --git a/generated/stripe_misc/src/climate_supplier/requests.rs b/generated/stripe_misc/src/climate_supplier/requests.rs deleted file mode 100644 index 193bb9685..000000000 --- a/generated/stripe_misc/src/climate_supplier/requests.rs +++ /dev/null @@ -1,60 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListClimateSupplier<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListClimateSupplier<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListClimateSupplier<'a> { - /// Lists all available Climate supplier objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ClimateSupplier>> { - client.get_query("/climate/suppliers", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ClimateSupplier>> { - stripe::ListPaginator::from_list_params("/climate/suppliers", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveClimateSupplier<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveClimateSupplier<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveClimateSupplier<'a> { - /// Retrieves a Climate supplier object. - pub fn send( - &self, - client: &stripe::Client, - supplier: &stripe_misc::ClimateSupplierId, - ) -> stripe::Response<stripe_misc::ClimateSupplier> { - client.get_query(&format!("/climate/suppliers/{supplier}"), self) - } -} diff --git a/generated/stripe_misc/src/climate_supplier/types.rs b/generated/stripe_misc/src/climate_supplier/types.rs deleted file mode 100644 index 5f4a13f13..000000000 --- a/generated/stripe_misc/src/climate_supplier/types.rs +++ /dev/null @@ -1,81 +0,0 @@ -/// A supplier of carbon removal. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClimateSupplier { - /// Unique identifier for the object. - pub id: stripe_misc::ClimateSupplierId, - /// Link to a webpage to learn more about the supplier. - pub info_url: String, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - pub livemode: bool, - /// The locations in which this supplier operates. - pub locations: Vec<stripe_misc::ClimateRemovalsLocation>, - /// Name of this carbon removal supplier. - pub name: String, - /// The scientific pathway used for carbon removal. - pub removal_pathway: ClimateSupplierRemovalPathway, -} -/// The scientific pathway used for carbon removal. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ClimateSupplierRemovalPathway { - BiomassCarbonRemovalAndStorage, - DirectAirCapture, - EnhancedWeathering, -} -impl ClimateSupplierRemovalPathway { - pub fn as_str(self) -> &'static str { - use ClimateSupplierRemovalPathway::*; - match self { - BiomassCarbonRemovalAndStorage => "biomass_carbon_removal_and_storage", - DirectAirCapture => "direct_air_capture", - EnhancedWeathering => "enhanced_weathering", - } - } -} - -impl std::str::FromStr for ClimateSupplierRemovalPathway { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ClimateSupplierRemovalPathway::*; - match s { - "biomass_carbon_removal_and_storage" => Ok(BiomassCarbonRemovalAndStorage), - "direct_air_capture" => Ok(DirectAirCapture), - "enhanced_weathering" => Ok(EnhancedWeathering), - _ => Err(()), - } - } -} -impl std::fmt::Display for ClimateSupplierRemovalPathway { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ClimateSupplierRemovalPathway { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ClimateSupplierRemovalPathway { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for ClimateSupplierRemovalPathway { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ClimateSupplierRemovalPathway") - }) - } -} -impl stripe_types::Object for ClimateSupplier { - type Id = stripe_misc::ClimateSupplierId; - fn id(&self) -> &Self::Id { - &self.id - } -} -stripe_types::def_id!(ClimateSupplierId); diff --git a/generated/stripe_misc/src/deleted_apple_pay_domain.rs b/generated/stripe_misc/src/deleted_apple_pay_domain.rs index 666770f23..c8ba9a193 100644 --- a/generated/stripe_misc/src/deleted_apple_pay_domain.rs +++ b/generated/stripe_misc/src/deleted_apple_pay_domain.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedApplePayDomain { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_misc::ApplePayDomainId, } +#[cfg(feature = "min-ser")] +pub struct DeletedApplePayDomainBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_misc::ApplePayDomainId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedApplePayDomain { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedApplePayDomain>, + builder: DeletedApplePayDomainBuilder, + } + + impl Visitor for Place<DeletedApplePayDomain> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedApplePayDomainBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedApplePayDomainBuilder { + type Out = DeletedApplePayDomain; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedApplePayDomain { + type Builder = DeletedApplePayDomainBuilder; + } + + impl FromValueOpt for DeletedApplePayDomain { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedApplePayDomainBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedApplePayDomain { type Id = stripe_misc::ApplePayDomainId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/deleted_webhook_endpoint.rs b/generated/stripe_misc/src/deleted_webhook_endpoint.rs index c327e5e37..05d194ff0 100644 --- a/generated/stripe_misc/src/deleted_webhook_endpoint.rs +++ b/generated/stripe_misc/src/deleted_webhook_endpoint.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedWebhookEndpoint { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_misc::WebhookEndpointId, } +#[cfg(feature = "min-ser")] +pub struct DeletedWebhookEndpointBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_misc::WebhookEndpointId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedWebhookEndpoint { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedWebhookEndpoint>, + builder: DeletedWebhookEndpointBuilder, + } + + impl Visitor for Place<DeletedWebhookEndpoint> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedWebhookEndpointBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedWebhookEndpointBuilder { + type Out = DeletedWebhookEndpoint; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedWebhookEndpoint { + type Builder = DeletedWebhookEndpointBuilder; + } + + impl FromValueOpt for DeletedWebhookEndpoint { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedWebhookEndpointBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedWebhookEndpoint { type Id = stripe_misc::WebhookEndpointId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/ephemeral_key/requests.rs b/generated/stripe_misc/src/ephemeral_key/requests.rs index 18f1db15b..35b9bf53b 100644 --- a/generated/stripe_misc/src/ephemeral_key/requests.rs +++ b/generated/stripe_misc/src/ephemeral_key/requests.rs @@ -1,25 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteEphemeralKey<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> DeleteEphemeralKey<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> DeleteEphemeralKey<'a> { - /// Invalidates a short-lived API key for a given resource. - pub fn send( - &self, - client: &stripe::Client, - key: &stripe_misc::EphemeralKeyId, - ) -> stripe::Response<stripe_misc::EphemeralKey> { - client.send_form(&format!("/ephemeral_keys/{key}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateEphemeralKey<'a> { /// The ID of the Customer you'd like to modify using the resulting ephemeral key. #[serde(skip_serializing_if = "Option::is_none")] @@ -48,3 +27,20 @@ impl<'a> CreateEphemeralKey<'a> { client.send_form("/ephemeral_keys", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteEphemeralKey<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> DeleteEphemeralKey<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> DeleteEphemeralKey<'a> { + /// Invalidates a short-lived API key for a given resource. + pub fn send(&self, client: &stripe::Client, key: &stripe_misc::EphemeralKeyId) -> stripe::Response<stripe_misc::EphemeralKey> { + client.send_form(&format!("/ephemeral_keys/{key}"), self, http_types::Method::Delete) + } +} diff --git a/generated/stripe_misc/src/ephemeral_key/types.rs b/generated/stripe_misc/src/ephemeral_key/types.rs index 524bd3190..0aedc02ee 100644 --- a/generated/stripe_misc/src/ephemeral_key/types.rs +++ b/generated/stripe_misc/src/ephemeral_key/types.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct EphemeralKey { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -9,9 +11,110 @@ pub struct EphemeralKey { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// The key's secret. You can use this value to make authorized requests to the Stripe API. - #[serde(skip_serializing_if = "Option::is_none")] pub secret: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct EphemeralKeyBuilder { + created: Option<stripe_types::Timestamp>, + expires: Option<stripe_types::Timestamp>, + id: Option<stripe_misc::EphemeralKeyId>, + livemode: Option<bool>, + secret: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for EphemeralKey { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<EphemeralKey>, + builder: EphemeralKeyBuilder, + } + + impl Visitor for Place<EphemeralKey> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: EphemeralKeyBuilder::deser_default() })) + } + } + + impl MapBuilder for EphemeralKeyBuilder { + type Out = EphemeralKey; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "expires" => Deserialize::begin(&mut self.expires), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "secret" => Deserialize::begin(&mut self.secret), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { created: Deserialize::default(), expires: Deserialize::default(), id: Deserialize::default(), livemode: Deserialize::default(), secret: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let expires = self.expires.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let secret = self.secret.take()?; + + Some(Self::Out { created, expires, id, livemode, secret }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for EphemeralKey { + type Builder = EphemeralKeyBuilder; + } + + impl FromValueOpt for EphemeralKey { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = EphemeralKeyBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "expires" => b.expires = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "secret" => b.secret = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for EphemeralKey { type Id = stripe_misc::EphemeralKeyId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/exchange_rate/requests.rs b/generated/stripe_misc/src/exchange_rate/requests.rs index 3b7ddffe3..f55835173 100644 --- a/generated/stripe_misc/src/exchange_rate/requests.rs +++ b/generated/stripe_misc/src/exchange_rate/requests.rs @@ -26,10 +26,7 @@ impl<'a> ListExchangeRate<'a> { impl<'a> ListExchangeRate<'a> { /// Returns a list of objects that contain the rates at which foreign currencies are converted to one another. /// Only shows the currencies for which Stripe supports. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ExchangeRate>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::ExchangeRate>> { client.get_query("/exchange_rates", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ExchangeRate>> { @@ -49,11 +46,7 @@ impl<'a> RetrieveExchangeRate<'a> { } impl<'a> RetrieveExchangeRate<'a> { /// Retrieves the exchange rates from the given currency to every supported currency. - pub fn send( - &self, - client: &stripe::Client, - rate_id: &stripe_misc::ExchangeRateId, - ) -> stripe::Response<stripe_misc::ExchangeRate> { + pub fn send(&self, client: &stripe::Client, rate_id: &stripe_misc::ExchangeRateId) -> stripe::Response<stripe_misc::ExchangeRate> { client.get_query(&format!("/exchange_rates/{rate_id}"), self) } } diff --git a/generated/stripe_misc/src/exchange_rate/types.rs b/generated/stripe_misc/src/exchange_rate/types.rs index 1d6b8a176..3557adc0a 100644 --- a/generated/stripe_misc/src/exchange_rate/types.rs +++ b/generated/stripe_misc/src/exchange_rate/types.rs @@ -26,7 +26,9 @@ /// - *determine app fees to charge a connected account* /// /// *Using this Exchange Rates API beta for any purpose other than to transact on Stripe is strictly prohibited and constitutes a violation of Stripe's terms of service.*. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ExchangeRate { /// Unique identifier for the object. /// Represented as the three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) in lowercase. @@ -34,6 +36,96 @@ pub struct ExchangeRate { /// Hash where the keys are supported currencies and the values are the exchange rate at which the base id currency converts to the key currency. pub rates: std::collections::HashMap<String, f64>, } +#[cfg(feature = "min-ser")] +pub struct ExchangeRateBuilder { + id: Option<stripe_misc::ExchangeRateId>, + rates: Option<std::collections::HashMap<String, f64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ExchangeRate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ExchangeRate>, + builder: ExchangeRateBuilder, + } + + impl Visitor for Place<ExchangeRate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ExchangeRateBuilder::deser_default() })) + } + } + + impl MapBuilder for ExchangeRateBuilder { + type Out = ExchangeRate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "rates" => Deserialize::begin(&mut self.rates), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), rates: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let rates = self.rates.take()?; + + Some(Self::Out { id, rates }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ExchangeRate { + type Builder = ExchangeRateBuilder; + } + + impl FromValueOpt for ExchangeRate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ExchangeRateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "rates" => b.rates = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ExchangeRate { type Id = stripe_misc::ExchangeRateId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/financial_connections_account/requests.rs b/generated/stripe_misc/src/financial_connections_account/requests.rs index e17232df1..72786a776 100644 --- a/generated/stripe_misc/src/financial_connections_account/requests.rs +++ b/generated/stripe_misc/src/financial_connections_account/requests.rs @@ -48,15 +48,10 @@ impl<'a> ListFinancialConnectionsAccountAccountHolder<'a> { } impl<'a> ListFinancialConnectionsAccount<'a> { /// Returns a list of Financial Connections `Account` objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::FinancialConnectionsAccount>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::FinancialConnectionsAccount>> { client.get_query("/financial_connections/accounts", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::FinancialConnectionsAccount>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::FinancialConnectionsAccount>> { stripe::ListPaginator::from_list_params("/financial_connections/accounts", self) } } @@ -73,11 +68,7 @@ impl<'a> RetrieveFinancialConnectionsAccount<'a> { } impl<'a> RetrieveFinancialConnectionsAccount<'a> { /// Retrieves the details of an Financial Connections `Account`. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_misc::FinancialConnectionsAccountId, - ) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { + pub fn send(&self, client: &stripe::Client, account: &stripe_misc::FinancialConnectionsAccountId) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { client.get_query(&format!("/financial_connections/accounts/{account}"), self) } } @@ -110,49 +101,11 @@ impl<'a> ListOwnersFinancialConnectionsAccount<'a> { } impl<'a> ListOwnersFinancialConnectionsAccount<'a> { /// Lists all owners for a given `Account` - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_misc::FinancialConnectionsAccountId, - ) -> stripe::Response<stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>> { + pub fn send(&self, client: &stripe::Client, account: &stripe_misc::FinancialConnectionsAccountId) -> stripe::Response<stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>> { client.get_query(&format!("/financial_connections/accounts/{account}/owners"), self) } - pub fn paginate( - self, - account: &stripe_misc::FinancialConnectionsAccountId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>> - { - stripe::ListPaginator::from_list_params( - &format!("/financial_connections/accounts/{account}/owners"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DisconnectFinancialConnectionsAccount<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> DisconnectFinancialConnectionsAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> DisconnectFinancialConnectionsAccount<'a> { - /// Disables your access to a Financial Connections `Account`. - /// You will no longer be able to access data associated with the account (e.g. - /// balances, transactions). - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_misc::FinancialConnectionsAccountId, - ) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { - client.send_form( - &format!("/financial_connections/accounts/{account}/disconnect"), - self, - http_types::Method::Post, - ) + pub fn paginate(self, account: &stripe_misc::FinancialConnectionsAccountId) -> stripe::ListPaginator<stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>> { + stripe::ListPaginator::from_list_params(&format!("/financial_connections/accounts/{account}/owners"), self) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -173,7 +126,6 @@ impl<'a> RefreshFinancialConnectionsAccount<'a> { pub enum RefreshFinancialConnectionsAccountFeatures { Balance, Ownership, - Transactions, } impl RefreshFinancialConnectionsAccountFeatures { pub fn as_str(self) -> &'static str { @@ -181,7 +133,6 @@ impl RefreshFinancialConnectionsAccountFeatures { match self { Balance => "balance", Ownership => "ownership", - Transactions => "transactions", } } } @@ -193,7 +144,6 @@ impl std::str::FromStr for RefreshFinancialConnectionsAccountFeatures { match s { "balance" => Ok(Balance), "ownership" => Ok(Ownership), - "transactions" => Ok(Transactions), _ => Err(()), } } @@ -219,155 +169,26 @@ impl serde::Serialize for RefreshFinancialConnectionsAccountFeatures { } impl<'a> RefreshFinancialConnectionsAccount<'a> { /// Refreshes the data associated with a Financial Connections `Account`. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_misc::FinancialConnectionsAccountId, - ) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { - client.send_form( - &format!("/financial_connections/accounts/{account}/refresh"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct SubscribeFinancialConnectionsAccount<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// The list of account features to which you would like to subscribe. - pub features: &'a [SubscribeFinancialConnectionsAccountFeatures], -} -impl<'a> SubscribeFinancialConnectionsAccount<'a> { - pub fn new(features: &'a [SubscribeFinancialConnectionsAccountFeatures]) -> Self { - Self { expand: None, features } + pub fn send(&self, client: &stripe::Client, account: &stripe_misc::FinancialConnectionsAccountId) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { + client.send_form(&format!("/financial_connections/accounts/{account}/refresh"), self, http_types::Method::Post) } } -/// The list of account features to which you would like to subscribe. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum SubscribeFinancialConnectionsAccountFeatures { - Transactions, -} -impl SubscribeFinancialConnectionsAccountFeatures { - pub fn as_str(self) -> &'static str { - use SubscribeFinancialConnectionsAccountFeatures::*; - match self { - Transactions => "transactions", - } - } -} - -impl std::str::FromStr for SubscribeFinancialConnectionsAccountFeatures { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use SubscribeFinancialConnectionsAccountFeatures::*; - match s { - "transactions" => Ok(Transactions), - _ => Err(()), - } - } -} -impl std::fmt::Display for SubscribeFinancialConnectionsAccountFeatures { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for SubscribeFinancialConnectionsAccountFeatures { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for SubscribeFinancialConnectionsAccountFeatures { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> SubscribeFinancialConnectionsAccount<'a> { - /// Subscribes to periodic refreshes of data associated with a Financial Connections `Account`. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_misc::FinancialConnectionsAccountId, - ) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { - client.send_form( - &format!("/financial_connections/accounts/{account}/subscribe"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UnsubscribeFinancialConnectionsAccount<'a> { +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DisconnectFinancialConnectionsAccount<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// The list of account features from which you would like to unsubscribe. - pub features: &'a [UnsubscribeFinancialConnectionsAccountFeatures], -} -impl<'a> UnsubscribeFinancialConnectionsAccount<'a> { - pub fn new(features: &'a [UnsubscribeFinancialConnectionsAccountFeatures]) -> Self { - Self { expand: None, features } - } -} -/// The list of account features from which you would like to unsubscribe. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UnsubscribeFinancialConnectionsAccountFeatures { - Transactions, -} -impl UnsubscribeFinancialConnectionsAccountFeatures { - pub fn as_str(self) -> &'static str { - use UnsubscribeFinancialConnectionsAccountFeatures::*; - match self { - Transactions => "transactions", - } - } -} - -impl std::str::FromStr for UnsubscribeFinancialConnectionsAccountFeatures { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UnsubscribeFinancialConnectionsAccountFeatures::*; - match s { - "transactions" => Ok(Transactions), - _ => Err(()), - } - } -} -impl std::fmt::Display for UnsubscribeFinancialConnectionsAccountFeatures { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UnsubscribeFinancialConnectionsAccountFeatures { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } } -impl serde::Serialize for UnsubscribeFinancialConnectionsAccountFeatures { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl<'a> DisconnectFinancialConnectionsAccount<'a> { + pub fn new() -> Self { + Self::default() } } -impl<'a> UnsubscribeFinancialConnectionsAccount<'a> { - /// Unsubscribes from periodic refreshes of data associated with a Financial Connections `Account`. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_misc::FinancialConnectionsAccountId, - ) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { - client.send_form( - &format!("/financial_connections/accounts/{account}/unsubscribe"), - self, - http_types::Method::Post, - ) +impl<'a> DisconnectFinancialConnectionsAccount<'a> { + /// Disables your access to a Financial Connections `Account`. + /// You will no longer be able to access data associated with the account (e.g. + /// balances, transactions). + pub fn send(&self, client: &stripe::Client, account: &stripe_misc::FinancialConnectionsAccountId) -> stripe::Response<stripe_misc::FinancialConnectionsAccount> { + client.send_form(&format!("/financial_connections/accounts/{account}/disconnect"), self, http_types::Method::Post) } } diff --git a/generated/stripe_misc/src/financial_connections_account/types.rs b/generated/stripe_misc/src/financial_connections_account/types.rs index c1751e37f..a1b4ff8ed 100644 --- a/generated/stripe_misc/src/financial_connections_account/types.rs +++ b/generated/stripe_misc/src/financial_connections_account/types.rs @@ -1,7 +1,9 @@ /// A Financial Connections Account represents an account that exists outside of Stripe, to which you have been granted some degree of access. /// /// For more details see <<https://stripe.com/docs/api/financial_connections/accounts/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FinancialConnectionsAccount { /// The account holder that this account belongs to. pub account_holder: Option<stripe_misc::BankConnectionsResourceAccountholder>, @@ -24,8 +26,7 @@ pub struct FinancialConnectionsAccount { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// The most recent information about the account's owners. - pub ownership: - Option<stripe_types::Expandable<stripe_misc::FinancialConnectionsAccountOwnership>>, + pub ownership: Option<stripe_types::Expandable<stripe_misc::FinancialConnectionsAccountOwnership>>, /// The state of the most recent attempt to refresh the account owners. pub ownership_refresh: Option<stripe_misc::BankConnectionsResourceOwnershipRefresh>, /// The list of permissions granted by this account. @@ -47,13 +48,189 @@ pub struct FinancialConnectionsAccount { /// /// If `category` is `investment` or `other`, this will be `other`. pub subcategory: FinancialConnectionsAccountSubcategory, - /// The list of data refresh subscriptions requested on this account. - pub subscriptions: Option<Vec<FinancialConnectionsAccountSubscriptions>>, /// The [PaymentMethod type](https://stripe.com/docs/api/payment_methods/object#payment_method_object-type)(s) that can be created from this account. pub supported_payment_method_types: Vec<FinancialConnectionsAccountSupportedPaymentMethodTypes>, - /// The state of the most recent attempt to refresh the account transactions. - pub transaction_refresh: Option<stripe_misc::BankConnectionsResourceTransactionRefresh>, } +#[cfg(feature = "min-ser")] +pub struct FinancialConnectionsAccountBuilder { + account_holder: Option<Option<stripe_misc::BankConnectionsResourceAccountholder>>, + balance: Option<Option<stripe_misc::BankConnectionsResourceBalance>>, + balance_refresh: Option<Option<stripe_misc::BankConnectionsResourceBalanceRefresh>>, + category: Option<FinancialConnectionsAccountCategory>, + created: Option<stripe_types::Timestamp>, + display_name: Option<Option<String>>, + id: Option<stripe_misc::FinancialConnectionsAccountId>, + institution_name: Option<String>, + last4: Option<Option<String>>, + livemode: Option<bool>, + ownership: Option<Option<stripe_types::Expandable<stripe_misc::FinancialConnectionsAccountOwnership>>>, + ownership_refresh: Option<Option<stripe_misc::BankConnectionsResourceOwnershipRefresh>>, + permissions: Option<Option<Vec<FinancialConnectionsAccountPermissions>>>, + status: Option<FinancialConnectionsAccountStatus>, + subcategory: Option<FinancialConnectionsAccountSubcategory>, + supported_payment_method_types: Option<Vec<FinancialConnectionsAccountSupportedPaymentMethodTypes>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FinancialConnectionsAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FinancialConnectionsAccount>, + builder: FinancialConnectionsAccountBuilder, + } + + impl Visitor for Place<FinancialConnectionsAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FinancialConnectionsAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for FinancialConnectionsAccountBuilder { + type Out = FinancialConnectionsAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder" => Deserialize::begin(&mut self.account_holder), + "balance" => Deserialize::begin(&mut self.balance), + "balance_refresh" => Deserialize::begin(&mut self.balance_refresh), + "category" => Deserialize::begin(&mut self.category), + "created" => Deserialize::begin(&mut self.created), + "display_name" => Deserialize::begin(&mut self.display_name), + "id" => Deserialize::begin(&mut self.id), + "institution_name" => Deserialize::begin(&mut self.institution_name), + "last4" => Deserialize::begin(&mut self.last4), + "livemode" => Deserialize::begin(&mut self.livemode), + "ownership" => Deserialize::begin(&mut self.ownership), + "ownership_refresh" => Deserialize::begin(&mut self.ownership_refresh), + "permissions" => Deserialize::begin(&mut self.permissions), + "status" => Deserialize::begin(&mut self.status), + "subcategory" => Deserialize::begin(&mut self.subcategory), + "supported_payment_method_types" => Deserialize::begin(&mut self.supported_payment_method_types), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder: Deserialize::default(), + balance: Deserialize::default(), + balance_refresh: Deserialize::default(), + category: Deserialize::default(), + created: Deserialize::default(), + display_name: Deserialize::default(), + id: Deserialize::default(), + institution_name: Deserialize::default(), + last4: Deserialize::default(), + livemode: Deserialize::default(), + ownership: Deserialize::default(), + ownership_refresh: Deserialize::default(), + permissions: Deserialize::default(), + status: Deserialize::default(), + subcategory: Deserialize::default(), + supported_payment_method_types: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder = self.account_holder.take()?; + let balance = self.balance.take()?; + let balance_refresh = self.balance_refresh.take()?; + let category = self.category.take()?; + let created = self.created.take()?; + let display_name = self.display_name.take()?; + let id = self.id.take()?; + let institution_name = self.institution_name.take()?; + let last4 = self.last4.take()?; + let livemode = self.livemode.take()?; + let ownership = self.ownership.take()?; + let ownership_refresh = self.ownership_refresh.take()?; + let permissions = self.permissions.take()?; + let status = self.status.take()?; + let subcategory = self.subcategory.take()?; + let supported_payment_method_types = self.supported_payment_method_types.take()?; + + Some(Self::Out { + account_holder, + balance, + balance_refresh, + category, + created, + display_name, + id, + institution_name, + last4, + livemode, + ownership, + ownership_refresh, + permissions, + status, + subcategory, + supported_payment_method_types, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FinancialConnectionsAccount { + type Builder = FinancialConnectionsAccountBuilder; + } + + impl FromValueOpt for FinancialConnectionsAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FinancialConnectionsAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder" => b.account_holder = Some(FromValueOpt::from_value(v)?), + "balance" => b.balance = Some(FromValueOpt::from_value(v)?), + "balance_refresh" => b.balance_refresh = Some(FromValueOpt::from_value(v)?), + "category" => b.category = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "institution_name" => b.institution_name = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "ownership" => b.ownership = Some(FromValueOpt::from_value(v)?), + "ownership_refresh" => b.ownership_refresh = Some(FromValueOpt::from_value(v)?), + "permissions" => b.permissions = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "subcategory" => b.subcategory = Some(FromValueOpt::from_value(v)?), + "supported_payment_method_types" => b.supported_payment_method_types = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the account. Account category is further divided in `subcategory`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum FinancialConnectionsAccountCategory { @@ -110,11 +287,27 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountCategory { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsAccountCategory") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FinancialConnectionsAccountCategory")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FinancialConnectionsAccountCategory { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FinancialConnectionsAccountCategory> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FinancialConnectionsAccountCategory::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountCategory); /// The list of permissions granted by this account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum FinancialConnectionsAccountPermissions { @@ -171,11 +364,27 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountPermissions { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsAccountPermissions") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FinancialConnectionsAccountPermissions")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FinancialConnectionsAccountPermissions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FinancialConnectionsAccountPermissions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FinancialConnectionsAccountPermissions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountPermissions); /// The status of the link to the account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum FinancialConnectionsAccountStatus { @@ -229,11 +438,27 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsAccountStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FinancialConnectionsAccountStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FinancialConnectionsAccountStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FinancialConnectionsAccountStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FinancialConnectionsAccountStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountStatus); /// If `category` is `cash`, one of: /// /// - `checking` @@ -309,63 +534,27 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountSubcategory { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsAccountSubcategory") - }) - } -} -/// The list of data refresh subscriptions requested on this account. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum FinancialConnectionsAccountSubscriptions { - Transactions, -} -impl FinancialConnectionsAccountSubscriptions { - pub fn as_str(self) -> &'static str { - use FinancialConnectionsAccountSubscriptions::*; - match self { - Transactions => "transactions", - } - } -} - -impl std::str::FromStr for FinancialConnectionsAccountSubscriptions { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use FinancialConnectionsAccountSubscriptions::*; - match s { - "transactions" => Ok(Transactions), - _ => Err(()), - } + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FinancialConnectionsAccountSubcategory")) } } -impl std::fmt::Display for FinancialConnectionsAccountSubscriptions { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FinancialConnectionsAccountSubcategory { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } -impl std::fmt::Debug for FinancialConnectionsAccountSubscriptions { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for FinancialConnectionsAccountSubscriptions { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountSubscriptions { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FinancialConnectionsAccountSubcategory> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsAccountSubscriptions") - }) + self.out = Some(FinancialConnectionsAccountSubcategory::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountSubcategory); /// The [PaymentMethod type](https://stripe.com/docs/api/payment_methods/object#payment_method_object-type)(s) that can be created from this account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum FinancialConnectionsAccountSupportedPaymentMethodTypes { @@ -416,13 +605,27 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountSupportedPaymen fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for FinancialConnectionsAccountSupportedPaymentMethodTypes", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FinancialConnectionsAccountSupportedPaymentMethodTypes")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FinancialConnectionsAccountSupportedPaymentMethodTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FinancialConnectionsAccountSupportedPaymentMethodTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FinancialConnectionsAccountSupportedPaymentMethodTypes::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountSupportedPaymentMethodTypes); impl stripe_types::Object for FinancialConnectionsAccount { type Id = stripe_misc::FinancialConnectionsAccountId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/financial_connections_account_owner.rs b/generated/stripe_misc/src/financial_connections_account_owner.rs index 02630032d..1d6d5459a 100644 --- a/generated/stripe_misc/src/financial_connections_account_owner.rs +++ b/generated/stripe_misc/src/financial_connections_account_owner.rs @@ -1,5 +1,7 @@ /// Describes an owner of an account. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FinancialConnectionsAccountOwner { /// The email address of the owner. pub email: Option<String>, @@ -16,6 +18,124 @@ pub struct FinancialConnectionsAccountOwner { /// The timestamp of the refresh that updated this owner. pub refreshed_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct FinancialConnectionsAccountOwnerBuilder { + email: Option<Option<String>>, + id: Option<stripe_misc::FinancialConnectionsAccountOwnerId>, + name: Option<String>, + ownership: Option<String>, + phone: Option<Option<String>>, + raw_address: Option<Option<String>>, + refreshed_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FinancialConnectionsAccountOwner { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FinancialConnectionsAccountOwner>, + builder: FinancialConnectionsAccountOwnerBuilder, + } + + impl Visitor for Place<FinancialConnectionsAccountOwner> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FinancialConnectionsAccountOwnerBuilder::deser_default() })) + } + } + + impl MapBuilder for FinancialConnectionsAccountOwnerBuilder { + type Out = FinancialConnectionsAccountOwner; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "email" => Deserialize::begin(&mut self.email), + "id" => Deserialize::begin(&mut self.id), + "name" => Deserialize::begin(&mut self.name), + "ownership" => Deserialize::begin(&mut self.ownership), + "phone" => Deserialize::begin(&mut self.phone), + "raw_address" => Deserialize::begin(&mut self.raw_address), + "refreshed_at" => Deserialize::begin(&mut self.refreshed_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + email: Deserialize::default(), + id: Deserialize::default(), + name: Deserialize::default(), + ownership: Deserialize::default(), + phone: Deserialize::default(), + raw_address: Deserialize::default(), + refreshed_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let email = self.email.take()?; + let id = self.id.take()?; + let name = self.name.take()?; + let ownership = self.ownership.take()?; + let phone = self.phone.take()?; + let raw_address = self.raw_address.take()?; + let refreshed_at = self.refreshed_at.take()?; + + Some(Self::Out { email, id, name, ownership, phone, raw_address, refreshed_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FinancialConnectionsAccountOwner { + type Builder = FinancialConnectionsAccountOwnerBuilder; + } + + impl FromValueOpt for FinancialConnectionsAccountOwner { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FinancialConnectionsAccountOwnerBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "ownership" => b.ownership = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + "raw_address" => b.raw_address = Some(FromValueOpt::from_value(v)?), + "refreshed_at" => b.refreshed_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for FinancialConnectionsAccountOwner { type Id = stripe_misc::FinancialConnectionsAccountOwnerId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/financial_connections_account_ownership.rs b/generated/stripe_misc/src/financial_connections_account_ownership.rs index 82417f791..6afb9f69a 100644 --- a/generated/stripe_misc/src/financial_connections_account_ownership.rs +++ b/generated/stripe_misc/src/financial_connections_account_ownership.rs @@ -1,5 +1,7 @@ /// Describes a snapshot of the owners of an account at a particular point in time. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FinancialConnectionsAccountOwnership { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -8,6 +10,100 @@ pub struct FinancialConnectionsAccountOwnership { /// A paginated list of owners for this account. pub owners: stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>, } +#[cfg(feature = "min-ser")] +pub struct FinancialConnectionsAccountOwnershipBuilder { + created: Option<stripe_types::Timestamp>, + id: Option<stripe_misc::FinancialConnectionsAccountOwnershipId>, + owners: Option<stripe_types::List<stripe_misc::FinancialConnectionsAccountOwner>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FinancialConnectionsAccountOwnership { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FinancialConnectionsAccountOwnership>, + builder: FinancialConnectionsAccountOwnershipBuilder, + } + + impl Visitor for Place<FinancialConnectionsAccountOwnership> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FinancialConnectionsAccountOwnershipBuilder::deser_default() })) + } + } + + impl MapBuilder for FinancialConnectionsAccountOwnershipBuilder { + type Out = FinancialConnectionsAccountOwnership; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "id" => Deserialize::begin(&mut self.id), + "owners" => Deserialize::begin(&mut self.owners), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { created: Deserialize::default(), id: Deserialize::default(), owners: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let id = self.id.take()?; + let owners = self.owners.take()?; + + Some(Self::Out { created, id, owners }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FinancialConnectionsAccountOwnership { + type Builder = FinancialConnectionsAccountOwnershipBuilder; + } + + impl FromValueOpt for FinancialConnectionsAccountOwnership { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FinancialConnectionsAccountOwnershipBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "owners" => b.owners = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for FinancialConnectionsAccountOwnership { type Id = stripe_misc::FinancialConnectionsAccountOwnershipId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/financial_connections_session/requests.rs b/generated/stripe_misc/src/financial_connections_session/requests.rs index d9cd397b3..b0c7878b4 100644 --- a/generated/stripe_misc/src/financial_connections_session/requests.rs +++ b/generated/stripe_misc/src/financial_connections_session/requests.rs @@ -1,24 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveFinancialConnectionsSession<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveFinancialConnectionsSession<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveFinancialConnectionsSession<'a> { - /// Retrieves the details of a Financial Connections `Session` - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_misc::FinancialConnectionsSessionId, - ) -> stripe::Response<stripe_misc::FinancialConnectionsSession> { - client.get_query(&format!("/financial_connections/sessions/{session}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateFinancialConnectionsSession<'a> { /// The account holder to link accounts for. @@ -42,18 +21,8 @@ pub struct CreateFinancialConnectionsSession<'a> { pub return_url: Option<&'a str>, } impl<'a> CreateFinancialConnectionsSession<'a> { - pub fn new( - account_holder: CreateFinancialConnectionsSessionAccountHolder<'a>, - permissions: &'a [stripe_misc::FinancialConnectionsSessionPermissions], - ) -> Self { - Self { - account_holder, - expand: None, - filters: None, - permissions, - prefetch: None, - return_url: None, - } + pub fn new(account_holder: CreateFinancialConnectionsSessionAccountHolder<'a>, permissions: &'a [stripe_misc::FinancialConnectionsSessionPermissions]) -> Self { + Self { account_holder, expand: None, filters: None, permissions, prefetch: None, return_url: None } } } /// The account holder to link accounts for. @@ -68,7 +37,7 @@ pub struct CreateFinancialConnectionsSessionAccountHolder<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<&'a str>, /// Type of account holder to collect accounts for. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateFinancialConnectionsSessionAccountHolderType, } impl<'a> CreateFinancialConnectionsSessionAccountHolder<'a> { @@ -136,10 +105,24 @@ impl<'a> CreateFinancialConnectionsSessionFilters<'a> { impl<'a> CreateFinancialConnectionsSession<'a> { /// To launch the Financial Connections authorization flow, create a `Session`. /// The session’s `client_secret` can be used to launch the flow using Stripe.js. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_misc::FinancialConnectionsSession> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::FinancialConnectionsSession> { client.send_form("/financial_connections/sessions", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveFinancialConnectionsSession<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveFinancialConnectionsSession<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveFinancialConnectionsSession<'a> { + /// Retrieves the details of a Financial Connections `Session` + pub fn send(&self, client: &stripe::Client, session: &stripe_misc::FinancialConnectionsSessionId) -> stripe::Response<stripe_misc::FinancialConnectionsSession> { + client.get_query(&format!("/financial_connections/sessions/{session}"), self) + } +} diff --git a/generated/stripe_misc/src/financial_connections_session/types.rs b/generated/stripe_misc/src/financial_connections_session/types.rs index 9890e5288..9ec4b50e4 100644 --- a/generated/stripe_misc/src/financial_connections_session/types.rs +++ b/generated/stripe_misc/src/financial_connections_session/types.rs @@ -1,7 +1,9 @@ /// A Financial Connections Session is the secure way to programmatically launch the client-side Stripe.js modal that lets your users link their accounts. /// /// For more details see <<https://stripe.com/docs/api/financial_connections/sessions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FinancialConnectionsSession { /// The account holder for whom accounts are collected in this session. pub account_holder: Option<stripe_misc::BankConnectionsResourceAccountholder>, @@ -9,7 +11,6 @@ pub struct FinancialConnectionsSession { pub accounts: stripe_types::List<stripe_misc::FinancialConnectionsAccount>, /// A value that will be passed to the client to launch the authentication flow. pub client_secret: String, - #[serde(skip_serializing_if = "Option::is_none")] pub filters: Option<stripe_misc::BankConnectionsResourceLinkAccountSessionFilters>, /// Unique identifier for the object. pub id: stripe_misc::FinancialConnectionsSessionId, @@ -21,9 +22,136 @@ pub struct FinancialConnectionsSession { pub prefetch: Option<Vec<stripe_misc::FinancialConnectionsSessionPrefetch>>, /// For webview integrations only. /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. - #[serde(skip_serializing_if = "Option::is_none")] pub return_url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct FinancialConnectionsSessionBuilder { + account_holder: Option<Option<stripe_misc::BankConnectionsResourceAccountholder>>, + accounts: Option<stripe_types::List<stripe_misc::FinancialConnectionsAccount>>, + client_secret: Option<String>, + filters: Option<Option<stripe_misc::BankConnectionsResourceLinkAccountSessionFilters>>, + id: Option<stripe_misc::FinancialConnectionsSessionId>, + livemode: Option<bool>, + permissions: Option<Vec<stripe_misc::FinancialConnectionsSessionPermissions>>, + prefetch: Option<Option<Vec<stripe_misc::FinancialConnectionsSessionPrefetch>>>, + return_url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FinancialConnectionsSession { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FinancialConnectionsSession>, + builder: FinancialConnectionsSessionBuilder, + } + + impl Visitor for Place<FinancialConnectionsSession> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FinancialConnectionsSessionBuilder::deser_default() })) + } + } + + impl MapBuilder for FinancialConnectionsSessionBuilder { + type Out = FinancialConnectionsSession; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder" => Deserialize::begin(&mut self.account_holder), + "accounts" => Deserialize::begin(&mut self.accounts), + "client_secret" => Deserialize::begin(&mut self.client_secret), + "filters" => Deserialize::begin(&mut self.filters), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "permissions" => Deserialize::begin(&mut self.permissions), + "prefetch" => Deserialize::begin(&mut self.prefetch), + "return_url" => Deserialize::begin(&mut self.return_url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder: Deserialize::default(), + accounts: Deserialize::default(), + client_secret: Deserialize::default(), + filters: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + permissions: Deserialize::default(), + prefetch: Deserialize::default(), + return_url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder = self.account_holder.take()?; + let accounts = self.accounts.take()?; + let client_secret = self.client_secret.take()?; + let filters = self.filters.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let permissions = self.permissions.take()?; + let prefetch = self.prefetch.take()?; + let return_url = self.return_url.take()?; + + Some(Self::Out { account_holder, accounts, client_secret, filters, id, livemode, permissions, prefetch, return_url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FinancialConnectionsSession { + type Builder = FinancialConnectionsSessionBuilder; + } + + impl FromValueOpt for FinancialConnectionsSession { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FinancialConnectionsSessionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder" => b.account_holder = Some(FromValueOpt::from_value(v)?), + "accounts" => b.accounts = Some(FromValueOpt::from_value(v)?), + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "filters" => b.filters = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "permissions" => b.permissions = Some(FromValueOpt::from_value(v)?), + "prefetch" => b.prefetch = Some(FromValueOpt::from_value(v)?), + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for FinancialConnectionsSession { type Id = stripe_misc::FinancialConnectionsSessionId; fn id(&self) -> &Self::Id { @@ -86,16 +214,31 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsSessionPermissions { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsSessionPermissions") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FinancialConnectionsSessionPermissions")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FinancialConnectionsSessionPermissions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FinancialConnectionsSessionPermissions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FinancialConnectionsSessionPermissions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsSessionPermissions); #[derive(Copy, Clone, Eq, PartialEq)] pub enum FinancialConnectionsSessionPrefetch { Balances, Ownership, - Transactions, } impl FinancialConnectionsSessionPrefetch { pub fn as_str(self) -> &'static str { @@ -103,7 +246,6 @@ impl FinancialConnectionsSessionPrefetch { match self { Balances => "balances", Ownership => "ownership", - Transactions => "transactions", } } } @@ -115,7 +257,6 @@ impl std::str::FromStr for FinancialConnectionsSessionPrefetch { match s { "balances" => Ok(Balances), "ownership" => Ok(Ownership), - "transactions" => Ok(Transactions), _ => Err(()), } } @@ -143,8 +284,24 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsSessionPrefetch { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsSessionPrefetch") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FinancialConnectionsSessionPrefetch")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FinancialConnectionsSessionPrefetch { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FinancialConnectionsSessionPrefetch> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FinancialConnectionsSessionPrefetch::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsSessionPrefetch); diff --git a/generated/stripe_misc/src/financial_connections_transaction/mod.rs b/generated/stripe_misc/src/financial_connections_transaction/mod.rs deleted file mode 100644 index eb10ac40c..000000000 --- a/generated/stripe_misc/src/financial_connections_transaction/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[cfg(feature = "financial_connections_transaction")] -mod requests; -pub(crate) mod types; -#[cfg(feature = "financial_connections_transaction")] -pub use requests::*; diff --git a/generated/stripe_misc/src/financial_connections_transaction/requests.rs b/generated/stripe_misc/src/financial_connections_transaction/requests.rs deleted file mode 100644 index ec05ca1d9..000000000 --- a/generated/stripe_misc/src/financial_connections_transaction/requests.rs +++ /dev/null @@ -1,91 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ListFinancialConnectionsTransaction<'a> { - /// The ID of the Stripe account whose transactions will be retrieved. - pub account: &'a str, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// A filter on the list based on the object `transacted_at` field. - /// The value can be a string with an integer Unix timestamp, or it can be a dictionary with the following options:. - #[serde(skip_serializing_if = "Option::is_none")] - pub transacted_at: Option<stripe_types::RangeQueryTs>, - /// A filter on the list based on the object `transaction_refresh` field. - /// The value can be a dictionary with the following options:. - #[serde(skip_serializing_if = "Option::is_none")] - pub transaction_refresh: Option<ListFinancialConnectionsTransactionTransactionRefresh<'a>>, -} -impl<'a> ListFinancialConnectionsTransaction<'a> { - pub fn new(account: &'a str) -> Self { - Self { - account, - ending_before: None, - expand: None, - limit: None, - starting_after: None, - transacted_at: None, - transaction_refresh: None, - } - } -} -/// A filter on the list based on the object `transaction_refresh` field. -/// The value can be a dictionary with the following options:. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ListFinancialConnectionsTransactionTransactionRefresh<'a> { - /// Return results where the transactions were created or updated by a refresh that took place after this refresh (non-inclusive). - pub after: &'a str, -} -impl<'a> ListFinancialConnectionsTransactionTransactionRefresh<'a> { - pub fn new(after: &'a str) -> Self { - Self { after } - } -} -impl<'a> ListFinancialConnectionsTransaction<'a> { - /// Returns a list of Financial Connections `Transaction` objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::FinancialConnectionsTransaction>> { - client.get_query("/financial_connections/transactions", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::FinancialConnectionsTransaction>> - { - stripe::ListPaginator::from_list_params("/financial_connections/transactions", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveFinancialConnectionsTransaction<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveFinancialConnectionsTransaction<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveFinancialConnectionsTransaction<'a> { - /// Retrieves the details of a Financial Connections `Transaction` - pub fn send( - &self, - client: &stripe::Client, - transaction: &stripe_misc::FinancialConnectionsTransactionId, - ) -> stripe::Response<stripe_misc::FinancialConnectionsTransaction> { - client.get_query(&format!("/financial_connections/transactions/{transaction}"), self) - } -} diff --git a/generated/stripe_misc/src/financial_connections_transaction/types.rs b/generated/stripe_misc/src/financial_connections_transaction/types.rs deleted file mode 100644 index 774426515..000000000 --- a/generated/stripe_misc/src/financial_connections_transaction/types.rs +++ /dev/null @@ -1,92 +0,0 @@ -/// A Transaction represents a real transaction that affects a Financial Connections Account balance. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct FinancialConnectionsTransaction { - /// The ID of the Financial Connections Account this transaction belongs to. - pub account: String, - /// The amount of this transaction, in cents (or local equivalent). - pub amount: i64, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// The description of this transaction. - pub description: String, - /// Unique identifier for the object. - pub id: stripe_misc::FinancialConnectionsTransactionId, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - pub livemode: bool, - /// The status of the transaction. - pub status: FinancialConnectionsTransactionStatus, - pub status_transitions: - stripe_misc::BankConnectionsResourceTransactionResourceStatusTransitions, - /// Time at which the transaction was transacted. Measured in seconds since the Unix epoch. - pub transacted_at: stripe_types::Timestamp, - /// The token of the transaction refresh that last updated or created this transaction. - pub transaction_refresh: String, - /// Time at which the object was last updated. Measured in seconds since the Unix epoch. - pub updated: stripe_types::Timestamp, -} -/// The status of the transaction. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum FinancialConnectionsTransactionStatus { - Pending, - Posted, - Void, -} -impl FinancialConnectionsTransactionStatus { - pub fn as_str(self) -> &'static str { - use FinancialConnectionsTransactionStatus::*; - match self { - Pending => "pending", - Posted => "posted", - Void => "void", - } - } -} - -impl std::str::FromStr for FinancialConnectionsTransactionStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use FinancialConnectionsTransactionStatus::*; - match s { - "pending" => Ok(Pending), - "posted" => Ok(Posted), - "void" => Ok(Void), - _ => Err(()), - } - } -} -impl std::fmt::Display for FinancialConnectionsTransactionStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for FinancialConnectionsTransactionStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for FinancialConnectionsTransactionStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for FinancialConnectionsTransactionStatus { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FinancialConnectionsTransactionStatus") - }) - } -} -impl stripe_types::Object for FinancialConnectionsTransaction { - type Id = stripe_misc::FinancialConnectionsTransactionId; - fn id(&self) -> &Self::Id { - &self.id - } -} -stripe_types::def_id!(FinancialConnectionsTransactionId); diff --git a/generated/stripe_misc/src/financial_reporting_finance_report_run_run_parameters.rs b/generated/stripe_misc/src/financial_reporting_finance_report_run_run_parameters.rs index f4f1483b3..4e5cdfbd6 100644 --- a/generated/stripe_misc/src/financial_reporting_finance_report_run_run_parameters.rs +++ b/generated/stripe_misc/src/financial_reporting_finance_report_run_run_parameters.rs @@ -1,32 +1,149 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FinancialReportingFinanceReportRunRunParameters { /// The set of output columns requested for inclusion in the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub columns: Option<Vec<String>>, /// Connected account ID by which to filter the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub connected_account: Option<String>, /// Currency of objects to be included in the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<stripe_types::Currency>, /// Ending timestamp of data to be included in the report run. /// Can be any UTC timestamp between 1 second after the user specified `interval_start` and 1 second before this report's last `data_available_end` value. - #[serde(skip_serializing_if = "Option::is_none")] pub interval_end: Option<stripe_types::Timestamp>, /// Starting timestamp of data to be included in the report run. /// Can be any UTC timestamp between 1 second after this report's `data_available_start` and 1 second before the user specified `interval_end` value. - #[serde(skip_serializing_if = "Option::is_none")] pub interval_start: Option<stripe_types::Timestamp>, /// Payout ID by which to filter the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub payout: Option<String>, /// Category of balance transactions to be included in the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub reporting_category: Option<String>, /// Defaults to `Etc/UTC`. /// The output timezone for all timestamps in the report. /// A list of possible time zone values is maintained at the [IANA Time Zone Database](http://www.iana.org/time-zones). /// Has no effect on `interval_start` or `interval_end`. - #[serde(skip_serializing_if = "Option::is_none")] pub timezone: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct FinancialReportingFinanceReportRunRunParametersBuilder { + columns: Option<Option<Vec<String>>>, + connected_account: Option<Option<String>>, + currency: Option<Option<stripe_types::Currency>>, + interval_end: Option<Option<stripe_types::Timestamp>>, + interval_start: Option<Option<stripe_types::Timestamp>>, + payout: Option<Option<String>>, + reporting_category: Option<Option<String>>, + timezone: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FinancialReportingFinanceReportRunRunParameters { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FinancialReportingFinanceReportRunRunParameters>, + builder: FinancialReportingFinanceReportRunRunParametersBuilder, + } + + impl Visitor for Place<FinancialReportingFinanceReportRunRunParameters> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FinancialReportingFinanceReportRunRunParametersBuilder::deser_default() })) + } + } + + impl MapBuilder for FinancialReportingFinanceReportRunRunParametersBuilder { + type Out = FinancialReportingFinanceReportRunRunParameters; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "columns" => Deserialize::begin(&mut self.columns), + "connected_account" => Deserialize::begin(&mut self.connected_account), + "currency" => Deserialize::begin(&mut self.currency), + "interval_end" => Deserialize::begin(&mut self.interval_end), + "interval_start" => Deserialize::begin(&mut self.interval_start), + "payout" => Deserialize::begin(&mut self.payout), + "reporting_category" => Deserialize::begin(&mut self.reporting_category), + "timezone" => Deserialize::begin(&mut self.timezone), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + columns: Deserialize::default(), + connected_account: Deserialize::default(), + currency: Deserialize::default(), + interval_end: Deserialize::default(), + interval_start: Deserialize::default(), + payout: Deserialize::default(), + reporting_category: Deserialize::default(), + timezone: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let columns = self.columns.take()?; + let connected_account = self.connected_account.take()?; + let currency = self.currency.take()?; + let interval_end = self.interval_end.take()?; + let interval_start = self.interval_start.take()?; + let payout = self.payout.take()?; + let reporting_category = self.reporting_category.take()?; + let timezone = self.timezone.take()?; + + Some(Self::Out { columns, connected_account, currency, interval_end, interval_start, payout, reporting_category, timezone }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FinancialReportingFinanceReportRunRunParameters { + type Builder = FinancialReportingFinanceReportRunRunParametersBuilder; + } + + impl FromValueOpt for FinancialReportingFinanceReportRunRunParameters { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FinancialReportingFinanceReportRunRunParametersBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "columns" => b.columns = Some(FromValueOpt::from_value(v)?), + "connected_account" => b.connected_account = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "interval_end" => b.interval_end = Some(FromValueOpt::from_value(v)?), + "interval_start" => b.interval_start = Some(FromValueOpt::from_value(v)?), + "payout" => b.payout = Some(FromValueOpt::from_value(v)?), + "reporting_category" => b.reporting_category = Some(FromValueOpt::from_value(v)?), + "timezone" => b.timezone = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_data_document_report_date_of_birth.rs b/generated/stripe_misc/src/gelato_data_document_report_date_of_birth.rs index 340c8ae4b..0adea12c5 100644 --- a/generated/stripe_misc/src/gelato_data_document_report_date_of_birth.rs +++ b/generated/stripe_misc/src/gelato_data_document_report_date_of_birth.rs @@ -1,5 +1,7 @@ /// Point in Time -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoDataDocumentReportDateOfBirth { /// Numerical day between 1 and 31. pub day: Option<i64>, @@ -8,3 +10,97 @@ pub struct GelatoDataDocumentReportDateOfBirth { /// The four-digit year. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct GelatoDataDocumentReportDateOfBirthBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoDataDocumentReportDateOfBirth { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoDataDocumentReportDateOfBirth>, + builder: GelatoDataDocumentReportDateOfBirthBuilder, + } + + impl Visitor for Place<GelatoDataDocumentReportDateOfBirth> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoDataDocumentReportDateOfBirthBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoDataDocumentReportDateOfBirthBuilder { + type Out = GelatoDataDocumentReportDateOfBirth; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoDataDocumentReportDateOfBirth { + type Builder = GelatoDataDocumentReportDateOfBirthBuilder; + } + + impl FromValueOpt for GelatoDataDocumentReportDateOfBirth { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoDataDocumentReportDateOfBirthBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_data_document_report_expiration_date.rs b/generated/stripe_misc/src/gelato_data_document_report_expiration_date.rs index a30a7654a..f20525cfb 100644 --- a/generated/stripe_misc/src/gelato_data_document_report_expiration_date.rs +++ b/generated/stripe_misc/src/gelato_data_document_report_expiration_date.rs @@ -1,5 +1,7 @@ /// Point in Time -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoDataDocumentReportExpirationDate { /// Numerical day between 1 and 31. pub day: Option<i64>, @@ -8,3 +10,97 @@ pub struct GelatoDataDocumentReportExpirationDate { /// The four-digit year. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct GelatoDataDocumentReportExpirationDateBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoDataDocumentReportExpirationDate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoDataDocumentReportExpirationDate>, + builder: GelatoDataDocumentReportExpirationDateBuilder, + } + + impl Visitor for Place<GelatoDataDocumentReportExpirationDate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoDataDocumentReportExpirationDateBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoDataDocumentReportExpirationDateBuilder { + type Out = GelatoDataDocumentReportExpirationDate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoDataDocumentReportExpirationDate { + type Builder = GelatoDataDocumentReportExpirationDateBuilder; + } + + impl FromValueOpt for GelatoDataDocumentReportExpirationDate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoDataDocumentReportExpirationDateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_data_document_report_issued_date.rs b/generated/stripe_misc/src/gelato_data_document_report_issued_date.rs index 950ee2a7e..40d1be2c8 100644 --- a/generated/stripe_misc/src/gelato_data_document_report_issued_date.rs +++ b/generated/stripe_misc/src/gelato_data_document_report_issued_date.rs @@ -1,5 +1,7 @@ /// Point in Time -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoDataDocumentReportIssuedDate { /// Numerical day between 1 and 31. pub day: Option<i64>, @@ -8,3 +10,97 @@ pub struct GelatoDataDocumentReportIssuedDate { /// The four-digit year. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct GelatoDataDocumentReportIssuedDateBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoDataDocumentReportIssuedDate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoDataDocumentReportIssuedDate>, + builder: GelatoDataDocumentReportIssuedDateBuilder, + } + + impl Visitor for Place<GelatoDataDocumentReportIssuedDate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoDataDocumentReportIssuedDateBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoDataDocumentReportIssuedDateBuilder { + type Out = GelatoDataDocumentReportIssuedDate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoDataDocumentReportIssuedDate { + type Builder = GelatoDataDocumentReportIssuedDateBuilder; + } + + impl FromValueOpt for GelatoDataDocumentReportIssuedDate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoDataDocumentReportIssuedDateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_data_id_number_report_date.rs b/generated/stripe_misc/src/gelato_data_id_number_report_date.rs index e7c4d2c8d..d5348e737 100644 --- a/generated/stripe_misc/src/gelato_data_id_number_report_date.rs +++ b/generated/stripe_misc/src/gelato_data_id_number_report_date.rs @@ -1,5 +1,7 @@ /// Point in Time -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoDataIdNumberReportDate { /// Numerical day between 1 and 31. pub day: Option<i64>, @@ -8,3 +10,97 @@ pub struct GelatoDataIdNumberReportDate { /// The four-digit year. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct GelatoDataIdNumberReportDateBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoDataIdNumberReportDate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoDataIdNumberReportDate>, + builder: GelatoDataIdNumberReportDateBuilder, + } + + impl Visitor for Place<GelatoDataIdNumberReportDate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoDataIdNumberReportDateBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoDataIdNumberReportDateBuilder { + type Out = GelatoDataIdNumberReportDate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoDataIdNumberReportDate { + type Builder = GelatoDataIdNumberReportDateBuilder; + } + + impl FromValueOpt for GelatoDataIdNumberReportDate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoDataIdNumberReportDateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_data_verified_outputs_date.rs b/generated/stripe_misc/src/gelato_data_verified_outputs_date.rs index 06b4a0298..a886be5ec 100644 --- a/generated/stripe_misc/src/gelato_data_verified_outputs_date.rs +++ b/generated/stripe_misc/src/gelato_data_verified_outputs_date.rs @@ -1,5 +1,7 @@ /// Point in Time -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoDataVerifiedOutputsDate { /// Numerical day between 1 and 31. pub day: Option<i64>, @@ -8,3 +10,97 @@ pub struct GelatoDataVerifiedOutputsDate { /// The four-digit year. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct GelatoDataVerifiedOutputsDateBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoDataVerifiedOutputsDate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoDataVerifiedOutputsDate>, + builder: GelatoDataVerifiedOutputsDateBuilder, + } + + impl Visitor for Place<GelatoDataVerifiedOutputsDate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoDataVerifiedOutputsDateBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoDataVerifiedOutputsDateBuilder { + type Out = GelatoDataVerifiedOutputsDate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoDataVerifiedOutputsDate { + type Builder = GelatoDataVerifiedOutputsDateBuilder; + } + + impl FromValueOpt for GelatoDataVerifiedOutputsDate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoDataVerifiedOutputsDateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_document_report.rs b/generated/stripe_misc/src/gelato_document_report.rs index f78555dfe..926e8bdd9 100644 --- a/generated/stripe_misc/src/gelato_document_report.rs +++ b/generated/stripe_misc/src/gelato_document_report.rs @@ -1,5 +1,7 @@ /// Result from a document check -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoDocumentReport { /// Address as it appears in the document. pub address: Option<stripe_shared::Address>, @@ -24,9 +26,152 @@ pub struct GelatoDocumentReport { /// Status of this `document` check. pub status: GelatoDocumentReportStatus, /// Type of the document. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<GelatoDocumentReportType>, } +#[cfg(feature = "min-ser")] +pub struct GelatoDocumentReportBuilder { + address: Option<Option<stripe_shared::Address>>, + dob: Option<Option<stripe_misc::GelatoDataDocumentReportDateOfBirth>>, + error: Option<Option<stripe_misc::GelatoDocumentReportError>>, + expiration_date: Option<Option<stripe_misc::GelatoDataDocumentReportExpirationDate>>, + files: Option<Option<Vec<String>>>, + first_name: Option<Option<String>>, + issued_date: Option<Option<stripe_misc::GelatoDataDocumentReportIssuedDate>>, + issuing_country: Option<Option<String>>, + last_name: Option<Option<String>>, + number: Option<Option<String>>, + status: Option<GelatoDocumentReportStatus>, + type_: Option<Option<GelatoDocumentReportType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoDocumentReport { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoDocumentReport>, + builder: GelatoDocumentReportBuilder, + } + + impl Visitor for Place<GelatoDocumentReport> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoDocumentReportBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoDocumentReportBuilder { + type Out = GelatoDocumentReport; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "dob" => Deserialize::begin(&mut self.dob), + "error" => Deserialize::begin(&mut self.error), + "expiration_date" => Deserialize::begin(&mut self.expiration_date), + "files" => Deserialize::begin(&mut self.files), + "first_name" => Deserialize::begin(&mut self.first_name), + "issued_date" => Deserialize::begin(&mut self.issued_date), + "issuing_country" => Deserialize::begin(&mut self.issuing_country), + "last_name" => Deserialize::begin(&mut self.last_name), + "number" => Deserialize::begin(&mut self.number), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + dob: Deserialize::default(), + error: Deserialize::default(), + expiration_date: Deserialize::default(), + files: Deserialize::default(), + first_name: Deserialize::default(), + issued_date: Deserialize::default(), + issuing_country: Deserialize::default(), + last_name: Deserialize::default(), + number: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let dob = self.dob.take()?; + let error = self.error.take()?; + let expiration_date = self.expiration_date.take()?; + let files = self.files.take()?; + let first_name = self.first_name.take()?; + let issued_date = self.issued_date.take()?; + let issuing_country = self.issuing_country.take()?; + let last_name = self.last_name.take()?; + let number = self.number.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { address, dob, error, expiration_date, files, first_name, issued_date, issuing_country, last_name, number, status, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoDocumentReport { + type Builder = GelatoDocumentReportBuilder; + } + + impl FromValueOpt for GelatoDocumentReport { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoDocumentReportBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "dob" => b.dob = Some(FromValueOpt::from_value(v)?), + "error" => b.error = Some(FromValueOpt::from_value(v)?), + "expiration_date" => b.expiration_date = Some(FromValueOpt::from_value(v)?), + "files" => b.files = Some(FromValueOpt::from_value(v)?), + "first_name" => b.first_name = Some(FromValueOpt::from_value(v)?), + "issued_date" => b.issued_date = Some(FromValueOpt::from_value(v)?), + "issuing_country" => b.issuing_country = Some(FromValueOpt::from_value(v)?), + "last_name" => b.last_name = Some(FromValueOpt::from_value(v)?), + "number" => b.number = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Status of this `document` check. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoDocumentReportStatus { @@ -77,10 +222,27 @@ impl<'de> serde::Deserialize<'de> for GelatoDocumentReportStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for GelatoDocumentReportStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoDocumentReportStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoDocumentReportStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoDocumentReportStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoDocumentReportStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportStatus); /// Type of the document. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoDocumentReportType { @@ -134,7 +296,24 @@ impl<'de> serde::Deserialize<'de> for GelatoDocumentReportType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for GelatoDocumentReportType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoDocumentReportType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoDocumentReportType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoDocumentReportType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoDocumentReportType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportType); diff --git a/generated/stripe_misc/src/gelato_document_report_error.rs b/generated/stripe_misc/src/gelato_document_report_error.rs index cb6845bcf..e9b618d57 100644 --- a/generated/stripe_misc/src/gelato_document_report_error.rs +++ b/generated/stripe_misc/src/gelato_document_report_error.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoDocumentReportError { /// A short machine-readable string giving the reason for the verification failure. pub code: Option<GelatoDocumentReportErrorCode>, @@ -6,6 +8,96 @@ pub struct GelatoDocumentReportError { /// These messages can be shown to your users. pub reason: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct GelatoDocumentReportErrorBuilder { + code: Option<Option<GelatoDocumentReportErrorCode>>, + reason: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoDocumentReportError { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoDocumentReportError>, + builder: GelatoDocumentReportErrorBuilder, + } + + impl Visitor for Place<GelatoDocumentReportError> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoDocumentReportErrorBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoDocumentReportErrorBuilder { + type Out = GelatoDocumentReportError; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "reason" => Deserialize::begin(&mut self.reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let reason = self.reason.take()?; + + Some(Self::Out { code, reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoDocumentReportError { + type Builder = GelatoDocumentReportErrorBuilder; + } + + impl FromValueOpt for GelatoDocumentReportError { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoDocumentReportErrorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A short machine-readable string giving the reason for the verification failure. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoDocumentReportErrorCode { @@ -59,8 +151,24 @@ impl<'de> serde::Deserialize<'de> for GelatoDocumentReportErrorCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for GelatoDocumentReportErrorCode") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoDocumentReportErrorCode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoDocumentReportErrorCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoDocumentReportErrorCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoDocumentReportErrorCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportErrorCode); diff --git a/generated/stripe_misc/src/gelato_id_number_report.rs b/generated/stripe_misc/src/gelato_id_number_report.rs index 9f0a3bbeb..8501b6003 100644 --- a/generated/stripe_misc/src/gelato_id_number_report.rs +++ b/generated/stripe_misc/src/gelato_id_number_report.rs @@ -1,5 +1,7 @@ /// Result from an id_number check -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoIdNumberReport { /// Date of birth. pub dob: Option<stripe_misc::GelatoDataIdNumberReportDate>, @@ -7,7 +9,7 @@ pub struct GelatoIdNumberReport { pub error: Option<stripe_misc::GelatoIdNumberReportError>, /// First name. pub first_name: Option<String>, - /// ID number. When `id_number_type` is `us_ssn`, only the last 4 digits are present. + /// ID number. pub id_number: Option<String>, /// Type of ID number. pub id_number_type: Option<GelatoIdNumberReportIdNumberType>, @@ -16,6 +18,124 @@ pub struct GelatoIdNumberReport { /// Status of this `id_number` check. pub status: GelatoIdNumberReportStatus, } +#[cfg(feature = "min-ser")] +pub struct GelatoIdNumberReportBuilder { + dob: Option<Option<stripe_misc::GelatoDataIdNumberReportDate>>, + error: Option<Option<stripe_misc::GelatoIdNumberReportError>>, + first_name: Option<Option<String>>, + id_number: Option<Option<String>>, + id_number_type: Option<Option<GelatoIdNumberReportIdNumberType>>, + last_name: Option<Option<String>>, + status: Option<GelatoIdNumberReportStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoIdNumberReport { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoIdNumberReport>, + builder: GelatoIdNumberReportBuilder, + } + + impl Visitor for Place<GelatoIdNumberReport> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoIdNumberReportBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoIdNumberReportBuilder { + type Out = GelatoIdNumberReport; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "dob" => Deserialize::begin(&mut self.dob), + "error" => Deserialize::begin(&mut self.error), + "first_name" => Deserialize::begin(&mut self.first_name), + "id_number" => Deserialize::begin(&mut self.id_number), + "id_number_type" => Deserialize::begin(&mut self.id_number_type), + "last_name" => Deserialize::begin(&mut self.last_name), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + dob: Deserialize::default(), + error: Deserialize::default(), + first_name: Deserialize::default(), + id_number: Deserialize::default(), + id_number_type: Deserialize::default(), + last_name: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let dob = self.dob.take()?; + let error = self.error.take()?; + let first_name = self.first_name.take()?; + let id_number = self.id_number.take()?; + let id_number_type = self.id_number_type.take()?; + let last_name = self.last_name.take()?; + let status = self.status.take()?; + + Some(Self::Out { dob, error, first_name, id_number, id_number_type, last_name, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoIdNumberReport { + type Builder = GelatoIdNumberReportBuilder; + } + + impl FromValueOpt for GelatoIdNumberReport { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoIdNumberReportBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "dob" => b.dob = Some(FromValueOpt::from_value(v)?), + "error" => b.error = Some(FromValueOpt::from_value(v)?), + "first_name" => b.first_name = Some(FromValueOpt::from_value(v)?), + "id_number" => b.id_number = Some(FromValueOpt::from_value(v)?), + "id_number_type" => b.id_number_type = Some(FromValueOpt::from_value(v)?), + "last_name" => b.last_name = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of ID number. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoIdNumberReportIdNumberType { @@ -69,11 +189,27 @@ impl<'de> serde::Deserialize<'de> for GelatoIdNumberReportIdNumberType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for GelatoIdNumberReportIdNumberType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoIdNumberReportIdNumberType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoIdNumberReportIdNumberType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoIdNumberReportIdNumberType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoIdNumberReportIdNumberType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoIdNumberReportIdNumberType); /// Status of this `id_number` check. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoIdNumberReportStatus { @@ -124,7 +260,24 @@ impl<'de> serde::Deserialize<'de> for GelatoIdNumberReportStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for GelatoIdNumberReportStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoIdNumberReportStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoIdNumberReportStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoIdNumberReportStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoIdNumberReportStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoIdNumberReportStatus); diff --git a/generated/stripe_misc/src/gelato_id_number_report_error.rs b/generated/stripe_misc/src/gelato_id_number_report_error.rs index 409b95f04..a60d79b7b 100644 --- a/generated/stripe_misc/src/gelato_id_number_report_error.rs +++ b/generated/stripe_misc/src/gelato_id_number_report_error.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoIdNumberReportError { /// A short machine-readable string giving the reason for the verification failure. pub code: Option<GelatoIdNumberReportErrorCode>, @@ -6,6 +8,96 @@ pub struct GelatoIdNumberReportError { /// These messages can be shown to your users. pub reason: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct GelatoIdNumberReportErrorBuilder { + code: Option<Option<GelatoIdNumberReportErrorCode>>, + reason: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoIdNumberReportError { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoIdNumberReportError>, + builder: GelatoIdNumberReportErrorBuilder, + } + + impl Visitor for Place<GelatoIdNumberReportError> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoIdNumberReportErrorBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoIdNumberReportErrorBuilder { + type Out = GelatoIdNumberReportError; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "reason" => Deserialize::begin(&mut self.reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let reason = self.reason.take()?; + + Some(Self::Out { code, reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoIdNumberReportError { + type Builder = GelatoIdNumberReportErrorBuilder; + } + + impl FromValueOpt for GelatoIdNumberReportError { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoIdNumberReportErrorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A short machine-readable string giving the reason for the verification failure. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoIdNumberReportErrorCode { @@ -59,8 +151,24 @@ impl<'de> serde::Deserialize<'de> for GelatoIdNumberReportErrorCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for GelatoIdNumberReportErrorCode") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoIdNumberReportErrorCode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoIdNumberReportErrorCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoIdNumberReportErrorCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoIdNumberReportErrorCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoIdNumberReportErrorCode); diff --git a/generated/stripe_misc/src/gelato_report_document_options.rs b/generated/stripe_misc/src/gelato_report_document_options.rs index d64cf9535..c4fc09236 100644 --- a/generated/stripe_misc/src/gelato_report_document_options.rs +++ b/generated/stripe_misc/src/gelato_report_document_options.rs @@ -1,20 +1,116 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoReportDocumentOptions { /// Array of strings of allowed identity document types. /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code. - #[serde(skip_serializing_if = "Option::is_none")] pub allowed_types: Option<Vec<GelatoReportDocumentOptionsAllowedTypes>>, /// Collect an ID number and perform an [ID number check](https://stripe.com/docs/identity/verification-checks?type=id-number) with the document’s extracted name and date of birth. - #[serde(skip_serializing_if = "Option::is_none")] pub require_id_number: Option<bool>, /// Disable image uploads, identity document images have to be captured using the device’s camera. - #[serde(skip_serializing_if = "Option::is_none")] pub require_live_capture: Option<bool>, /// Capture a face image and perform a [selfie check](https://stripe.com/docs/identity/verification-checks?type=selfie) comparing a photo ID and a picture of your user’s face. /// [Learn more](https://stripe.com/docs/identity/selfie). - #[serde(skip_serializing_if = "Option::is_none")] pub require_matching_selfie: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct GelatoReportDocumentOptionsBuilder { + allowed_types: Option<Option<Vec<GelatoReportDocumentOptionsAllowedTypes>>>, + require_id_number: Option<Option<bool>>, + require_live_capture: Option<Option<bool>>, + require_matching_selfie: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoReportDocumentOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoReportDocumentOptions>, + builder: GelatoReportDocumentOptionsBuilder, + } + + impl Visitor for Place<GelatoReportDocumentOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoReportDocumentOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoReportDocumentOptionsBuilder { + type Out = GelatoReportDocumentOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allowed_types" => Deserialize::begin(&mut self.allowed_types), + "require_id_number" => Deserialize::begin(&mut self.require_id_number), + "require_live_capture" => Deserialize::begin(&mut self.require_live_capture), + "require_matching_selfie" => Deserialize::begin(&mut self.require_matching_selfie), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_types: Deserialize::default(), require_id_number: Deserialize::default(), require_live_capture: Deserialize::default(), require_matching_selfie: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allowed_types = self.allowed_types.take()?; + let require_id_number = self.require_id_number.take()?; + let require_live_capture = self.require_live_capture.take()?; + let require_matching_selfie = self.require_matching_selfie.take()?; + + Some(Self::Out { allowed_types, require_id_number, require_live_capture, require_matching_selfie }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoReportDocumentOptions { + type Builder = GelatoReportDocumentOptionsBuilder; + } + + impl FromValueOpt for GelatoReportDocumentOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoReportDocumentOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allowed_types" => b.allowed_types = Some(FromValueOpt::from_value(v)?), + "require_id_number" => b.require_id_number = Some(FromValueOpt::from_value(v)?), + "require_live_capture" => b.require_live_capture = Some(FromValueOpt::from_value(v)?), + "require_matching_selfie" => b.require_matching_selfie = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Array of strings of allowed identity document types. /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code. #[derive(Copy, Clone, Eq, PartialEq)] @@ -69,8 +165,24 @@ impl<'de> serde::Deserialize<'de> for GelatoReportDocumentOptionsAllowedTypes { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for GelatoReportDocumentOptionsAllowedTypes") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoReportDocumentOptionsAllowedTypes")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoReportDocumentOptionsAllowedTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoReportDocumentOptionsAllowedTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoReportDocumentOptionsAllowedTypes::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoReportDocumentOptionsAllowedTypes); diff --git a/generated/stripe_misc/src/gelato_report_id_number_options.rs b/generated/stripe_misc/src/gelato_report_id_number_options.rs index 469d8e9a1..032e83965 100644 --- a/generated/stripe_misc/src/gelato_report_id_number_options.rs +++ b/generated/stripe_misc/src/gelato_report_id_number_options.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoReportIdNumberOptions {} +#[cfg(feature = "min-ser")] +pub struct GelatoReportIdNumberOptionsBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoReportIdNumberOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoReportIdNumberOptions>, + builder: GelatoReportIdNumberOptionsBuilder, + } + + impl Visitor for Place<GelatoReportIdNumberOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoReportIdNumberOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoReportIdNumberOptionsBuilder { + type Out = GelatoReportIdNumberOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoReportIdNumberOptions { + type Builder = GelatoReportIdNumberOptionsBuilder; + } + + impl FromValueOpt for GelatoReportIdNumberOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoReportIdNumberOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_selfie_report.rs b/generated/stripe_misc/src/gelato_selfie_report.rs index d6d7ed27b..08e7fd8be 100644 --- a/generated/stripe_misc/src/gelato_selfie_report.rs +++ b/generated/stripe_misc/src/gelato_selfie_report.rs @@ -1,5 +1,7 @@ /// Result from a selfie check -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoSelfieReport { /// ID of the [File](https://stripe.com/docs/api/files) holding the image of the identity document used in this check. pub document: Option<String>, @@ -10,6 +12,104 @@ pub struct GelatoSelfieReport { /// Status of this `selfie` check. pub status: GelatoSelfieReportStatus, } +#[cfg(feature = "min-ser")] +pub struct GelatoSelfieReportBuilder { + document: Option<Option<String>>, + error: Option<Option<stripe_misc::GelatoSelfieReportError>>, + selfie: Option<Option<String>>, + status: Option<GelatoSelfieReportStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoSelfieReport { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoSelfieReport>, + builder: GelatoSelfieReportBuilder, + } + + impl Visitor for Place<GelatoSelfieReport> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoSelfieReportBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoSelfieReportBuilder { + type Out = GelatoSelfieReport; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "document" => Deserialize::begin(&mut self.document), + "error" => Deserialize::begin(&mut self.error), + "selfie" => Deserialize::begin(&mut self.selfie), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default(), error: Deserialize::default(), selfie: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let document = self.document.take()?; + let error = self.error.take()?; + let selfie = self.selfie.take()?; + let status = self.status.take()?; + + Some(Self::Out { document, error, selfie, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoSelfieReport { + type Builder = GelatoSelfieReportBuilder; + } + + impl FromValueOpt for GelatoSelfieReport { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoSelfieReportBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "document" => b.document = Some(FromValueOpt::from_value(v)?), + "error" => b.error = Some(FromValueOpt::from_value(v)?), + "selfie" => b.selfie = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Status of this `selfie` check. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoSelfieReportStatus { @@ -60,7 +160,24 @@ impl<'de> serde::Deserialize<'de> for GelatoSelfieReportStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for GelatoSelfieReportStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoSelfieReportStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoSelfieReportStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoSelfieReportStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoSelfieReportStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoSelfieReportStatus); diff --git a/generated/stripe_misc/src/gelato_selfie_report_error.rs b/generated/stripe_misc/src/gelato_selfie_report_error.rs index 068e3dd79..0f79a051a 100644 --- a/generated/stripe_misc/src/gelato_selfie_report_error.rs +++ b/generated/stripe_misc/src/gelato_selfie_report_error.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoSelfieReportError { /// A short machine-readable string giving the reason for the verification failure. pub code: Option<GelatoSelfieReportErrorCode>, @@ -6,6 +8,96 @@ pub struct GelatoSelfieReportError { /// These messages can be shown to your users. pub reason: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct GelatoSelfieReportErrorBuilder { + code: Option<Option<GelatoSelfieReportErrorCode>>, + reason: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoSelfieReportError { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoSelfieReportError>, + builder: GelatoSelfieReportErrorBuilder, + } + + impl Visitor for Place<GelatoSelfieReportError> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoSelfieReportErrorBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoSelfieReportErrorBuilder { + type Out = GelatoSelfieReportError; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "reason" => Deserialize::begin(&mut self.reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let reason = self.reason.take()?; + + Some(Self::Out { code, reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoSelfieReportError { + type Builder = GelatoSelfieReportErrorBuilder; + } + + impl FromValueOpt for GelatoSelfieReportError { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoSelfieReportErrorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A short machine-readable string giving the reason for the verification failure. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoSelfieReportErrorCode { @@ -62,7 +154,24 @@ impl<'de> serde::Deserialize<'de> for GelatoSelfieReportErrorCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for GelatoSelfieReportErrorCode")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoSelfieReportErrorCode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoSelfieReportErrorCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoSelfieReportErrorCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoSelfieReportErrorCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoSelfieReportErrorCode); diff --git a/generated/stripe_misc/src/gelato_session_document_options.rs b/generated/stripe_misc/src/gelato_session_document_options.rs index ca96e161a..06798aeb9 100644 --- a/generated/stripe_misc/src/gelato_session_document_options.rs +++ b/generated/stripe_misc/src/gelato_session_document_options.rs @@ -1,20 +1,116 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoSessionDocumentOptions { /// Array of strings of allowed identity document types. /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code. - #[serde(skip_serializing_if = "Option::is_none")] pub allowed_types: Option<Vec<GelatoSessionDocumentOptionsAllowedTypes>>, /// Collect an ID number and perform an [ID number check](https://stripe.com/docs/identity/verification-checks?type=id-number) with the document’s extracted name and date of birth. - #[serde(skip_serializing_if = "Option::is_none")] pub require_id_number: Option<bool>, /// Disable image uploads, identity document images have to be captured using the device’s camera. - #[serde(skip_serializing_if = "Option::is_none")] pub require_live_capture: Option<bool>, /// Capture a face image and perform a [selfie check](https://stripe.com/docs/identity/verification-checks?type=selfie) comparing a photo ID and a picture of your user’s face. /// [Learn more](https://stripe.com/docs/identity/selfie). - #[serde(skip_serializing_if = "Option::is_none")] pub require_matching_selfie: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct GelatoSessionDocumentOptionsBuilder { + allowed_types: Option<Option<Vec<GelatoSessionDocumentOptionsAllowedTypes>>>, + require_id_number: Option<Option<bool>>, + require_live_capture: Option<Option<bool>>, + require_matching_selfie: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoSessionDocumentOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoSessionDocumentOptions>, + builder: GelatoSessionDocumentOptionsBuilder, + } + + impl Visitor for Place<GelatoSessionDocumentOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoSessionDocumentOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoSessionDocumentOptionsBuilder { + type Out = GelatoSessionDocumentOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allowed_types" => Deserialize::begin(&mut self.allowed_types), + "require_id_number" => Deserialize::begin(&mut self.require_id_number), + "require_live_capture" => Deserialize::begin(&mut self.require_live_capture), + "require_matching_selfie" => Deserialize::begin(&mut self.require_matching_selfie), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_types: Deserialize::default(), require_id_number: Deserialize::default(), require_live_capture: Deserialize::default(), require_matching_selfie: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allowed_types = self.allowed_types.take()?; + let require_id_number = self.require_id_number.take()?; + let require_live_capture = self.require_live_capture.take()?; + let require_matching_selfie = self.require_matching_selfie.take()?; + + Some(Self::Out { allowed_types, require_id_number, require_live_capture, require_matching_selfie }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoSessionDocumentOptions { + type Builder = GelatoSessionDocumentOptionsBuilder; + } + + impl FromValueOpt for GelatoSessionDocumentOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoSessionDocumentOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allowed_types" => b.allowed_types = Some(FromValueOpt::from_value(v)?), + "require_id_number" => b.require_id_number = Some(FromValueOpt::from_value(v)?), + "require_live_capture" => b.require_live_capture = Some(FromValueOpt::from_value(v)?), + "require_matching_selfie" => b.require_matching_selfie = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Array of strings of allowed identity document types. /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code. #[derive(Copy, Clone, Eq, PartialEq)] @@ -69,8 +165,24 @@ impl<'de> serde::Deserialize<'de> for GelatoSessionDocumentOptionsAllowedTypes { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for GelatoSessionDocumentOptionsAllowedTypes") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoSessionDocumentOptionsAllowedTypes")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoSessionDocumentOptionsAllowedTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoSessionDocumentOptionsAllowedTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoSessionDocumentOptionsAllowedTypes::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoSessionDocumentOptionsAllowedTypes); diff --git a/generated/stripe_misc/src/gelato_session_id_number_options.rs b/generated/stripe_misc/src/gelato_session_id_number_options.rs index 2e402a477..2a533d47e 100644 --- a/generated/stripe_misc/src/gelato_session_id_number_options.rs +++ b/generated/stripe_misc/src/gelato_session_id_number_options.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoSessionIdNumberOptions {} +#[cfg(feature = "min-ser")] +pub struct GelatoSessionIdNumberOptionsBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoSessionIdNumberOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoSessionIdNumberOptions>, + builder: GelatoSessionIdNumberOptionsBuilder, + } + + impl Visitor for Place<GelatoSessionIdNumberOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoSessionIdNumberOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoSessionIdNumberOptionsBuilder { + type Out = GelatoSessionIdNumberOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoSessionIdNumberOptions { + type Builder = GelatoSessionIdNumberOptionsBuilder; + } + + impl FromValueOpt for GelatoSessionIdNumberOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoSessionIdNumberOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_session_last_error.rs b/generated/stripe_misc/src/gelato_session_last_error.rs index bc2802fa4..a08207aae 100644 --- a/generated/stripe_misc/src/gelato_session_last_error.rs +++ b/generated/stripe_misc/src/gelato_session_last_error.rs @@ -1,11 +1,103 @@ /// Shows last VerificationSession error -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoSessionLastError { /// A short machine-readable string giving the reason for the verification or user-session failure. pub code: Option<GelatoSessionLastErrorCode>, /// A message that explains the reason for verification or user-session failure. pub reason: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct GelatoSessionLastErrorBuilder { + code: Option<Option<GelatoSessionLastErrorCode>>, + reason: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoSessionLastError { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoSessionLastError>, + builder: GelatoSessionLastErrorBuilder, + } + + impl Visitor for Place<GelatoSessionLastError> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoSessionLastErrorBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoSessionLastErrorBuilder { + type Out = GelatoSessionLastError; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "reason" => Deserialize::begin(&mut self.reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let reason = self.reason.take()?; + + Some(Self::Out { code, reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoSessionLastError { + type Builder = GelatoSessionLastErrorBuilder; + } + + impl FromValueOpt for GelatoSessionLastError { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoSessionLastErrorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A short machine-readable string giving the reason for the verification or user-session failure. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -99,6 +191,24 @@ impl<'de> serde::Deserialize<'de> for GelatoSessionLastErrorCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(GelatoSessionLastErrorCode::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoSessionLastErrorCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoSessionLastErrorCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoSessionLastErrorCode::from_str(s).unwrap_or(GelatoSessionLastErrorCode::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoSessionLastErrorCode); diff --git a/generated/stripe_misc/src/gelato_verification_report_options.rs b/generated/stripe_misc/src/gelato_verification_report_options.rs index 84bb33614..b4b2b3d0b 100644 --- a/generated/stripe_misc/src/gelato_verification_report_options.rs +++ b/generated/stripe_misc/src/gelato_verification_report_options.rs @@ -1,7 +1,97 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoVerificationReportOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub document: Option<stripe_misc::GelatoReportDocumentOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub id_number: Option<stripe_misc::GelatoReportIdNumberOptions>, } +#[cfg(feature = "min-ser")] +pub struct GelatoVerificationReportOptionsBuilder { + document: Option<Option<stripe_misc::GelatoReportDocumentOptions>>, + id_number: Option<Option<stripe_misc::GelatoReportIdNumberOptions>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoVerificationReportOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoVerificationReportOptions>, + builder: GelatoVerificationReportOptionsBuilder, + } + + impl Visitor for Place<GelatoVerificationReportOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoVerificationReportOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoVerificationReportOptionsBuilder { + type Out = GelatoVerificationReportOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "document" => Deserialize::begin(&mut self.document), + "id_number" => Deserialize::begin(&mut self.id_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default(), id_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let document = self.document.take()?; + let id_number = self.id_number.take()?; + + Some(Self::Out { document, id_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoVerificationReportOptions { + type Builder = GelatoVerificationReportOptionsBuilder; + } + + impl FromValueOpt for GelatoVerificationReportOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoVerificationReportOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "document" => b.document = Some(FromValueOpt::from_value(v)?), + "id_number" => b.id_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_verification_session_options.rs b/generated/stripe_misc/src/gelato_verification_session_options.rs index fdce179be..f5cbb3dad 100644 --- a/generated/stripe_misc/src/gelato_verification_session_options.rs +++ b/generated/stripe_misc/src/gelato_verification_session_options.rs @@ -1,7 +1,97 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoVerificationSessionOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub document: Option<stripe_misc::GelatoSessionDocumentOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub id_number: Option<stripe_misc::GelatoSessionIdNumberOptions>, } +#[cfg(feature = "min-ser")] +pub struct GelatoVerificationSessionOptionsBuilder { + document: Option<Option<stripe_misc::GelatoSessionDocumentOptions>>, + id_number: Option<Option<stripe_misc::GelatoSessionIdNumberOptions>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoVerificationSessionOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoVerificationSessionOptions>, + builder: GelatoVerificationSessionOptionsBuilder, + } + + impl Visitor for Place<GelatoVerificationSessionOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoVerificationSessionOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoVerificationSessionOptionsBuilder { + type Out = GelatoVerificationSessionOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "document" => Deserialize::begin(&mut self.document), + "id_number" => Deserialize::begin(&mut self.id_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default(), id_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let document = self.document.take()?; + let id_number = self.id_number.take()?; + + Some(Self::Out { document, id_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoVerificationSessionOptions { + type Builder = GelatoVerificationSessionOptionsBuilder; + } + + impl FromValueOpt for GelatoVerificationSessionOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoVerificationSessionOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "document" => b.document = Some(FromValueOpt::from_value(v)?), + "id_number" => b.id_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/gelato_verified_outputs.rs b/generated/stripe_misc/src/gelato_verified_outputs.rs index 74d0960aa..4b54a9fd6 100644 --- a/generated/stripe_misc/src/gelato_verified_outputs.rs +++ b/generated/stripe_misc/src/gelato_verified_outputs.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct GelatoVerifiedOutputs { /// The user's verified address. pub address: Option<stripe_shared::Address>, @@ -13,6 +15,119 @@ pub struct GelatoVerifiedOutputs { /// The user's verified last name. pub last_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct GelatoVerifiedOutputsBuilder { + address: Option<Option<stripe_shared::Address>>, + dob: Option<Option<stripe_misc::GelatoDataVerifiedOutputsDate>>, + first_name: Option<Option<String>>, + id_number: Option<Option<String>>, + id_number_type: Option<Option<GelatoVerifiedOutputsIdNumberType>>, + last_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for GelatoVerifiedOutputs { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<GelatoVerifiedOutputs>, + builder: GelatoVerifiedOutputsBuilder, + } + + impl Visitor for Place<GelatoVerifiedOutputs> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: GelatoVerifiedOutputsBuilder::deser_default() })) + } + } + + impl MapBuilder for GelatoVerifiedOutputsBuilder { + type Out = GelatoVerifiedOutputs; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "dob" => Deserialize::begin(&mut self.dob), + "first_name" => Deserialize::begin(&mut self.first_name), + "id_number" => Deserialize::begin(&mut self.id_number), + "id_number_type" => Deserialize::begin(&mut self.id_number_type), + "last_name" => Deserialize::begin(&mut self.last_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + dob: Deserialize::default(), + first_name: Deserialize::default(), + id_number: Deserialize::default(), + id_number_type: Deserialize::default(), + last_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let dob = self.dob.take()?; + let first_name = self.first_name.take()?; + let id_number = self.id_number.take()?; + let id_number_type = self.id_number_type.take()?; + let last_name = self.last_name.take()?; + + Some(Self::Out { address, dob, first_name, id_number, id_number_type, last_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for GelatoVerifiedOutputs { + type Builder = GelatoVerifiedOutputsBuilder; + } + + impl FromValueOpt for GelatoVerifiedOutputs { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = GelatoVerifiedOutputsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "dob" => b.dob = Some(FromValueOpt::from_value(v)?), + "first_name" => b.first_name = Some(FromValueOpt::from_value(v)?), + "id_number" => b.id_number = Some(FromValueOpt::from_value(v)?), + "id_number_type" => b.id_number_type = Some(FromValueOpt::from_value(v)?), + "last_name" => b.last_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The user's verified id number type. #[derive(Copy, Clone, Eq, PartialEq)] pub enum GelatoVerifiedOutputsIdNumberType { @@ -66,8 +181,24 @@ impl<'de> serde::Deserialize<'de> for GelatoVerifiedOutputsIdNumberType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for GelatoVerifiedOutputsIdNumberType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for GelatoVerifiedOutputsIdNumberType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for GelatoVerifiedOutputsIdNumberType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<GelatoVerifiedOutputsIdNumberType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoVerifiedOutputsIdNumberType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(GelatoVerifiedOutputsIdNumberType); diff --git a/generated/stripe_misc/src/identity_verification_report/requests.rs b/generated/stripe_misc/src/identity_verification_report/requests.rs index 3e4b46c2b..8bc17a42e 100644 --- a/generated/stripe_misc/src/identity_verification_report/requests.rs +++ b/generated/stripe_misc/src/identity_verification_report/requests.rs @@ -1,4 +1,21 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveIdentityVerificationReport<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveIdentityVerificationReport<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveIdentityVerificationReport<'a> { + /// Retrieves an existing VerificationReport + pub fn send(&self, client: &stripe::Client, report: &stripe_misc::IdentityVerificationReportId) -> stripe::Response<stripe_misc::IdentityVerificationReport> { + client.get_query(&format!("/identity/verification_reports/{report}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListIdentityVerificationReport<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub created: Option<stripe_types::RangeQueryTs>, @@ -20,7 +37,7 @@ pub struct ListIdentityVerificationReport<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, /// Only return VerificationReports of this type - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_misc::IdentityVerificationReportType>, /// Only return VerificationReports created by this VerificationSession ID. @@ -35,36 +52,10 @@ impl<'a> ListIdentityVerificationReport<'a> { } impl<'a> ListIdentityVerificationReport<'a> { /// List all verification reports. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::IdentityVerificationReport>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::IdentityVerificationReport>> { client.get_query("/identity/verification_reports", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::IdentityVerificationReport>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::IdentityVerificationReport>> { stripe::ListPaginator::from_list_params("/identity/verification_reports", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveIdentityVerificationReport<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveIdentityVerificationReport<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveIdentityVerificationReport<'a> { - /// Retrieves an existing VerificationReport - pub fn send( - &self, - client: &stripe::Client, - report: &stripe_misc::IdentityVerificationReportId, - ) -> stripe::Response<stripe_misc::IdentityVerificationReport> { - client.get_query(&format!("/identity/verification_reports/{report}"), self) - } -} diff --git a/generated/stripe_misc/src/identity_verification_report/types.rs b/generated/stripe_misc/src/identity_verification_report/types.rs index b2d14646d..911ac3316 100644 --- a/generated/stripe_misc/src/identity_verification_report/types.rs +++ b/generated/stripe_misc/src/identity_verification_report/types.rs @@ -11,29 +11,154 @@ /// Related guides: [Accessing verification results](https://stripe.com/docs/identity/verification-sessions#results). /// /// For more details see <<https://stripe.com/docs/api/identity/verification_reports/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IdentityVerificationReport { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, - #[serde(skip_serializing_if = "Option::is_none")] pub document: Option<stripe_misc::GelatoDocumentReport>, /// Unique identifier for the object. pub id: stripe_misc::IdentityVerificationReportId, - #[serde(skip_serializing_if = "Option::is_none")] pub id_number: Option<stripe_misc::GelatoIdNumberReport>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub options: Option<stripe_misc::GelatoVerificationReportOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub selfie: Option<stripe_misc::GelatoSelfieReport>, /// Type of report. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<stripe_misc::IdentityVerificationReportType>, /// ID of the VerificationSession that created this report. pub verification_session: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IdentityVerificationReportBuilder { + created: Option<stripe_types::Timestamp>, + document: Option<Option<stripe_misc::GelatoDocumentReport>>, + id: Option<stripe_misc::IdentityVerificationReportId>, + id_number: Option<Option<stripe_misc::GelatoIdNumberReport>>, + livemode: Option<bool>, + options: Option<Option<stripe_misc::GelatoVerificationReportOptions>>, + selfie: Option<Option<stripe_misc::GelatoSelfieReport>>, + type_: Option<Option<stripe_misc::IdentityVerificationReportType>>, + verification_session: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IdentityVerificationReport { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IdentityVerificationReport>, + builder: IdentityVerificationReportBuilder, + } + + impl Visitor for Place<IdentityVerificationReport> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IdentityVerificationReportBuilder::deser_default() })) + } + } + + impl MapBuilder for IdentityVerificationReportBuilder { + type Out = IdentityVerificationReport; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "document" => Deserialize::begin(&mut self.document), + "id" => Deserialize::begin(&mut self.id), + "id_number" => Deserialize::begin(&mut self.id_number), + "livemode" => Deserialize::begin(&mut self.livemode), + "options" => Deserialize::begin(&mut self.options), + "selfie" => Deserialize::begin(&mut self.selfie), + "type" => Deserialize::begin(&mut self.type_), + "verification_session" => Deserialize::begin(&mut self.verification_session), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + document: Deserialize::default(), + id: Deserialize::default(), + id_number: Deserialize::default(), + livemode: Deserialize::default(), + options: Deserialize::default(), + selfie: Deserialize::default(), + type_: Deserialize::default(), + verification_session: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let document = self.document.take()?; + let id = self.id.take()?; + let id_number = self.id_number.take()?; + let livemode = self.livemode.take()?; + let options = self.options.take()?; + let selfie = self.selfie.take()?; + let type_ = self.type_.take()?; + let verification_session = self.verification_session.take()?; + + Some(Self::Out { created, document, id, id_number, livemode, options, selfie, type_, verification_session }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IdentityVerificationReport { + type Builder = IdentityVerificationReportBuilder; + } + + impl FromValueOpt for IdentityVerificationReport { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IdentityVerificationReportBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "document" => b.document = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "id_number" => b.id_number = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "options" => b.options = Some(FromValueOpt::from_value(v)?), + "selfie" => b.selfie = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "verification_session" => b.verification_session = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for IdentityVerificationReport { type Id = stripe_misc::IdentityVerificationReportId; fn id(&self) -> &Self::Id { @@ -90,8 +215,24 @@ impl<'de> serde::Deserialize<'de> for IdentityVerificationReportType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IdentityVerificationReportType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IdentityVerificationReportType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IdentityVerificationReportType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IdentityVerificationReportType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IdentityVerificationReportType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IdentityVerificationReportType); diff --git a/generated/stripe_misc/src/identity_verification_session/requests.rs b/generated/stripe_misc/src/identity_verification_session/requests.rs index efbfed561..7b057e473 100644 --- a/generated/stripe_misc/src/identity_verification_session/requests.rs +++ b/generated/stripe_misc/src/identity_verification_session/requests.rs @@ -1,72 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListIdentityVerificationSession<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// Only return VerificationSessions with this status. - /// [Learn more about the lifecycle of sessions](https://stripe.com/docs/identity/how-sessions-work). - #[serde(skip_serializing_if = "Option::is_none")] - pub status: Option<stripe_misc::IdentityVerificationSessionStatus>, -} -impl<'a> ListIdentityVerificationSession<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListIdentityVerificationSession<'a> { - /// Returns a list of VerificationSessions - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::IdentityVerificationSession>> { - client.get_query("/identity/verification_sessions", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::IdentityVerificationSession>> { - stripe::ListPaginator::from_list_params("/identity/verification_sessions", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveIdentityVerificationSession<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveIdentityVerificationSession<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveIdentityVerificationSession<'a> { - /// Retrieves the details of a VerificationSession that was previously created. - /// - /// When the session status is `requires_input`, you can use this method to retrieve a valid - /// `client_secret` or `url` to allow re-submission. - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_misc::IdentityVerificationSessionId, - ) -> stripe::Response<stripe_misc::IdentityVerificationSession> { - client.get_query(&format!("/identity/verification_sessions/{session}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIdentityVerificationSession<'a> { /// Specifies which fields in the response should be expanded. @@ -85,7 +16,7 @@ pub struct CreateIdentityVerificationSession<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub return_url: Option<&'a str>, /// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_misc::IdentityVerificationSessionType, } impl<'a> CreateIdentityVerificationSession<'a> { @@ -186,14 +117,128 @@ impl<'a> CreateIdentityVerificationSession<'a> { /// If your API key is in test mode, verification checks won’t actually process, though everything else will occur as if in live mode. /// /// Related guide: [Verify your users’ identity documents](https://stripe.com/docs/identity/verify-identity-documents). - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_misc::IdentityVerificationSession> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::IdentityVerificationSession> { client.send_form("/identity/verification_sessions", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveIdentityVerificationSession<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveIdentityVerificationSession<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveIdentityVerificationSession<'a> { + /// Retrieves the details of a VerificationSession that was previously created. + /// + /// When the session status is `requires_input`, you can use this method to retrieve a valid + /// `client_secret` or `url` to allow re-submission. + pub fn send(&self, client: &stripe::Client, session: &stripe_misc::IdentityVerificationSessionId) -> stripe::Response<stripe_misc::IdentityVerificationSession> { + client.get_query(&format!("/identity/verification_sessions/{session}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListIdentityVerificationSession<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// Only return VerificationSessions with this status. + /// [Learn more about the lifecycle of sessions](https://stripe.com/docs/identity/how-sessions-work). + #[serde(skip_serializing_if = "Option::is_none")] + pub status: Option<stripe_misc::IdentityVerificationSessionStatus>, +} +impl<'a> ListIdentityVerificationSession<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListIdentityVerificationSession<'a> { + /// Returns a list of VerificationSessions + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::IdentityVerificationSession>> { + client.get_query("/identity/verification_sessions", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::IdentityVerificationSession>> { + stripe::ListPaginator::from_list_params("/identity/verification_sessions", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CancelIdentityVerificationSession<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> CancelIdentityVerificationSession<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> CancelIdentityVerificationSession<'a> { + /// A VerificationSession object can be canceled when it is in `requires_input` [status](https://stripe.com/docs/identity/how-sessions-work). + /// + /// Once canceled, future submission attempts are disabled. + /// This cannot be undone. + /// [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). + pub fn send(&self, client: &stripe::Client, session: &stripe_misc::IdentityVerificationSessionId) -> stripe::Response<stripe_misc::IdentityVerificationSession> { + client.send_form(&format!("/identity/verification_sessions/{session}/cancel"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RedactIdentityVerificationSession<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RedactIdentityVerificationSession<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RedactIdentityVerificationSession<'a> { + /// Redact a VerificationSession to remove all collected information from Stripe. This will redact + /// the VerificationSession and all objects related to it, including VerificationReports, Events, + /// request logs, etc. + /// + /// A VerificationSession object can be redacted when it is in `requires_input` or `verified` + /// [status](https://stripe.com/docs/identity/how-sessions-work). + /// Redacting a VerificationSession in `requires_action`. + /// state will automatically cancel it. + /// + /// The redaction process may take up to four days. When the redaction process is in progress, the + /// VerificationSession’s `redaction.status` field will be set to `processing`; when the process is + /// finished, it will change to `redacted` and an `identity.verification_session.redacted` event + /// will be emitted. + /// + /// Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the + /// fields that contain personal data will be replaced by the string `[redacted]` or a similar + /// placeholder. The `metadata` field will also be erased. Redacted objects cannot be updated or + /// used for any purpose. + /// + /// [Learn more](https://stripe.com/docs/identity/verification-sessions#redact). + pub fn send(&self, client: &stripe::Client, session: &stripe_misc::IdentityVerificationSessionId) -> stripe::Response<stripe_misc::IdentityVerificationSession> { + client.send_form(&format!("/identity/verification_sessions/{session}/redact"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateIdentityVerificationSession<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -208,7 +253,7 @@ pub struct UpdateIdentityVerificationSession<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub options: Option<UpdateIdentityVerificationSessionOptions<'a>>, /// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_misc::IdentityVerificationSessionType>, } @@ -307,88 +352,7 @@ impl<'a> UpdateIdentityVerificationSession<'a> { /// /// When the session status is `requires_input`, you can use this method to update the /// verification check and options. - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_misc::IdentityVerificationSessionId, - ) -> stripe::Response<stripe_misc::IdentityVerificationSession> { - client.send_form( - &format!("/identity/verification_sessions/{session}"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelIdentityVerificationSession<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CancelIdentityVerificationSession<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CancelIdentityVerificationSession<'a> { - /// A VerificationSession object can be canceled when it is in `requires_input` [status](https://stripe.com/docs/identity/how-sessions-work). - /// - /// Once canceled, future submission attempts are disabled. - /// This cannot be undone. - /// [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel). - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_misc::IdentityVerificationSessionId, - ) -> stripe::Response<stripe_misc::IdentityVerificationSession> { - client.send_form( - &format!("/identity/verification_sessions/{session}/cancel"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RedactIdentityVerificationSession<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RedactIdentityVerificationSession<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RedactIdentityVerificationSession<'a> { - /// Redact a VerificationSession to remove all collected information from Stripe. This will redact - /// the VerificationSession and all objects related to it, including VerificationReports, Events, - /// request logs, etc. - /// - /// A VerificationSession object can be redacted when it is in `requires_input` or `verified` - /// [status](https://stripe.com/docs/identity/how-sessions-work). - /// Redacting a VerificationSession in `requires_action`. - /// state will automatically cancel it. - /// - /// The redaction process may take up to four days. When the redaction process is in progress, the - /// VerificationSession’s `redaction.status` field will be set to `processing`; when the process is - /// finished, it will change to `redacted` and an `identity.verification_session.redacted` event - /// will be emitted. - /// - /// Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the - /// fields that contain personal data will be replaced by the string `[redacted]` or a similar - /// placeholder. The `metadata` field will also be erased. Redacted objects cannot be updated or - /// used for any purpose. - /// - /// [Learn more](https://stripe.com/docs/identity/verification-sessions#redact). - pub fn send( - &self, - client: &stripe::Client, - session: &stripe_misc::IdentityVerificationSessionId, - ) -> stripe::Response<stripe_misc::IdentityVerificationSession> { - client.send_form( - &format!("/identity/verification_sessions/{session}/redact"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, session: &stripe_misc::IdentityVerificationSessionId) -> stripe::Response<stripe_misc::IdentityVerificationSession> { + client.send_form(&format!("/identity/verification_sessions/{session}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_misc/src/identity_verification_session/types.rs b/generated/stripe_misc/src/identity_verification_session/types.rs index f1526e239..35767dbf7 100644 --- a/generated/stripe_misc/src/identity_verification_session/types.rs +++ b/generated/stripe_misc/src/identity_verification_session/types.rs @@ -11,7 +11,9 @@ /// Related guide: [The Verification Sessions API](https://stripe.com/docs/identity/verification-sessions). /// /// For more details see <<https://stripe.com/docs/api/identity/verification_sessions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IdentityVerificationSession { /// The short-lived client secret used by Stripe.js to [show a verification modal](https://stripe.com/docs/js/identity/modal) inside your app. /// This client secret expires after 24 hours and can only be used once. @@ -27,8 +29,7 @@ pub struct IdentityVerificationSession { pub last_error: Option<stripe_misc::GelatoSessionLastError>, /// ID of the most recent VerificationReport. /// [Learn more about accessing detailed verification results.](https://stripe.com/docs/identity/verification-sessions#results). - pub last_verification_report: - Option<stripe_types::Expandable<stripe_misc::IdentityVerificationReport>>, + pub last_verification_report: Option<stripe_types::Expandable<stripe_misc::IdentityVerificationReport>>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. @@ -43,7 +44,7 @@ pub struct IdentityVerificationSession { /// [Learn more about the lifecycle of sessions](https://stripe.com/docs/identity/how-sessions-work). pub status: stripe_misc::IdentityVerificationSessionStatus, /// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<stripe_misc::IdentityVerificationSessionType>, /// The short-lived URL that you use to redirect a user to Stripe to submit their identity information. /// This URL expires after 48 hours and can only be used once. @@ -53,6 +54,154 @@ pub struct IdentityVerificationSession { /// The user’s verified data. pub verified_outputs: Option<stripe_misc::GelatoVerifiedOutputs>, } +#[cfg(feature = "min-ser")] +pub struct IdentityVerificationSessionBuilder { + client_secret: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + id: Option<stripe_misc::IdentityVerificationSessionId>, + last_error: Option<Option<stripe_misc::GelatoSessionLastError>>, + last_verification_report: Option<Option<stripe_types::Expandable<stripe_misc::IdentityVerificationReport>>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + options: Option<Option<stripe_misc::GelatoVerificationSessionOptions>>, + redaction: Option<Option<stripe_misc::VerificationSessionRedaction>>, + status: Option<stripe_misc::IdentityVerificationSessionStatus>, + type_: Option<Option<stripe_misc::IdentityVerificationSessionType>>, + url: Option<Option<String>>, + verified_outputs: Option<Option<stripe_misc::GelatoVerifiedOutputs>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IdentityVerificationSession { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IdentityVerificationSession>, + builder: IdentityVerificationSessionBuilder, + } + + impl Visitor for Place<IdentityVerificationSession> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IdentityVerificationSessionBuilder::deser_default() })) + } + } + + impl MapBuilder for IdentityVerificationSessionBuilder { + type Out = IdentityVerificationSession; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "client_secret" => Deserialize::begin(&mut self.client_secret), + "created" => Deserialize::begin(&mut self.created), + "id" => Deserialize::begin(&mut self.id), + "last_error" => Deserialize::begin(&mut self.last_error), + "last_verification_report" => Deserialize::begin(&mut self.last_verification_report), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "options" => Deserialize::begin(&mut self.options), + "redaction" => Deserialize::begin(&mut self.redaction), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + "url" => Deserialize::begin(&mut self.url), + "verified_outputs" => Deserialize::begin(&mut self.verified_outputs), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + client_secret: Deserialize::default(), + created: Deserialize::default(), + id: Deserialize::default(), + last_error: Deserialize::default(), + last_verification_report: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + options: Deserialize::default(), + redaction: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + url: Deserialize::default(), + verified_outputs: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let client_secret = self.client_secret.take()?; + let created = self.created.take()?; + let id = self.id.take()?; + let last_error = self.last_error.take()?; + let last_verification_report = self.last_verification_report.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let options = self.options.take()?; + let redaction = self.redaction.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + let url = self.url.take()?; + let verified_outputs = self.verified_outputs.take()?; + + Some(Self::Out { client_secret, created, id, last_error, last_verification_report, livemode, metadata, options, redaction, status, type_, url, verified_outputs }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IdentityVerificationSession { + type Builder = IdentityVerificationSessionBuilder; + } + + impl FromValueOpt for IdentityVerificationSession { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IdentityVerificationSessionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "last_error" => b.last_error = Some(FromValueOpt::from_value(v)?), + "last_verification_report" => b.last_verification_report = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "options" => b.options = Some(FromValueOpt::from_value(v)?), + "redaction" => b.redaction = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + "verified_outputs" => b.verified_outputs = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for IdentityVerificationSession { type Id = stripe_misc::IdentityVerificationSessionId; fn id(&self) -> &Self::Id { @@ -115,11 +264,27 @@ impl<'de> serde::Deserialize<'de> for IdentityVerificationSessionStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IdentityVerificationSessionStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IdentityVerificationSessionStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IdentityVerificationSessionStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IdentityVerificationSessionStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IdentityVerificationSessionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IdentityVerificationSessionStatus); #[derive(Copy, Clone, Eq, PartialEq)] pub enum IdentityVerificationSessionType { Document, @@ -169,8 +334,24 @@ impl<'de> serde::Deserialize<'de> for IdentityVerificationSessionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IdentityVerificationSessionType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IdentityVerificationSessionType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IdentityVerificationSessionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IdentityVerificationSessionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IdentityVerificationSessionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IdentityVerificationSessionType); diff --git a/generated/stripe_misc/src/mod.rs b/generated/stripe_misc/src/mod.rs index 35e7c18a4..4f01a4d0f 100644 --- a/generated/stripe_misc/src/mod.rs +++ b/generated/stripe_misc/src/mod.rs @@ -8,6 +8,9 @@ //! and `Webhooks` sections of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_misc; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub use apple_pay_domain::types::*; pub mod apple_pay_domain; #[doc(hidden)] @@ -39,36 +42,6 @@ pub mod bank_connections_resource_ownership_refresh; #[doc(inline)] pub use bank_connections_resource_ownership_refresh::*; #[doc(hidden)] -pub mod bank_connections_resource_transaction_refresh; -#[doc(inline)] -pub use bank_connections_resource_transaction_refresh::*; -#[doc(hidden)] -pub mod bank_connections_resource_transaction_resource_status_transitions; -#[doc(inline)] -pub use bank_connections_resource_transaction_resource_status_transitions::*; -pub use climate_order::types::*; -pub mod climate_order; -pub use climate_product::types::*; -pub mod climate_product; -pub use climate_supplier::types::*; -#[doc(hidden)] -pub mod climate_removals_beneficiary; -pub mod climate_supplier; -#[doc(inline)] -pub use climate_removals_beneficiary::*; -#[doc(hidden)] -pub mod climate_removals_location; -#[doc(inline)] -pub use climate_removals_location::*; -#[doc(hidden)] -pub mod climate_removals_order_deliveries; -#[doc(inline)] -pub use climate_removals_order_deliveries::*; -#[doc(hidden)] -pub mod climate_removals_products_price; -#[doc(inline)] -pub use climate_removals_products_price::*; -#[doc(hidden)] pub mod deleted_apple_pay_domain; #[doc(inline)] pub use deleted_apple_pay_domain::*; @@ -92,8 +65,6 @@ pub mod financial_connections_account_ownership; pub use financial_connections_account_ownership::*; pub use financial_connections_session::types::*; pub mod financial_connections_session; -pub use financial_connections_transaction::types::*; -pub mod financial_connections_transaction; #[doc(hidden)] pub mod financial_reporting_finance_report_run_run_parameters; #[doc(inline)] diff --git a/generated/stripe_misc/src/reporting_report_run/requests.rs b/generated/stripe_misc/src/reporting_report_run/requests.rs index 2cdf5e17c..d64839ba1 100644 --- a/generated/stripe_misc/src/reporting_report_run/requests.rs +++ b/generated/stripe_misc/src/reporting_report_run/requests.rs @@ -1,45 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListReportingReportRun<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListReportingReportRun<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListReportingReportRun<'a> { - /// Returns a list of Report Runs, with the most recent appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ReportingReportRun>> { - client.get_query("/reporting/report_runs", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ReportingReportRun>> { - stripe::ListPaginator::from_list_params("/reporting/report_runs", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveReportingReportRun<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -52,11 +11,7 @@ impl<'a> RetrieveReportingReportRun<'a> { } impl<'a> RetrieveReportingReportRun<'a> { /// Retrieves the details of an existing Report Run. - pub fn send( - &self, - client: &stripe::Client, - report_run: &stripe_misc::ReportingReportRunId, - ) -> stripe::Response<stripe_misc::ReportingReportRun> { + pub fn send(&self, client: &stripe::Client, report_run: &stripe_misc::ReportingReportRunId) -> stripe::Response<stripe_misc::ReportingReportRun> { client.get_query(&format!("/reporting/report_runs/{report_run}"), self) } } @@ -124,8 +79,6 @@ pub enum CreateReportingReportRunParametersReportingCategory { AnticipationRepayment, Charge, ChargeFailure, - ClimateOrderPurchase, - ClimateOrderRefund, ConnectCollectionTransfer, ConnectReservedFunds, Contribution, @@ -141,6 +94,7 @@ pub enum CreateReportingReportRunParametersReportingCategory { IssuingDispute, IssuingTransaction, NetworkCost, + Obligation, OtherAdjustment, PartialCaptureReversal, Payout, @@ -168,8 +122,6 @@ impl CreateReportingReportRunParametersReportingCategory { AnticipationRepayment => "anticipation_repayment", Charge => "charge", ChargeFailure => "charge_failure", - ClimateOrderPurchase => "climate_order_purchase", - ClimateOrderRefund => "climate_order_refund", ConnectCollectionTransfer => "connect_collection_transfer", ConnectReservedFunds => "connect_reserved_funds", Contribution => "contribution", @@ -185,6 +137,7 @@ impl CreateReportingReportRunParametersReportingCategory { IssuingDispute => "issuing_dispute", IssuingTransaction => "issuing_transaction", NetworkCost => "network_cost", + Obligation => "obligation", OtherAdjustment => "other_adjustment", PartialCaptureReversal => "partial_capture_reversal", Payout => "payout", @@ -215,8 +168,6 @@ impl std::str::FromStr for CreateReportingReportRunParametersReportingCategory { "anticipation_repayment" => Ok(AnticipationRepayment), "charge" => Ok(Charge), "charge_failure" => Ok(ChargeFailure), - "climate_order_purchase" => Ok(ClimateOrderPurchase), - "climate_order_refund" => Ok(ClimateOrderRefund), "connect_collection_transfer" => Ok(ConnectCollectionTransfer), "connect_reserved_funds" => Ok(ConnectReservedFunds), "contribution" => Ok(Contribution), @@ -232,6 +183,7 @@ impl std::str::FromStr for CreateReportingReportRunParametersReportingCategory { "issuing_dispute" => Ok(IssuingDispute), "issuing_transaction" => Ok(IssuingTransaction), "network_cost" => Ok(NetworkCost), + "obligation" => Ok(Obligation), "other_adjustment" => Ok(OtherAdjustment), "partial_capture_reversal" => Ok(PartialCaptureReversal), "payout" => Ok(Payout), @@ -2114,10 +2066,43 @@ impl serde::Serialize for CreateReportingReportRunParametersTimezone { impl<'a> CreateReportingReportRun<'a> { /// Creates a new object and begin running the report. /// (Certain report types require a [live-mode API key](https://stripe.com/docs/keys#test-live-modes).). - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_misc::ReportingReportRun> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::ReportingReportRun> { client.send_form("/reporting/report_runs", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListReportingReportRun<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListReportingReportRun<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListReportingReportRun<'a> { + /// Returns a list of Report Runs, with the most recent appearing first. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::ReportingReportRun>> { + client.get_query("/reporting/report_runs", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ReportingReportRun>> { + stripe::ListPaginator::from_list_params("/reporting/report_runs", self) + } +} diff --git a/generated/stripe_misc/src/reporting_report_run/types.rs b/generated/stripe_misc/src/reporting_report_run/types.rs index 0282fc92d..d6aa0ce88 100644 --- a/generated/stripe_misc/src/reporting_report_run/types.rs +++ b/generated/stripe_misc/src/reporting_report_run/types.rs @@ -8,7 +8,9 @@ /// data), and will error when queried without a [live-mode API key](https://stripe.com/docs/keys#test-live-modes). /// /// For more details see <<https://stripe.com/docs/api/reporting/report_run/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ReportingReportRun { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -33,6 +35,134 @@ pub struct ReportingReportRun { /// `status=succeeded`). Measured in seconds since the Unix epoch. pub succeeded_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct ReportingReportRunBuilder { + created: Option<stripe_types::Timestamp>, + error: Option<Option<String>>, + id: Option<stripe_misc::ReportingReportRunId>, + livemode: Option<bool>, + parameters: Option<stripe_misc::FinancialReportingFinanceReportRunRunParameters>, + report_type: Option<String>, + result: Option<Option<stripe_shared::File>>, + status: Option<String>, + succeeded_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ReportingReportRun { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ReportingReportRun>, + builder: ReportingReportRunBuilder, + } + + impl Visitor for Place<ReportingReportRun> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ReportingReportRunBuilder::deser_default() })) + } + } + + impl MapBuilder for ReportingReportRunBuilder { + type Out = ReportingReportRun; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "error" => Deserialize::begin(&mut self.error), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "parameters" => Deserialize::begin(&mut self.parameters), + "report_type" => Deserialize::begin(&mut self.report_type), + "result" => Deserialize::begin(&mut self.result), + "status" => Deserialize::begin(&mut self.status), + "succeeded_at" => Deserialize::begin(&mut self.succeeded_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + error: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + parameters: Deserialize::default(), + report_type: Deserialize::default(), + result: Deserialize::default(), + status: Deserialize::default(), + succeeded_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let error = self.error.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let parameters = self.parameters.take()?; + let report_type = self.report_type.take()?; + let result = self.result.take()?; + let status = self.status.take()?; + let succeeded_at = self.succeeded_at.take()?; + + Some(Self::Out { created, error, id, livemode, parameters, report_type, result, status, succeeded_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ReportingReportRun { + type Builder = ReportingReportRunBuilder; + } + + impl FromValueOpt for ReportingReportRun { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ReportingReportRunBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "error" => b.error = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "parameters" => b.parameters = Some(FromValueOpt::from_value(v)?), + "report_type" => b.report_type = Some(FromValueOpt::from_value(v)?), + "result" => b.result = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "succeeded_at" => b.succeeded_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ReportingReportRun { type Id = stripe_misc::ReportingReportRunId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/reporting_report_type/requests.rs b/generated/stripe_misc/src/reporting_report_type/requests.rs index bb6adf037..fbfb3aed0 100644 --- a/generated/stripe_misc/src/reporting_report_type/requests.rs +++ b/generated/stripe_misc/src/reporting_report_type/requests.rs @@ -1,47 +1,38 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListReportingReportType<'a> { +pub struct RetrieveReportingReportType<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> ListReportingReportType<'a> { +impl<'a> RetrieveReportingReportType<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> ListReportingReportType<'a> { - /// Returns a full list of Report Types. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ReportingReportType>> { - client.get_query("/reporting/report_types", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ReportingReportType>> { - stripe::ListPaginator::from_list_params("/reporting/report_types", self) +impl<'a> RetrieveReportingReportType<'a> { + /// Retrieves the details of a Report Type. + /// (Certain report types require a [live-mode API key](https://stripe.com/docs/keys#test-live-modes).). + pub fn send(&self, client: &stripe::Client, report_type: &stripe_misc::ReportingReportTypeId) -> stripe::Response<stripe_misc::ReportingReportType> { + client.get_query(&format!("/reporting/report_types/{report_type}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveReportingReportType<'a> { +pub struct ListReportingReportType<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> RetrieveReportingReportType<'a> { +impl<'a> ListReportingReportType<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> RetrieveReportingReportType<'a> { - /// Retrieves the details of a Report Type. - /// (Certain report types require a [live-mode API key](https://stripe.com/docs/keys#test-live-modes).). - pub fn send( - &self, - client: &stripe::Client, - report_type: &stripe_misc::ReportingReportTypeId, - ) -> stripe::Response<stripe_misc::ReportingReportType> { - client.get_query(&format!("/reporting/report_types/{report_type}"), self) +impl<'a> ListReportingReportType<'a> { + /// Returns a full list of Report Types. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::ReportingReportType>> { + client.get_query("/reporting/report_types", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ReportingReportType>> { + stripe::ListPaginator::from_list_params("/reporting/report_types", self) } } diff --git a/generated/stripe_misc/src/reporting_report_type/types.rs b/generated/stripe_misc/src/reporting_report_type/types.rs index fe66c52fe..0203dc0ed 100644 --- a/generated/stripe_misc/src/reporting_report_type/types.rs +++ b/generated/stripe_misc/src/reporting_report_type/types.rs @@ -8,7 +8,9 @@ /// data), and will error when queried without a [live-mode API key](https://stripe.com/docs/keys#test-live-modes). /// /// For more details see <<https://stripe.com/docs/api/reporting/report_type/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ReportingReportType { /// Most recent time for which this Report Type is available. Measured in seconds since the Unix epoch. pub data_available_end: stripe_types::Timestamp, @@ -29,6 +31,129 @@ pub struct ReportingReportType { /// Different versions report with the same ID will have the same purpose, but may take different run parameters or have different result schemas. pub version: i64, } +#[cfg(feature = "min-ser")] +pub struct ReportingReportTypeBuilder { + data_available_end: Option<stripe_types::Timestamp>, + data_available_start: Option<stripe_types::Timestamp>, + default_columns: Option<Option<Vec<String>>>, + id: Option<stripe_misc::ReportingReportTypeId>, + livemode: Option<bool>, + name: Option<String>, + updated: Option<stripe_types::Timestamp>, + version: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ReportingReportType { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ReportingReportType>, + builder: ReportingReportTypeBuilder, + } + + impl Visitor for Place<ReportingReportType> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ReportingReportTypeBuilder::deser_default() })) + } + } + + impl MapBuilder for ReportingReportTypeBuilder { + type Out = ReportingReportType; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "data_available_end" => Deserialize::begin(&mut self.data_available_end), + "data_available_start" => Deserialize::begin(&mut self.data_available_start), + "default_columns" => Deserialize::begin(&mut self.default_columns), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "name" => Deserialize::begin(&mut self.name), + "updated" => Deserialize::begin(&mut self.updated), + "version" => Deserialize::begin(&mut self.version), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + data_available_end: Deserialize::default(), + data_available_start: Deserialize::default(), + default_columns: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + name: Deserialize::default(), + updated: Deserialize::default(), + version: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let data_available_end = self.data_available_end.take()?; + let data_available_start = self.data_available_start.take()?; + let default_columns = self.default_columns.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let name = self.name.take()?; + let updated = self.updated.take()?; + let version = self.version.take()?; + + Some(Self::Out { data_available_end, data_available_start, default_columns, id, livemode, name, updated, version }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ReportingReportType { + type Builder = ReportingReportTypeBuilder; + } + + impl FromValueOpt for ReportingReportType { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ReportingReportTypeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "data_available_end" => b.data_available_end = Some(FromValueOpt::from_value(v)?), + "data_available_start" => b.data_available_start = Some(FromValueOpt::from_value(v)?), + "default_columns" => b.default_columns = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "updated" => b.updated = Some(FromValueOpt::from_value(v)?), + "version" => b.version = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ReportingReportType { type Id = stripe_misc::ReportingReportTypeId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/scheduled_query_run/requests.rs b/generated/stripe_misc/src/scheduled_query_run/requests.rs index bebced59e..c47bf8869 100644 --- a/generated/stripe_misc/src/scheduled_query_run/requests.rs +++ b/generated/stripe_misc/src/scheduled_query_run/requests.rs @@ -25,15 +25,10 @@ impl<'a> ListScheduledQueryRun<'a> { } impl<'a> ListScheduledQueryRun<'a> { /// Returns a list of scheduled query runs. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::ScheduledQueryRun>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::ScheduledQueryRun>> { client.get_query("/sigma/scheduled_query_runs", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ScheduledQueryRun>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::ScheduledQueryRun>> { stripe::ListPaginator::from_list_params("/sigma/scheduled_query_runs", self) } } @@ -50,11 +45,7 @@ impl<'a> RetrieveScheduledQueryRun<'a> { } impl<'a> RetrieveScheduledQueryRun<'a> { /// Retrieves the details of an scheduled query run. - pub fn send( - &self, - client: &stripe::Client, - scheduled_query_run: &str, - ) -> stripe::Response<stripe_misc::ScheduledQueryRun> { + pub fn send(&self, client: &stripe::Client, scheduled_query_run: &str) -> stripe::Response<stripe_misc::ScheduledQueryRun> { client.get_query(&format!("/sigma/scheduled_query_runs/{scheduled_query_run}"), self) } } diff --git a/generated/stripe_misc/src/scheduled_query_run/types.rs b/generated/stripe_misc/src/scheduled_query_run/types.rs index 171b45dcf..322735b65 100644 --- a/generated/stripe_misc/src/scheduled_query_run/types.rs +++ b/generated/stripe_misc/src/scheduled_query_run/types.rs @@ -4,13 +4,14 @@ /// retrieve the query results. /// /// For more details see <<https://stripe.com/docs/api/sigma/scheduled_queries/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ScheduledQueryRun { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// When the query was run, Sigma contained a snapshot of your Stripe data at this time. pub data_load_time: stripe_types::Timestamp, - #[serde(skip_serializing_if = "Option::is_none")] pub error: Option<stripe_misc::SigmaScheduledQueryRunError>, /// The file object representing the results of the query. pub file: Option<stripe_shared::File>, @@ -27,6 +28,139 @@ pub struct ScheduledQueryRun { /// Title of the query. pub title: String, } +#[cfg(feature = "min-ser")] +pub struct ScheduledQueryRunBuilder { + created: Option<stripe_types::Timestamp>, + data_load_time: Option<stripe_types::Timestamp>, + error: Option<Option<stripe_misc::SigmaScheduledQueryRunError>>, + file: Option<Option<stripe_shared::File>>, + id: Option<stripe_misc::ScheduledQueryRunId>, + livemode: Option<bool>, + result_available_until: Option<stripe_types::Timestamp>, + sql: Option<String>, + status: Option<String>, + title: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ScheduledQueryRun { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ScheduledQueryRun>, + builder: ScheduledQueryRunBuilder, + } + + impl Visitor for Place<ScheduledQueryRun> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ScheduledQueryRunBuilder::deser_default() })) + } + } + + impl MapBuilder for ScheduledQueryRunBuilder { + type Out = ScheduledQueryRun; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "data_load_time" => Deserialize::begin(&mut self.data_load_time), + "error" => Deserialize::begin(&mut self.error), + "file" => Deserialize::begin(&mut self.file), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "result_available_until" => Deserialize::begin(&mut self.result_available_until), + "sql" => Deserialize::begin(&mut self.sql), + "status" => Deserialize::begin(&mut self.status), + "title" => Deserialize::begin(&mut self.title), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + data_load_time: Deserialize::default(), + error: Deserialize::default(), + file: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + result_available_until: Deserialize::default(), + sql: Deserialize::default(), + status: Deserialize::default(), + title: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let data_load_time = self.data_load_time.take()?; + let error = self.error.take()?; + let file = self.file.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let result_available_until = self.result_available_until.take()?; + let sql = self.sql.take()?; + let status = self.status.take()?; + let title = self.title.take()?; + + Some(Self::Out { created, data_load_time, error, file, id, livemode, result_available_until, sql, status, title }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ScheduledQueryRun { + type Builder = ScheduledQueryRunBuilder; + } + + impl FromValueOpt for ScheduledQueryRun { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ScheduledQueryRunBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "data_load_time" => b.data_load_time = Some(FromValueOpt::from_value(v)?), + "error" => b.error = Some(FromValueOpt::from_value(v)?), + "file" => b.file = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "result_available_until" => b.result_available_until = Some(FromValueOpt::from_value(v)?), + "sql" => b.sql = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "title" => b.title = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ScheduledQueryRun { type Id = stripe_misc::ScheduledQueryRunId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/sigma_scheduled_query_run_error.rs b/generated/stripe_misc/src/sigma_scheduled_query_run_error.rs index e52c463a5..f38c9a578 100644 --- a/generated/stripe_misc/src/sigma_scheduled_query_run_error.rs +++ b/generated/stripe_misc/src/sigma_scheduled_query_run_error.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SigmaScheduledQueryRunError { /// Information about the run failure. pub message: String, } +#[cfg(feature = "min-ser")] +pub struct SigmaScheduledQueryRunErrorBuilder { + message: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SigmaScheduledQueryRunError { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SigmaScheduledQueryRunError>, + builder: SigmaScheduledQueryRunErrorBuilder, + } + + impl Visitor for Place<SigmaScheduledQueryRunError> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SigmaScheduledQueryRunErrorBuilder::deser_default() })) + } + } + + impl MapBuilder for SigmaScheduledQueryRunErrorBuilder { + type Out = SigmaScheduledQueryRunError; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "message" => Deserialize::begin(&mut self.message), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let message = self.message.take()?; + + Some(Self::Out { message }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SigmaScheduledQueryRunError { + type Builder = SigmaScheduledQueryRunErrorBuilder; + } + + impl FromValueOpt for SigmaScheduledQueryRunError { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SigmaScheduledQueryRunErrorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "message" => b.message = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_calculation/requests.rs b/generated/stripe_misc/src/tax_calculation/requests.rs index bb3faf6e4..c65bbf1a7 100644 --- a/generated/stripe_misc/src/tax_calculation/requests.rs +++ b/generated/stripe_misc/src/tax_calculation/requests.rs @@ -1,47 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListLineItemsTaxCalculation<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListLineItemsTaxCalculation<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListLineItemsTaxCalculation<'a> { - /// Retrieves the line items of a persisted tax calculation as a collection. - pub fn send( - &self, - client: &stripe::Client, - calculation: &stripe_misc::TaxCalculationId, - ) -> stripe::Response<stripe_types::List<stripe_misc::TaxCalculationLineItem>> { - client.get_query(&format!("/tax/calculations/{calculation}/line_items"), self) - } - pub fn paginate( - self, - calculation: &stripe_misc::TaxCalculationId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::TaxCalculationLineItem>> { - stripe::ListPaginator::from_list_params( - &format!("/tax/calculations/{calculation}/line_items"), - self, - ) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxCalculation<'a> { /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. @@ -69,19 +25,8 @@ pub struct CreateTaxCalculation<'a> { pub tax_date: Option<stripe_types::Timestamp>, } impl<'a> CreateTaxCalculation<'a> { - pub fn new( - currency: stripe_types::Currency, - line_items: &'a [CreateTaxCalculationLineItems<'a>], - ) -> Self { - Self { - currency, - customer: None, - customer_details: None, - expand: None, - line_items, - shipping_cost: None, - tax_date: None, - } + pub fn new(currency: stripe_types::Currency, line_items: &'a [CreateTaxCalculationLineItems<'a>]) -> Self { + Self { currency, customer: None, customer_details: None, expand: None, line_items, shipping_cost: None, tax_date: None } } } /// Details about the customer, including address and tax IDs. @@ -97,8 +42,6 @@ pub struct CreateTaxCalculationCustomerDetails<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub ip_address: Option<&'a str>, /// The customer's tax IDs. - /// Stripe Tax might consider a transaction with applicable tax IDs to be B2B, which might affect the tax calculation result. - /// Stripe Tax doesn't validate tax IDs for correctness. #[serde(skip_serializing_if = "Option::is_none")] pub tax_ids: Option<&'a [CreateTaxCalculationCustomerDetailsTaxIds<'a>]>, /// Overrides the tax calculation result to allow you to not collect tax from your customer. @@ -186,12 +129,10 @@ impl serde::Serialize for CreateTaxCalculationCustomerDetailsAddressSource { } } /// The customer's tax IDs. -/// Stripe Tax might consider a transaction with applicable tax IDs to be B2B, which might affect the tax calculation result. -/// Stripe Tax doesn't validate tax IDs for correctness. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxCalculationCustomerDetailsTaxIds<'a> { /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxCalculationCustomerDetailsTaxIdsType, /// Value of the tax ID. pub value: &'a str, @@ -497,7 +438,7 @@ impl serde::Serialize for CreateTaxCalculationCustomerDetailsTaxabilityOverride /// A list of items the customer is purchasing. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxCalculationLineItems<'a> { - /// A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) representing the line item's total price. + /// A positive integer in cents representing the line item's total price. /// If `tax_behavior=inclusive`, then this amount includes taxes. /// Otherwise, taxes are calculated on top of this amount. pub amount: i64, @@ -524,14 +465,7 @@ pub struct CreateTaxCalculationLineItems<'a> { } impl<'a> CreateTaxCalculationLineItems<'a> { pub fn new(amount: i64) -> Self { - Self { - amount, - product: None, - quantity: None, - reference: None, - tax_behavior: None, - tax_code: None, - } + Self { amount, product: None, quantity: None, reference: None, tax_behavior: None, tax_code: None } } } /// Specifies whether the `amount` includes taxes. Defaults to `exclusive`. @@ -583,7 +517,7 @@ impl serde::Serialize for CreateTaxCalculationLineItemsTaxBehavior { /// Shipping cost details to be used for the calculation. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTaxCalculationShippingCost<'a> { - /// A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) representing the shipping charge. + /// A positive integer in cents representing the shipping charge. /// If `tax_behavior=inclusive`, then this amount includes taxes. /// Otherwise, taxes are calculated on top of this amount. #[serde(skip_serializing_if = "Option::is_none")] @@ -661,3 +595,37 @@ impl<'a> CreateTaxCalculation<'a> { client.send_form("/tax/calculations", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListLineItemsTaxCalculation<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListLineItemsTaxCalculation<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListLineItemsTaxCalculation<'a> { + /// Retrieves the line items of a persisted tax calculation as a collection. + pub fn send(&self, client: &stripe::Client, calculation: &stripe_misc::TaxCalculationId) -> stripe::Response<stripe_types::List<stripe_misc::TaxCalculationLineItem>> { + client.get_query(&format!("/tax/calculations/{calculation}/line_items"), self) + } + pub fn paginate(self, calculation: &stripe_misc::TaxCalculationId) -> stripe::ListPaginator<stripe_types::List<stripe_misc::TaxCalculationLineItem>> { + stripe::ListPaginator::from_list_params(&format!("/tax/calculations/{calculation}/line_items"), self) + } +} diff --git a/generated/stripe_misc/src/tax_calculation/types.rs b/generated/stripe_misc/src/tax_calculation/types.rs index 1e26a782c..2285d6e81 100644 --- a/generated/stripe_misc/src/tax_calculation/types.rs +++ b/generated/stripe_misc/src/tax_calculation/types.rs @@ -3,7 +3,9 @@ /// Related guide: [Calculate tax in your custom payment flow](https://stripe.com/docs/tax/custom) /// /// For more details see <<https://stripe.com/docs/api/tax/calculations/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxCalculation { /// Total after taxes. pub amount_total: i64, @@ -32,6 +34,168 @@ pub struct TaxCalculation { /// Timestamp of date at which the tax rules and rates in effect applies for the calculation. pub tax_date: stripe_types::Timestamp, } +#[cfg(feature = "min-ser")] +pub struct TaxCalculationBuilder { + amount_total: Option<i64>, + currency: Option<stripe_types::Currency>, + customer: Option<Option<String>>, + customer_details: Option<stripe_misc::TaxProductResourceCustomerDetails>, + expires_at: Option<Option<stripe_types::Timestamp>>, + id: Option<Option<stripe_misc::TaxCalculationId>>, + line_items: Option<Option<stripe_types::List<stripe_misc::TaxCalculationLineItem>>>, + livemode: Option<bool>, + shipping_cost: Option<Option<stripe_misc::TaxProductResourceTaxCalculationShippingCost>>, + tax_amount_exclusive: Option<i64>, + tax_amount_inclusive: Option<i64>, + tax_breakdown: Option<Vec<stripe_misc::TaxProductResourceTaxBreakdown>>, + tax_date: Option<stripe_types::Timestamp>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxCalculation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxCalculation>, + builder: TaxCalculationBuilder, + } + + impl Visitor for Place<TaxCalculation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxCalculationBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxCalculationBuilder { + type Out = TaxCalculation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_total" => Deserialize::begin(&mut self.amount_total), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "customer_details" => Deserialize::begin(&mut self.customer_details), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "id" => Deserialize::begin(&mut self.id), + "line_items" => Deserialize::begin(&mut self.line_items), + "livemode" => Deserialize::begin(&mut self.livemode), + "shipping_cost" => Deserialize::begin(&mut self.shipping_cost), + "tax_amount_exclusive" => Deserialize::begin(&mut self.tax_amount_exclusive), + "tax_amount_inclusive" => Deserialize::begin(&mut self.tax_amount_inclusive), + "tax_breakdown" => Deserialize::begin(&mut self.tax_breakdown), + "tax_date" => Deserialize::begin(&mut self.tax_date), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_total: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + customer_details: Deserialize::default(), + expires_at: Deserialize::default(), + id: Deserialize::default(), + line_items: Deserialize::default(), + livemode: Deserialize::default(), + shipping_cost: Deserialize::default(), + tax_amount_exclusive: Deserialize::default(), + tax_amount_inclusive: Deserialize::default(), + tax_breakdown: Deserialize::default(), + tax_date: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_total = self.amount_total.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let customer_details = self.customer_details.take()?; + let expires_at = self.expires_at.take()?; + let id = self.id.take()?; + let line_items = self.line_items.take()?; + let livemode = self.livemode.take()?; + let shipping_cost = self.shipping_cost.take()?; + let tax_amount_exclusive = self.tax_amount_exclusive.take()?; + let tax_amount_inclusive = self.tax_amount_inclusive.take()?; + let tax_breakdown = self.tax_breakdown.take()?; + let tax_date = self.tax_date.take()?; + + Some(Self::Out { + amount_total, + currency, + customer, + customer_details, + expires_at, + id, + line_items, + livemode, + shipping_cost, + tax_amount_exclusive, + tax_amount_inclusive, + tax_breakdown, + tax_date, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxCalculation { + type Builder = TaxCalculationBuilder; + } + + impl FromValueOpt for TaxCalculation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxCalculationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "customer_details" => b.customer_details = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "shipping_cost" => b.shipping_cost = Some(FromValueOpt::from_value(v)?), + "tax_amount_exclusive" => b.tax_amount_exclusive = Some(FromValueOpt::from_value(v)?), + "tax_amount_inclusive" => b.tax_amount_inclusive = Some(FromValueOpt::from_value(v)?), + "tax_breakdown" => b.tax_breakdown = Some(FromValueOpt::from_value(v)?), + "tax_date" => b.tax_date = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TaxCalculation { type Id = Option<stripe_misc::TaxCalculationId>; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/tax_calculation_line_item.rs b/generated/stripe_misc/src/tax_calculation_line_item.rs index 6b66c87bf..7eacc3183 100644 --- a/generated/stripe_misc/src/tax_calculation_line_item.rs +++ b/generated/stripe_misc/src/tax_calculation_line_item.rs @@ -1,10 +1,12 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxCalculationLineItem { - /// The line item amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The line item amount in integer cents. /// If `tax_behavior=inclusive`, then this amount includes taxes. /// Otherwise, taxes were calculated on top of this amount. pub amount: i64, - /// The amount of tax calculated for this line item, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount of tax calculated for this line item, in integer cents. pub amount_tax: i64, /// Unique identifier for the object. pub id: stripe_misc::TaxCalculationLineItemId, @@ -24,6 +26,139 @@ pub struct TaxCalculationLineItem { /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for this resource. pub tax_code: String, } +#[cfg(feature = "min-ser")] +pub struct TaxCalculationLineItemBuilder { + amount: Option<i64>, + amount_tax: Option<i64>, + id: Option<stripe_misc::TaxCalculationLineItemId>, + livemode: Option<bool>, + product: Option<Option<String>>, + quantity: Option<u64>, + reference: Option<Option<String>>, + tax_behavior: Option<TaxCalculationLineItemTaxBehavior>, + tax_breakdown: Option<Option<Vec<stripe_misc::TaxProductResourceLineItemTaxBreakdown>>>, + tax_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxCalculationLineItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxCalculationLineItem>, + builder: TaxCalculationLineItemBuilder, + } + + impl Visitor for Place<TaxCalculationLineItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxCalculationLineItemBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxCalculationLineItemBuilder { + type Out = TaxCalculationLineItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "product" => Deserialize::begin(&mut self.product), + "quantity" => Deserialize::begin(&mut self.quantity), + "reference" => Deserialize::begin(&mut self.reference), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tax_breakdown" => Deserialize::begin(&mut self.tax_breakdown), + "tax_code" => Deserialize::begin(&mut self.tax_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_tax: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + product: Deserialize::default(), + quantity: Deserialize::default(), + reference: Deserialize::default(), + tax_behavior: Deserialize::default(), + tax_breakdown: Deserialize::default(), + tax_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_tax = self.amount_tax.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let product = self.product.take()?; + let quantity = self.quantity.take()?; + let reference = self.reference.take()?; + let tax_behavior = self.tax_behavior.take()?; + let tax_breakdown = self.tax_breakdown.take()?; + let tax_code = self.tax_code.take()?; + + Some(Self::Out { amount, amount_tax, id, livemode, product, quantity, reference, tax_behavior, tax_breakdown, tax_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxCalculationLineItem { + type Builder = TaxCalculationLineItemBuilder; + } + + impl FromValueOpt for TaxCalculationLineItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxCalculationLineItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "product" => b.product = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tax_breakdown" => b.tax_breakdown = Some(FromValueOpt::from_value(v)?), + "tax_code" => b.tax_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. #[derive(Copy, Clone, Eq, PartialEq)] @@ -75,11 +210,27 @@ impl<'de> serde::Deserialize<'de> for TaxCalculationLineItemTaxBehavior { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TaxCalculationLineItemTaxBehavior") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxCalculationLineItemTaxBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxCalculationLineItemTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxCalculationLineItemTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxCalculationLineItemTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxCalculationLineItemTaxBehavior); impl stripe_types::Object for TaxCalculationLineItem { type Id = stripe_misc::TaxCalculationLineItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options.rs index aae0c58f1..942f5e621 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options.rs @@ -1,101 +1,432 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub ae: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub at: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub au: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub be: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub bg: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub ca: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsCanada>, - #[serde(skip_serializing_if = "Option::is_none")] pub ch: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub cl: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub co: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub cy: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub cz: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub de: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub dk: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub ee: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub es: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub fi: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub fr: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub gb: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub gr: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub hr: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub hu: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub id: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub ie: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub is: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub it: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub jp: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub kr: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub lt: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub lu: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub lv: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub mt: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub mx: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub my: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub nl: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub no: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub nz: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub pl: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub pt: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub ro: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub sa: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub se: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub sg: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, - #[serde(skip_serializing_if = "Option::is_none")] pub si: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub sk: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>, - #[serde(skip_serializing_if = "Option::is_none")] pub th: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub tr: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub us: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUnitedStates>, - #[serde(skip_serializing_if = "Option::is_none")] pub vn: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>, - #[serde(skip_serializing_if = "Option::is_none")] pub za: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsBuilder { + ae: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + at: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + au: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + be: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + bg: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + ca: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsCanada>>, + ch: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + cl: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + co: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + cy: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + cz: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + de: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + dk: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + ee: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + es: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + fi: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + fr: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + gb: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + gr: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + hr: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + hu: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + id: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + ie: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + is: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + it: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + jp: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + kr: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + lt: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + lu: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + lv: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + mt: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + mx: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + my: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + nl: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + no: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + nz: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + pl: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + pt: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + ro: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + sa: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + se: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + sg: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, + si: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + sk: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEurope>>, + th: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + tr: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + us: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUnitedStates>>, + vn: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsSimplified>>, + za: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsDefault>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptions>, + builder: TaxProductRegistrationsResourceCountryOptionsBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsBuilder { + type Out = TaxProductRegistrationsResourceCountryOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ae" => Deserialize::begin(&mut self.ae), + "at" => Deserialize::begin(&mut self.at), + "au" => Deserialize::begin(&mut self.au), + "be" => Deserialize::begin(&mut self.be), + "bg" => Deserialize::begin(&mut self.bg), + "ca" => Deserialize::begin(&mut self.ca), + "ch" => Deserialize::begin(&mut self.ch), + "cl" => Deserialize::begin(&mut self.cl), + "co" => Deserialize::begin(&mut self.co), + "cy" => Deserialize::begin(&mut self.cy), + "cz" => Deserialize::begin(&mut self.cz), + "de" => Deserialize::begin(&mut self.de), + "dk" => Deserialize::begin(&mut self.dk), + "ee" => Deserialize::begin(&mut self.ee), + "es" => Deserialize::begin(&mut self.es), + "fi" => Deserialize::begin(&mut self.fi), + "fr" => Deserialize::begin(&mut self.fr), + "gb" => Deserialize::begin(&mut self.gb), + "gr" => Deserialize::begin(&mut self.gr), + "hr" => Deserialize::begin(&mut self.hr), + "hu" => Deserialize::begin(&mut self.hu), + "id" => Deserialize::begin(&mut self.id), + "ie" => Deserialize::begin(&mut self.ie), + "is" => Deserialize::begin(&mut self.is), + "it" => Deserialize::begin(&mut self.it), + "jp" => Deserialize::begin(&mut self.jp), + "kr" => Deserialize::begin(&mut self.kr), + "lt" => Deserialize::begin(&mut self.lt), + "lu" => Deserialize::begin(&mut self.lu), + "lv" => Deserialize::begin(&mut self.lv), + "mt" => Deserialize::begin(&mut self.mt), + "mx" => Deserialize::begin(&mut self.mx), + "my" => Deserialize::begin(&mut self.my), + "nl" => Deserialize::begin(&mut self.nl), + "no" => Deserialize::begin(&mut self.no), + "nz" => Deserialize::begin(&mut self.nz), + "pl" => Deserialize::begin(&mut self.pl), + "pt" => Deserialize::begin(&mut self.pt), + "ro" => Deserialize::begin(&mut self.ro), + "sa" => Deserialize::begin(&mut self.sa), + "se" => Deserialize::begin(&mut self.se), + "sg" => Deserialize::begin(&mut self.sg), + "si" => Deserialize::begin(&mut self.si), + "sk" => Deserialize::begin(&mut self.sk), + "th" => Deserialize::begin(&mut self.th), + "tr" => Deserialize::begin(&mut self.tr), + "us" => Deserialize::begin(&mut self.us), + "vn" => Deserialize::begin(&mut self.vn), + "za" => Deserialize::begin(&mut self.za), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + ae: Deserialize::default(), + at: Deserialize::default(), + au: Deserialize::default(), + be: Deserialize::default(), + bg: Deserialize::default(), + ca: Deserialize::default(), + ch: Deserialize::default(), + cl: Deserialize::default(), + co: Deserialize::default(), + cy: Deserialize::default(), + cz: Deserialize::default(), + de: Deserialize::default(), + dk: Deserialize::default(), + ee: Deserialize::default(), + es: Deserialize::default(), + fi: Deserialize::default(), + fr: Deserialize::default(), + gb: Deserialize::default(), + gr: Deserialize::default(), + hr: Deserialize::default(), + hu: Deserialize::default(), + id: Deserialize::default(), + ie: Deserialize::default(), + is: Deserialize::default(), + it: Deserialize::default(), + jp: Deserialize::default(), + kr: Deserialize::default(), + lt: Deserialize::default(), + lu: Deserialize::default(), + lv: Deserialize::default(), + mt: Deserialize::default(), + mx: Deserialize::default(), + my: Deserialize::default(), + nl: Deserialize::default(), + no: Deserialize::default(), + nz: Deserialize::default(), + pl: Deserialize::default(), + pt: Deserialize::default(), + ro: Deserialize::default(), + sa: Deserialize::default(), + se: Deserialize::default(), + sg: Deserialize::default(), + si: Deserialize::default(), + sk: Deserialize::default(), + th: Deserialize::default(), + tr: Deserialize::default(), + us: Deserialize::default(), + vn: Deserialize::default(), + za: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ae = self.ae.take()?; + let at = self.at.take()?; + let au = self.au.take()?; + let be = self.be.take()?; + let bg = self.bg.take()?; + let ca = self.ca.take()?; + let ch = self.ch.take()?; + let cl = self.cl.take()?; + let co = self.co.take()?; + let cy = self.cy.take()?; + let cz = self.cz.take()?; + let de = self.de.take()?; + let dk = self.dk.take()?; + let ee = self.ee.take()?; + let es = self.es.take()?; + let fi = self.fi.take()?; + let fr = self.fr.take()?; + let gb = self.gb.take()?; + let gr = self.gr.take()?; + let hr = self.hr.take()?; + let hu = self.hu.take()?; + let id = self.id.take()?; + let ie = self.ie.take()?; + let is = self.is.take()?; + let it = self.it.take()?; + let jp = self.jp.take()?; + let kr = self.kr.take()?; + let lt = self.lt.take()?; + let lu = self.lu.take()?; + let lv = self.lv.take()?; + let mt = self.mt.take()?; + let mx = self.mx.take()?; + let my = self.my.take()?; + let nl = self.nl.take()?; + let no = self.no.take()?; + let nz = self.nz.take()?; + let pl = self.pl.take()?; + let pt = self.pt.take()?; + let ro = self.ro.take()?; + let sa = self.sa.take()?; + let se = self.se.take()?; + let sg = self.sg.take()?; + let si = self.si.take()?; + let sk = self.sk.take()?; + let th = self.th.take()?; + let tr = self.tr.take()?; + let us = self.us.take()?; + let vn = self.vn.take()?; + let za = self.za.take()?; + + Some(Self::Out { + ae, + at, + au, + be, + bg, + ca, + ch, + cl, + co, + cy, + cz, + de, + dk, + ee, + es, + fi, + fr, + gb, + gr, + hr, + hu, + id, + ie, + is, + it, + jp, + kr, + lt, + lu, + lv, + mt, + mx, + my, + nl, + no, + nz, + pl, + pt, + ro, + sa, + se, + sg, + si, + sk, + th, + tr, + us, + vn, + za, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptions { + type Builder = TaxProductRegistrationsResourceCountryOptionsBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ae" => b.ae = Some(FromValueOpt::from_value(v)?), + "at" => b.at = Some(FromValueOpt::from_value(v)?), + "au" => b.au = Some(FromValueOpt::from_value(v)?), + "be" => b.be = Some(FromValueOpt::from_value(v)?), + "bg" => b.bg = Some(FromValueOpt::from_value(v)?), + "ca" => b.ca = Some(FromValueOpt::from_value(v)?), + "ch" => b.ch = Some(FromValueOpt::from_value(v)?), + "cl" => b.cl = Some(FromValueOpt::from_value(v)?), + "co" => b.co = Some(FromValueOpt::from_value(v)?), + "cy" => b.cy = Some(FromValueOpt::from_value(v)?), + "cz" => b.cz = Some(FromValueOpt::from_value(v)?), + "de" => b.de = Some(FromValueOpt::from_value(v)?), + "dk" => b.dk = Some(FromValueOpt::from_value(v)?), + "ee" => b.ee = Some(FromValueOpt::from_value(v)?), + "es" => b.es = Some(FromValueOpt::from_value(v)?), + "fi" => b.fi = Some(FromValueOpt::from_value(v)?), + "fr" => b.fr = Some(FromValueOpt::from_value(v)?), + "gb" => b.gb = Some(FromValueOpt::from_value(v)?), + "gr" => b.gr = Some(FromValueOpt::from_value(v)?), + "hr" => b.hr = Some(FromValueOpt::from_value(v)?), + "hu" => b.hu = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "ie" => b.ie = Some(FromValueOpt::from_value(v)?), + "is" => b.is = Some(FromValueOpt::from_value(v)?), + "it" => b.it = Some(FromValueOpt::from_value(v)?), + "jp" => b.jp = Some(FromValueOpt::from_value(v)?), + "kr" => b.kr = Some(FromValueOpt::from_value(v)?), + "lt" => b.lt = Some(FromValueOpt::from_value(v)?), + "lu" => b.lu = Some(FromValueOpt::from_value(v)?), + "lv" => b.lv = Some(FromValueOpt::from_value(v)?), + "mt" => b.mt = Some(FromValueOpt::from_value(v)?), + "mx" => b.mx = Some(FromValueOpt::from_value(v)?), + "my" => b.my = Some(FromValueOpt::from_value(v)?), + "nl" => b.nl = Some(FromValueOpt::from_value(v)?), + "no" => b.no = Some(FromValueOpt::from_value(v)?), + "nz" => b.nz = Some(FromValueOpt::from_value(v)?), + "pl" => b.pl = Some(FromValueOpt::from_value(v)?), + "pt" => b.pt = Some(FromValueOpt::from_value(v)?), + "ro" => b.ro = Some(FromValueOpt::from_value(v)?), + "sa" => b.sa = Some(FromValueOpt::from_value(v)?), + "se" => b.se = Some(FromValueOpt::from_value(v)?), + "sg" => b.sg = Some(FromValueOpt::from_value(v)?), + "si" => b.si = Some(FromValueOpt::from_value(v)?), + "sk" => b.sk = Some(FromValueOpt::from_value(v)?), + "th" => b.th = Some(FromValueOpt::from_value(v)?), + "tr" => b.tr = Some(FromValueOpt::from_value(v)?), + "us" => b.us = Some(FromValueOpt::from_value(v)?), + "vn" => b.vn = Some(FromValueOpt::from_value(v)?), + "za" => b.za = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_ca_province_standard.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_ca_province_standard.rs index 25ebd3e5c..95893f364 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_ca_province_standard.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_ca_province_standard.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard { /// Two-letter CA province code ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)). pub province: String, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder { + province: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard>, + builder: TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "province" => Deserialize::begin(&mut self.province), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { province: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let province = self.province.take()?; + + Some(Self::Out { province }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard { + type Builder = TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "province" => b.province = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_canada.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_canada.rs index c1e47c541..8f0766e89 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_canada.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_canada.rs @@ -1,12 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsCanada { - #[serde(skip_serializing_if = "Option::is_none")] - pub province_standard: - Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard>, + pub province_standard: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard>, /// Type of registration in Canada. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsCanadaType, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsCanadaBuilder { + province_standard: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard>>, + type_: Option<TaxProductRegistrationsResourceCountryOptionsCanadaType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsCanada { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsCanada>, + builder: TaxProductRegistrationsResourceCountryOptionsCanadaBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsCanada> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsCanadaBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsCanadaBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsCanada; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "province_standard" => Deserialize::begin(&mut self.province_standard), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { province_standard: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let province_standard = self.province_standard.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { province_standard, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsCanada { + type Builder = TaxProductRegistrationsResourceCountryOptionsCanadaBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsCanada { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsCanadaBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "province_standard" => b.province_standard = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of registration in Canada. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductRegistrationsResourceCountryOptionsCanadaType { @@ -60,10 +150,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOpti fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductRegistrationsResourceCountryOptionsCanadaType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductRegistrationsResourceCountryOptionsCanadaType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsCanadaType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductRegistrationsResourceCountryOptionsCanadaType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductRegistrationsResourceCountryOptionsCanadaType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsCanadaType); diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_default.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_default.rs index 40133e476..454796f59 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_default.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_default.rs @@ -1,9 +1,97 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsDefault { /// Type of registration in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsDefaultType, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsDefaultBuilder { + type_: Option<TaxProductRegistrationsResourceCountryOptionsDefaultType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsDefault { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsDefault>, + builder: TaxProductRegistrationsResourceCountryOptionsDefaultBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsDefault> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsDefaultBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsDefaultBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsDefault; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let type_ = self.type_.take()?; + + Some(Self::Out { type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsDefault { + type Builder = TaxProductRegistrationsResourceCountryOptionsDefaultBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsDefault { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsDefaultBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of registration in `country`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductRegistrationsResourceCountryOptionsDefaultType { @@ -51,10 +139,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOpti fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductRegistrationsResourceCountryOptionsDefaultType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductRegistrationsResourceCountryOptionsDefaultType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsDefaultType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductRegistrationsResourceCountryOptionsDefaultType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductRegistrationsResourceCountryOptionsDefaultType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsDefaultType); diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_eu_standard.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_eu_standard.rs index 748d439aa..ad77ee54b 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_eu_standard.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_eu_standard.rs @@ -1,9 +1,96 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsEuStandard { /// Place of supply scheme used in an EU standard registration. - pub place_of_supply_scheme: - TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme, + pub place_of_supply_scheme: TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder { + place_of_supply_scheme: Option<TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsEuStandard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsEuStandard>, + builder: TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsEuStandard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsEuStandard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "place_of_supply_scheme" => Deserialize::begin(&mut self.place_of_supply_scheme), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { place_of_supply_scheme: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let place_of_supply_scheme = self.place_of_supply_scheme.take()?; + + Some(Self::Out { place_of_supply_scheme }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsEuStandard { + type Builder = TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsEuStandard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "place_of_supply_scheme" => b.place_of_supply_scheme = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Place of supply scheme used in an EU standard registration. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { @@ -20,9 +107,7 @@ impl TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme } } -impl std::str::FromStr - for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme -{ +impl std::str::FromStr for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme::*; @@ -33,24 +118,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme -{ +impl std::fmt::Display for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme -{ +impl std::fmt::Debug for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme -{ +impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -58,12 +137,28 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme -{ +impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme); diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_europe.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_europe.rs index c428dc383..31d2ec62a 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_europe.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_europe.rs @@ -1,11 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsEurope { - #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEuStandard>, /// Type of registration in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsEuropeType, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsEuropeBuilder { + standard: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsEuStandard>>, + type_: Option<TaxProductRegistrationsResourceCountryOptionsEuropeType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsEurope { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsEurope>, + builder: TaxProductRegistrationsResourceCountryOptionsEuropeBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsEurope> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsEuropeBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsEuropeBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsEurope; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "standard" => Deserialize::begin(&mut self.standard), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { standard: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let standard = self.standard.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { standard, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsEurope { + type Builder = TaxProductRegistrationsResourceCountryOptionsEuropeBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsEurope { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsEuropeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "standard" => b.standard = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of registration in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductRegistrationsResourceCountryOptionsEuropeType { @@ -62,10 +153,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOpti fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductRegistrationsResourceCountryOptionsEuropeType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductRegistrationsResourceCountryOptionsEuropeType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsEuropeType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductRegistrationsResourceCountryOptionsEuropeType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductRegistrationsResourceCountryOptionsEuropeType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsEuropeType); diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_simplified.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_simplified.rs index 1d29bc159..a9ac96fcf 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_simplified.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_simplified.rs @@ -1,9 +1,97 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsSimplified { /// Type of registration in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsSimplifiedType, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder { + type_: Option<TaxProductRegistrationsResourceCountryOptionsSimplifiedType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsSimplified { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsSimplified>, + builder: TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsSimplified> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsSimplified; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let type_ = self.type_.take()?; + + Some(Self::Out { type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsSimplified { + type Builder = TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsSimplified { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of registration in `country`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductRegistrationsResourceCountryOptionsSimplifiedType { @@ -51,10 +139,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOpti fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductRegistrationsResourceCountryOptionsSimplifiedType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductRegistrationsResourceCountryOptionsSimplifiedType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsSimplifiedType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductRegistrationsResourceCountryOptionsSimplifiedType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductRegistrationsResourceCountryOptionsSimplifiedType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsSimplifiedType); diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_united_states.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_united_states.rs index a970b140d..7dcbbf9cb 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_united_states.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_united_states.rs @@ -1,17 +1,113 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsUnitedStates { - #[serde(skip_serializing_if = "Option::is_none")] - pub local_amusement_tax: - Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax>, - #[serde(skip_serializing_if = "Option::is_none")] - pub local_lease_tax: - Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax>, + pub local_amusement_tax: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax>, + pub local_lease_tax: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax>, /// Two-letter US state code ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)). pub state: String, /// Type of registration in the US. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsUnitedStatesType, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder { + local_amusement_tax: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax>>, + local_lease_tax: Option<Option<stripe_misc::TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax>>, + state: Option<String>, + type_: Option<TaxProductRegistrationsResourceCountryOptionsUnitedStatesType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsUnitedStates { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsUnitedStates>, + builder: TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsUnitedStates> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsUnitedStates; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "local_amusement_tax" => Deserialize::begin(&mut self.local_amusement_tax), + "local_lease_tax" => Deserialize::begin(&mut self.local_lease_tax), + "state" => Deserialize::begin(&mut self.state), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { local_amusement_tax: Deserialize::default(), local_lease_tax: Deserialize::default(), state: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let local_amusement_tax = self.local_amusement_tax.take()?; + let local_lease_tax = self.local_lease_tax.take()?; + let state = self.state.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { local_amusement_tax, local_lease_tax, state, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsUnitedStates { + type Builder = TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsUnitedStates { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "local_amusement_tax" => b.local_amusement_tax = Some(FromValueOpt::from_value(v)?), + "local_lease_tax" => b.local_lease_tax = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of registration in the US. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductRegistrationsResourceCountryOptionsUnitedStatesType { @@ -64,16 +160,28 @@ impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsUnitedSta serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TaxProductRegistrationsResourceCountryOptionsUnitedStatesType -{ +impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOptionsUnitedStatesType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductRegistrationsResourceCountryOptionsUnitedStatesType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductRegistrationsResourceCountryOptionsUnitedStatesType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsUnitedStatesType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductRegistrationsResourceCountryOptionsUnitedStatesType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductRegistrationsResourceCountryOptionsUnitedStatesType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsUnitedStatesType); diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_amusement_tax.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_amusement_tax.rs index 9ddcfee48..049386990 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_amusement_tax.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_amusement_tax.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax { /// A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction. pub jurisdiction: String, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder { + jurisdiction: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax>, + builder: TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "jurisdiction" => Deserialize::begin(&mut self.jurisdiction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { jurisdiction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let jurisdiction = self.jurisdiction.take()?; + + Some(Self::Out { jurisdiction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax { + type Builder = TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "jurisdiction" => b.jurisdiction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_lease_tax.rs b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_lease_tax.rs index 69c7fb567..8c8217f5a 100644 --- a/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_lease_tax.rs +++ b/generated/stripe_misc/src/tax_product_registrations_resource_country_options_us_local_lease_tax.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax { /// A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction. pub jurisdiction: String, } +#[cfg(feature = "min-ser")] +pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder { + jurisdiction: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax>, + builder: TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder, + } + + impl Visitor for Place<TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder { + type Out = TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "jurisdiction" => Deserialize::begin(&mut self.jurisdiction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { jurisdiction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let jurisdiction = self.jurisdiction.take()?; + + Some(Self::Out { jurisdiction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax { + type Builder = TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder; + } + + impl FromValueOpt for TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "jurisdiction" => b.jurisdiction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_customer_details.rs b/generated/stripe_misc/src/tax_product_resource_customer_details.rs index 3de071af8..403285721 100644 --- a/generated/stripe_misc/src/tax_product_resource_customer_details.rs +++ b/generated/stripe_misc/src/tax_product_resource_customer_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceCustomerDetails { /// The customer's postal address (for example, home or business location). pub address: Option<stripe_misc::TaxProductResourcePostalAddress>, @@ -11,6 +13,114 @@ pub struct TaxProductResourceCustomerDetails { /// The taxability override used for taxation. pub taxability_override: TaxProductResourceCustomerDetailsTaxabilityOverride, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceCustomerDetailsBuilder { + address: Option<Option<stripe_misc::TaxProductResourcePostalAddress>>, + address_source: Option<Option<TaxProductResourceCustomerDetailsAddressSource>>, + ip_address: Option<Option<String>>, + tax_ids: Option<Vec<stripe_misc::TaxProductResourceCustomerDetailsResourceTaxId>>, + taxability_override: Option<TaxProductResourceCustomerDetailsTaxabilityOverride>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceCustomerDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceCustomerDetails>, + builder: TaxProductResourceCustomerDetailsBuilder, + } + + impl Visitor for Place<TaxProductResourceCustomerDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceCustomerDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceCustomerDetailsBuilder { + type Out = TaxProductResourceCustomerDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "address_source" => Deserialize::begin(&mut self.address_source), + "ip_address" => Deserialize::begin(&mut self.ip_address), + "tax_ids" => Deserialize::begin(&mut self.tax_ids), + "taxability_override" => Deserialize::begin(&mut self.taxability_override), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + address_source: Deserialize::default(), + ip_address: Deserialize::default(), + tax_ids: Deserialize::default(), + taxability_override: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let address_source = self.address_source.take()?; + let ip_address = self.ip_address.take()?; + let tax_ids = self.tax_ids.take()?; + let taxability_override = self.taxability_override.take()?; + + Some(Self::Out { address, address_source, ip_address, tax_ids, taxability_override }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceCustomerDetails { + type Builder = TaxProductResourceCustomerDetailsBuilder; + } + + impl FromValueOpt for TaxProductResourceCustomerDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceCustomerDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "address_source" => b.address_source = Some(FromValueOpt::from_value(v)?), + "ip_address" => b.ip_address = Some(FromValueOpt::from_value(v)?), + "tax_ids" => b.tax_ids = Some(FromValueOpt::from_value(v)?), + "taxability_override" => b.taxability_override = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of customer address provided. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductResourceCustomerDetailsAddressSource { @@ -61,13 +171,27 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceCustomerDetailsAddressSo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceCustomerDetailsAddressSource", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceCustomerDetailsAddressSource")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceCustomerDetailsAddressSource { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceCustomerDetailsAddressSource> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceCustomerDetailsAddressSource::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceCustomerDetailsAddressSource); /// The taxability override used for taxation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductResourceCustomerDetailsTaxabilityOverride { @@ -121,10 +245,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceCustomerDetailsTaxabilit fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceCustomerDetailsTaxabilityOverride", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceCustomerDetailsTaxabilityOverride")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceCustomerDetailsTaxabilityOverride { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceCustomerDetailsTaxabilityOverride> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceCustomerDetailsTaxabilityOverride::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceCustomerDetailsTaxabilityOverride); diff --git a/generated/stripe_misc/src/tax_product_resource_customer_details_resource_tax_id.rs b/generated/stripe_misc/src/tax_product_resource_customer_details_resource_tax_id.rs index 1e89a4fdc..34143368c 100644 --- a/generated/stripe_misc/src/tax_product_resource_customer_details_resource_tax_id.rs +++ b/generated/stripe_misc/src/tax_product_resource_customer_details_resource_tax_id.rs @@ -1,11 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceCustomerDetailsResourceTaxId { /// The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxProductResourceCustomerDetailsResourceTaxIdType, /// The value of the tax ID. pub value: String, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceCustomerDetailsResourceTaxIdBuilder { + type_: Option<TaxProductResourceCustomerDetailsResourceTaxIdType>, + value: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceCustomerDetailsResourceTaxId { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceCustomerDetailsResourceTaxId>, + builder: TaxProductResourceCustomerDetailsResourceTaxIdBuilder, + } + + impl Visitor for Place<TaxProductResourceCustomerDetailsResourceTaxId> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceCustomerDetailsResourceTaxIdBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceCustomerDetailsResourceTaxIdBuilder { + type Out = TaxProductResourceCustomerDetailsResourceTaxId; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "type" => Deserialize::begin(&mut self.type_), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let type_ = self.type_.take()?; + let value = self.value.take()?; + + Some(Self::Out { type_, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceCustomerDetailsResourceTaxId { + type Builder = TaxProductResourceCustomerDetailsResourceTaxIdBuilder; + } + + impl FromValueOpt for TaxProductResourceCustomerDetailsResourceTaxId { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceCustomerDetailsResourceTaxIdBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductResourceCustomerDetailsResourceTaxIdType { @@ -251,10 +343,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceCustomerDetailsResourceT fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceCustomerDetailsResourceTaxIdType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceCustomerDetailsResourceTaxIdType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceCustomerDetailsResourceTaxIdType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceCustomerDetailsResourceTaxIdType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceCustomerDetailsResourceTaxIdType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceCustomerDetailsResourceTaxIdType); diff --git a/generated/stripe_misc/src/tax_product_resource_jurisdiction.rs b/generated/stripe_misc/src/tax_product_resource_jurisdiction.rs index 47fd98460..a43ae6ce8 100644 --- a/generated/stripe_misc/src/tax_product_resource_jurisdiction.rs +++ b/generated/stripe_misc/src/tax_product_resource_jurisdiction.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceJurisdiction { /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). pub country: String, @@ -10,6 +12,104 @@ pub struct TaxProductResourceJurisdiction { /// For example, "NY" for New York, United States. pub state: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceJurisdictionBuilder { + country: Option<String>, + display_name: Option<String>, + level: Option<TaxProductResourceJurisdictionLevel>, + state: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceJurisdiction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceJurisdiction>, + builder: TaxProductResourceJurisdictionBuilder, + } + + impl Visitor for Place<TaxProductResourceJurisdiction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceJurisdictionBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceJurisdictionBuilder { + type Out = TaxProductResourceJurisdiction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + "display_name" => Deserialize::begin(&mut self.display_name), + "level" => Deserialize::begin(&mut self.level), + "state" => Deserialize::begin(&mut self.state), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default(), display_name: Deserialize::default(), level: Deserialize::default(), state: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + let display_name = self.display_name.take()?; + let level = self.level.take()?; + let state = self.state.take()?; + + Some(Self::Out { country, display_name, level, state }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceJurisdiction { + type Builder = TaxProductResourceJurisdictionBuilder; + } + + impl FromValueOpt for TaxProductResourceJurisdiction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceJurisdictionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "level" => b.level = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates the level of the jurisdiction imposing the tax. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductResourceJurisdictionLevel { @@ -69,8 +169,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceJurisdictionLevel { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TaxProductResourceJurisdictionLevel") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceJurisdictionLevel")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceJurisdictionLevel { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceJurisdictionLevel> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceJurisdictionLevel::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceJurisdictionLevel); diff --git a/generated/stripe_misc/src/tax_product_resource_line_item_tax_breakdown.rs b/generated/stripe_misc/src/tax_product_resource_line_item_tax_breakdown.rs index b69be54d9..ea9050be3 100644 --- a/generated/stripe_misc/src/tax_product_resource_line_item_tax_breakdown.rs +++ b/generated/stripe_misc/src/tax_product_resource_line_item_tax_breakdown.rs @@ -1,6 +1,8 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceLineItemTaxBreakdown { - /// The amount of tax, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount of tax, in integer cents. pub amount: i64, pub jurisdiction: stripe_misc::TaxProductResourceJurisdiction, /// Indicates whether the jurisdiction was determined by the origin (merchant's address) or destination (customer's address). @@ -11,9 +13,122 @@ pub struct TaxProductResourceLineItemTaxBreakdown { /// The reasoning behind this tax, for example, if the product is tax exempt. /// The possible values for this field may be extended as new tax rules are supported. pub taxability_reason: TaxProductResourceLineItemTaxBreakdownTaxabilityReason, - /// The amount on which tax is calculated, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount on which tax is calculated, in integer cents. pub taxable_amount: i64, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceLineItemTaxBreakdownBuilder { + amount: Option<i64>, + jurisdiction: Option<stripe_misc::TaxProductResourceJurisdiction>, + sourcing: Option<TaxProductResourceLineItemTaxBreakdownSourcing>, + tax_rate_details: Option<Option<stripe_misc::TaxProductResourceLineItemTaxRateDetails>>, + taxability_reason: Option<TaxProductResourceLineItemTaxBreakdownTaxabilityReason>, + taxable_amount: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceLineItemTaxBreakdown { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceLineItemTaxBreakdown>, + builder: TaxProductResourceLineItemTaxBreakdownBuilder, + } + + impl Visitor for Place<TaxProductResourceLineItemTaxBreakdown> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceLineItemTaxBreakdownBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceLineItemTaxBreakdownBuilder { + type Out = TaxProductResourceLineItemTaxBreakdown; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "jurisdiction" => Deserialize::begin(&mut self.jurisdiction), + "sourcing" => Deserialize::begin(&mut self.sourcing), + "tax_rate_details" => Deserialize::begin(&mut self.tax_rate_details), + "taxability_reason" => Deserialize::begin(&mut self.taxability_reason), + "taxable_amount" => Deserialize::begin(&mut self.taxable_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + jurisdiction: Deserialize::default(), + sourcing: Deserialize::default(), + tax_rate_details: Deserialize::default(), + taxability_reason: Deserialize::default(), + taxable_amount: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let jurisdiction = self.jurisdiction.take()?; + let sourcing = self.sourcing.take()?; + let tax_rate_details = self.tax_rate_details.take()?; + let taxability_reason = self.taxability_reason.take()?; + let taxable_amount = self.taxable_amount.take()?; + + Some(Self::Out { amount, jurisdiction, sourcing, tax_rate_details, taxability_reason, taxable_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceLineItemTaxBreakdown { + type Builder = TaxProductResourceLineItemTaxBreakdownBuilder; + } + + impl FromValueOpt for TaxProductResourceLineItemTaxBreakdown { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceLineItemTaxBreakdownBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "jurisdiction" => b.jurisdiction = Some(FromValueOpt::from_value(v)?), + "sourcing" => b.sourcing = Some(FromValueOpt::from_value(v)?), + "tax_rate_details" => b.tax_rate_details = Some(FromValueOpt::from_value(v)?), + "taxability_reason" => b.taxability_reason = Some(FromValueOpt::from_value(v)?), + "taxable_amount" => b.taxable_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates whether the jurisdiction was determined by the origin (merchant's address) or destination (customer's address). #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductResourceLineItemTaxBreakdownSourcing { @@ -64,13 +179,27 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceLineItemTaxBreakdownSour fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceLineItemTaxBreakdownSourcing", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceLineItemTaxBreakdownSourcing")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceLineItemTaxBreakdownSourcing { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceLineItemTaxBreakdownSourcing> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceLineItemTaxBreakdownSourcing::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceLineItemTaxBreakdownSourcing); /// The reasoning behind this tax, for example, if the product is tax exempt. /// The possible values for this field may be extended as new tax rules are supported. #[derive(Copy, Clone, Eq, PartialEq)] @@ -165,7 +294,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceLineItemTaxBreakdownTaxa fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s) - .unwrap_or(TaxProductResourceLineItemTaxBreakdownTaxabilityReason::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceLineItemTaxBreakdownTaxabilityReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceLineItemTaxBreakdownTaxabilityReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceLineItemTaxBreakdownTaxabilityReason::from_str(s).unwrap_or(TaxProductResourceLineItemTaxBreakdownTaxabilityReason::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceLineItemTaxBreakdownTaxabilityReason); diff --git a/generated/stripe_misc/src/tax_product_resource_line_item_tax_rate_details.rs b/generated/stripe_misc/src/tax_product_resource_line_item_tax_rate_details.rs index 253bd40a4..85624bb70 100644 --- a/generated/stripe_misc/src/tax_product_resource_line_item_tax_rate_details.rs +++ b/generated/stripe_misc/src/tax_product_resource_line_item_tax_rate_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceLineItemTaxRateDetails { /// A localized display name for tax type, intended to be human-readable. /// For example, "Local Sales and Use Tax", "Value-added tax (VAT)", or "Umsatzsteuer (USt.)". @@ -8,6 +10,100 @@ pub struct TaxProductResourceLineItemTaxRateDetails { /// The tax type, such as `vat` or `sales_tax`. pub tax_type: TaxProductResourceLineItemTaxRateDetailsTaxType, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceLineItemTaxRateDetailsBuilder { + display_name: Option<String>, + percentage_decimal: Option<String>, + tax_type: Option<TaxProductResourceLineItemTaxRateDetailsTaxType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceLineItemTaxRateDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceLineItemTaxRateDetails>, + builder: TaxProductResourceLineItemTaxRateDetailsBuilder, + } + + impl Visitor for Place<TaxProductResourceLineItemTaxRateDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceLineItemTaxRateDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceLineItemTaxRateDetailsBuilder { + type Out = TaxProductResourceLineItemTaxRateDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "display_name" => Deserialize::begin(&mut self.display_name), + "percentage_decimal" => Deserialize::begin(&mut self.percentage_decimal), + "tax_type" => Deserialize::begin(&mut self.tax_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { display_name: Deserialize::default(), percentage_decimal: Deserialize::default(), tax_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let display_name = self.display_name.take()?; + let percentage_decimal = self.percentage_decimal.take()?; + let tax_type = self.tax_type.take()?; + + Some(Self::Out { display_name, percentage_decimal, tax_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceLineItemTaxRateDetails { + type Builder = TaxProductResourceLineItemTaxRateDetailsBuilder; + } + + impl FromValueOpt for TaxProductResourceLineItemTaxRateDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceLineItemTaxRateDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "percentage_decimal" => b.percentage_decimal = Some(FromValueOpt::from_value(v)?), + "tax_type" => b.tax_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The tax type, such as `vat` or `sales_tax`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductResourceLineItemTaxRateDetailsTaxType { @@ -88,10 +184,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceLineItemTaxRateDetailsTa fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceLineItemTaxRateDetailsTaxType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceLineItemTaxRateDetailsTaxType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceLineItemTaxRateDetailsTaxType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceLineItemTaxRateDetailsTaxType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceLineItemTaxRateDetailsTaxType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceLineItemTaxRateDetailsTaxType); diff --git a/generated/stripe_misc/src/tax_product_resource_postal_address.rs b/generated/stripe_misc/src/tax_product_resource_postal_address.rs index b048f8c16..621a3bf42 100644 --- a/generated/stripe_misc/src/tax_product_resource_postal_address.rs +++ b/generated/stripe_misc/src/tax_product_resource_postal_address.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourcePostalAddress { /// City, district, suburb, town, or village. pub city: Option<String>, @@ -14,3 +16,116 @@ pub struct TaxProductResourcePostalAddress { /// Example: "NY" or "TX". pub state: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourcePostalAddressBuilder { + city: Option<Option<String>>, + country: Option<String>, + line1: Option<Option<String>>, + line2: Option<Option<String>>, + postal_code: Option<Option<String>>, + state: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourcePostalAddress { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourcePostalAddress>, + builder: TaxProductResourcePostalAddressBuilder, + } + + impl Visitor for Place<TaxProductResourcePostalAddress> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourcePostalAddressBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourcePostalAddressBuilder { + type Out = TaxProductResourcePostalAddress; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "city" => Deserialize::begin(&mut self.city), + "country" => Deserialize::begin(&mut self.country), + "line1" => Deserialize::begin(&mut self.line1), + "line2" => Deserialize::begin(&mut self.line2), + "postal_code" => Deserialize::begin(&mut self.postal_code), + "state" => Deserialize::begin(&mut self.state), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + city: Deserialize::default(), + country: Deserialize::default(), + line1: Deserialize::default(), + line2: Deserialize::default(), + postal_code: Deserialize::default(), + state: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let city = self.city.take()?; + let country = self.country.take()?; + let line1 = self.line1.take()?; + let line2 = self.line2.take()?; + let postal_code = self.postal_code.take()?; + let state = self.state.take()?; + + Some(Self::Out { city, country, line1, line2, postal_code, state }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourcePostalAddress { + type Builder = TaxProductResourcePostalAddressBuilder; + } + + impl FromValueOpt for TaxProductResourcePostalAddress { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourcePostalAddressBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "city" => b.city = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "line1" => b.line1 = Some(FromValueOpt::from_value(v)?), + "line2" => b.line2 = Some(FromValueOpt::from_value(v)?), + "postal_code" => b.postal_code = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_tax_breakdown.rs b/generated/stripe_misc/src/tax_product_resource_tax_breakdown.rs index ee5b2c3e5..d9a8fe6c0 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_breakdown.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_breakdown.rs @@ -1,6 +1,8 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxBreakdown { - /// The amount of tax, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount of tax, in integer cents. pub amount: i64, /// Specifies whether the tax amount is included in the line item amount. pub inclusive: bool, @@ -8,9 +10,117 @@ pub struct TaxProductResourceTaxBreakdown { /// The reasoning behind this tax, for example, if the product is tax exempt. /// We might extend the possible values for this field to support new tax rules. pub taxability_reason: TaxProductResourceTaxBreakdownTaxabilityReason, - /// The amount on which tax is calculated, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount on which tax is calculated, in integer cents. pub taxable_amount: i64, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxBreakdownBuilder { + amount: Option<i64>, + inclusive: Option<bool>, + tax_rate_details: Option<stripe_misc::TaxProductResourceTaxRateDetails>, + taxability_reason: Option<TaxProductResourceTaxBreakdownTaxabilityReason>, + taxable_amount: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxBreakdown { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxBreakdown>, + builder: TaxProductResourceTaxBreakdownBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxBreakdown> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxBreakdownBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxBreakdownBuilder { + type Out = TaxProductResourceTaxBreakdown; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "inclusive" => Deserialize::begin(&mut self.inclusive), + "tax_rate_details" => Deserialize::begin(&mut self.tax_rate_details), + "taxability_reason" => Deserialize::begin(&mut self.taxability_reason), + "taxable_amount" => Deserialize::begin(&mut self.taxable_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + inclusive: Deserialize::default(), + tax_rate_details: Deserialize::default(), + taxability_reason: Deserialize::default(), + taxable_amount: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let inclusive = self.inclusive.take()?; + let tax_rate_details = self.tax_rate_details.take()?; + let taxability_reason = self.taxability_reason.take()?; + let taxable_amount = self.taxable_amount.take()?; + + Some(Self::Out { amount, inclusive, tax_rate_details, taxability_reason, taxable_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxBreakdown { + type Builder = TaxProductResourceTaxBreakdownBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxBreakdown { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxBreakdownBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "inclusive" => b.inclusive = Some(FromValueOpt::from_value(v)?), + "tax_rate_details" => b.tax_rate_details = Some(FromValueOpt::from_value(v)?), + "taxability_reason" => b.taxability_reason = Some(FromValueOpt::from_value(v)?), + "taxable_amount" => b.taxable_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reasoning behind this tax, for example, if the product is tax exempt. /// We might extend the possible values for this field to support new tax rules. #[derive(Copy, Clone, Eq, PartialEq)] @@ -105,6 +215,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxBreakdownTaxabilityRe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(TaxProductResourceTaxBreakdownTaxabilityReason::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceTaxBreakdownTaxabilityReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceTaxBreakdownTaxabilityReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceTaxBreakdownTaxabilityReason::from_str(s).unwrap_or(TaxProductResourceTaxBreakdownTaxabilityReason::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxBreakdownTaxabilityReason); diff --git a/generated/stripe_misc/src/tax_product_resource_tax_calculation_shipping_cost.rs b/generated/stripe_misc/src/tax_product_resource_tax_calculation_shipping_cost.rs index 0ed83962c..741d0ccc9 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_calculation_shipping_cost.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_calculation_shipping_cost.rs @@ -1,23 +1,136 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxCalculationShippingCost { - /// The shipping amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The shipping amount in integer cents. /// If `tax_behavior=inclusive`, then this amount includes taxes. /// Otherwise, taxes were calculated on top of this amount. pub amount: i64, - /// The amount of tax calculated for shipping, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount of tax calculated for shipping, in integer cents. pub amount_tax: i64, /// The ID of an existing [ShippingRate](https://stripe.com/docs/api/shipping_rates/object). - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_rate: Option<String>, /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. pub tax_behavior: TaxProductResourceTaxCalculationShippingCostTaxBehavior, /// Detailed account of taxes relevant to shipping cost. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_breakdown: Option<Vec<stripe_misc::TaxProductResourceLineItemTaxBreakdown>>, /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for shipping. pub tax_code: String, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxCalculationShippingCostBuilder { + amount: Option<i64>, + amount_tax: Option<i64>, + shipping_rate: Option<Option<String>>, + tax_behavior: Option<TaxProductResourceTaxCalculationShippingCostTaxBehavior>, + tax_breakdown: Option<Option<Vec<stripe_misc::TaxProductResourceLineItemTaxBreakdown>>>, + tax_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxCalculationShippingCost { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxCalculationShippingCost>, + builder: TaxProductResourceTaxCalculationShippingCostBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxCalculationShippingCost> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxCalculationShippingCostBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxCalculationShippingCostBuilder { + type Out = TaxProductResourceTaxCalculationShippingCost; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "shipping_rate" => Deserialize::begin(&mut self.shipping_rate), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tax_breakdown" => Deserialize::begin(&mut self.tax_breakdown), + "tax_code" => Deserialize::begin(&mut self.tax_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_tax: Deserialize::default(), + shipping_rate: Deserialize::default(), + tax_behavior: Deserialize::default(), + tax_breakdown: Deserialize::default(), + tax_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_tax = self.amount_tax.take()?; + let shipping_rate = self.shipping_rate.take()?; + let tax_behavior = self.tax_behavior.take()?; + let tax_breakdown = self.tax_breakdown.take()?; + let tax_code = self.tax_code.take()?; + + Some(Self::Out { amount, amount_tax, shipping_rate, tax_behavior, tax_breakdown, tax_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxCalculationShippingCost { + type Builder = TaxProductResourceTaxCalculationShippingCostBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxCalculationShippingCost { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxCalculationShippingCostBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "shipping_rate" => b.shipping_rate = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tax_breakdown" => b.tax_breakdown = Some(FromValueOpt::from_value(v)?), + "tax_code" => b.tax_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. #[derive(Copy, Clone, Eq, PartialEq)] @@ -69,10 +182,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxCalculationShippingCo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceTaxCalculationShippingCostTaxBehavior", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceTaxCalculationShippingCostTaxBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceTaxCalculationShippingCostTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceTaxCalculationShippingCostTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceTaxCalculationShippingCostTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxCalculationShippingCostTaxBehavior); diff --git a/generated/stripe_misc/src/tax_product_resource_tax_rate_details.rs b/generated/stripe_misc/src/tax_product_resource_tax_rate_details.rs index 8a300f041..dd961af61 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_rate_details.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_rate_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxRateDetails { /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). pub country: Option<String>, @@ -9,6 +11,104 @@ pub struct TaxProductResourceTaxRateDetails { /// The tax type, such as `vat` or `sales_tax`. pub tax_type: Option<TaxProductResourceTaxRateDetailsTaxType>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxRateDetailsBuilder { + country: Option<Option<String>>, + percentage_decimal: Option<String>, + state: Option<Option<String>>, + tax_type: Option<Option<TaxProductResourceTaxRateDetailsTaxType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxRateDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxRateDetails>, + builder: TaxProductResourceTaxRateDetailsBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxRateDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxRateDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxRateDetailsBuilder { + type Out = TaxProductResourceTaxRateDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + "percentage_decimal" => Deserialize::begin(&mut self.percentage_decimal), + "state" => Deserialize::begin(&mut self.state), + "tax_type" => Deserialize::begin(&mut self.tax_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default(), percentage_decimal: Deserialize::default(), state: Deserialize::default(), tax_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + let percentage_decimal = self.percentage_decimal.take()?; + let state = self.state.take()?; + let tax_type = self.tax_type.take()?; + + Some(Self::Out { country, percentage_decimal, state, tax_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxRateDetails { + type Builder = TaxProductResourceTaxRateDetailsBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxRateDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxRateDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "percentage_decimal" => b.percentage_decimal = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + "tax_type" => b.tax_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The tax type, such as `vat` or `sales_tax`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxProductResourceTaxRateDetailsTaxType { @@ -89,8 +189,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxRateDetailsTaxType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TaxProductResourceTaxRateDetailsTaxType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceTaxRateDetailsTaxType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceTaxRateDetailsTaxType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceTaxRateDetailsTaxType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceTaxRateDetailsTaxType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxRateDetailsTaxType); diff --git a/generated/stripe_misc/src/tax_product_resource_tax_settings_defaults.rs b/generated/stripe_misc/src/tax_product_resource_tax_settings_defaults.rs index c883b10f6..44a2c79cf 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_settings_defaults.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_settings_defaults.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxSettingsDefaults { /// Default [tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#tax-behavior) used to specify whether the price is considered inclusive of taxes or exclusive of taxes. /// If the item's price has a tax behavior set, it will take precedence over the default tax behavior. @@ -6,6 +8,96 @@ pub struct TaxProductResourceTaxSettingsDefaults { /// Default [tax code](https://stripe.com/docs/tax/tax-categories) used to classify your products and prices. pub tax_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxSettingsDefaultsBuilder { + tax_behavior: Option<Option<TaxProductResourceTaxSettingsDefaultsTaxBehavior>>, + tax_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxSettingsDefaults { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxSettingsDefaults>, + builder: TaxProductResourceTaxSettingsDefaultsBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxSettingsDefaults> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxSettingsDefaultsBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxSettingsDefaultsBuilder { + type Out = TaxProductResourceTaxSettingsDefaults; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tax_code" => Deserialize::begin(&mut self.tax_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_behavior: Deserialize::default(), tax_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let tax_behavior = self.tax_behavior.take()?; + let tax_code = self.tax_code.take()?; + + Some(Self::Out { tax_behavior, tax_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxSettingsDefaults { + type Builder = TaxProductResourceTaxSettingsDefaultsBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxSettingsDefaults { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxSettingsDefaultsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tax_code" => b.tax_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Default [tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#tax-behavior) used to specify whether the price is considered inclusive of taxes or exclusive of taxes. /// If the item's price has a tax behavior set, it will take precedence over the default tax behavior. #[derive(Copy, Clone, Eq, PartialEq)] @@ -60,10 +152,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxSettingsDefaultsTaxBe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceTaxSettingsDefaultsTaxBehavior", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceTaxSettingsDefaultsTaxBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceTaxSettingsDefaultsTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceTaxSettingsDefaultsTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceTaxSettingsDefaultsTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxSettingsDefaultsTaxBehavior); diff --git a/generated/stripe_misc/src/tax_product_resource_tax_settings_head_office.rs b/generated/stripe_misc/src/tax_product_resource_tax_settings_head_office.rs index 403641525..29acc7043 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_settings_head_office.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_settings_head_office.rs @@ -1,4 +1,92 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxSettingsHeadOffice { pub address: stripe_shared::Address, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxSettingsHeadOfficeBuilder { + address: Option<stripe_shared::Address>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxSettingsHeadOffice { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxSettingsHeadOffice>, + builder: TaxProductResourceTaxSettingsHeadOfficeBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxSettingsHeadOffice> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxSettingsHeadOfficeBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxSettingsHeadOfficeBuilder { + type Out = TaxProductResourceTaxSettingsHeadOffice; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + + Some(Self::Out { address }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxSettingsHeadOffice { + type Builder = TaxProductResourceTaxSettingsHeadOfficeBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxSettingsHeadOffice { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxSettingsHeadOfficeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details.rs b/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details.rs index f31f4308f..b992c6dcc 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details.rs @@ -1,7 +1,97 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxSettingsStatusDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub active: Option<stripe_misc::TaxProductResourceTaxSettingsStatusDetailsResourceActive>, - #[serde(skip_serializing_if = "Option::is_none")] pub pending: Option<stripe_misc::TaxProductResourceTaxSettingsStatusDetailsResourcePending>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxSettingsStatusDetailsBuilder { + active: Option<Option<stripe_misc::TaxProductResourceTaxSettingsStatusDetailsResourceActive>>, + pending: Option<Option<stripe_misc::TaxProductResourceTaxSettingsStatusDetailsResourcePending>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxSettingsStatusDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxSettingsStatusDetails>, + builder: TaxProductResourceTaxSettingsStatusDetailsBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxSettingsStatusDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxSettingsStatusDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxSettingsStatusDetailsBuilder { + type Out = TaxProductResourceTaxSettingsStatusDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "pending" => Deserialize::begin(&mut self.pending), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { active: Deserialize::default(), pending: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let pending = self.pending.take()?; + + Some(Self::Out { active, pending }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxSettingsStatusDetails { + type Builder = TaxProductResourceTaxSettingsStatusDetailsBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxSettingsStatusDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxSettingsStatusDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "pending" => b.pending = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_active.rs b/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_active.rs index f55dff9ac..24f29ffd7 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_active.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_active.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxSettingsStatusDetailsResourceActive {} +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxSettingsStatusDetailsResourceActive { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxSettingsStatusDetailsResourceActive>, + builder: TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxSettingsStatusDetailsResourceActive> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder { + type Out = TaxProductResourceTaxSettingsStatusDetailsResourceActive; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxSettingsStatusDetailsResourceActive { + type Builder = TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxSettingsStatusDetailsResourceActive { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_pending.rs b/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_pending.rs index 4aa35d5b8..a8fb3daa9 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_pending.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_settings_status_details_resource_pending.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxSettingsStatusDetailsResourcePending { /// The list of missing fields that are required to perform calculations. /// It includes the entry `head_office` when the status is `pending`. @@ -6,3 +8,89 @@ pub struct TaxProductResourceTaxSettingsStatusDetailsResourcePending { /// Calculations can fail if missing fields aren't explicitly provided on every call. pub missing_fields: Option<Vec<String>>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder { + missing_fields: Option<Option<Vec<String>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxSettingsStatusDetailsResourcePending { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxSettingsStatusDetailsResourcePending>, + builder: TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxSettingsStatusDetailsResourcePending> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder { + type Out = TaxProductResourceTaxSettingsStatusDetailsResourcePending; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "missing_fields" => Deserialize::begin(&mut self.missing_fields), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { missing_fields: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let missing_fields = self.missing_fields.take()?; + + Some(Self::Out { missing_fields }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxSettingsStatusDetailsResourcePending { + type Builder = TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxSettingsStatusDetailsResourcePending { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "missing_fields" => b.missing_fields = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_tax_transaction_line_item_resource_reversal.rs b/generated/stripe_misc/src/tax_product_resource_tax_transaction_line_item_resource_reversal.rs index 076e5937d..d63e01d32 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_transaction_line_item_resource_reversal.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_transaction_line_item_resource_reversal.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxTransactionLineItemResourceReversal { /// The `id` of the line item to reverse in the original transaction. pub original_line_item: String, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxTransactionLineItemResourceReversalBuilder { + original_line_item: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxTransactionLineItemResourceReversal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxTransactionLineItemResourceReversal>, + builder: TaxProductResourceTaxTransactionLineItemResourceReversalBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxTransactionLineItemResourceReversal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxTransactionLineItemResourceReversalBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxTransactionLineItemResourceReversalBuilder { + type Out = TaxProductResourceTaxTransactionLineItemResourceReversal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "original_line_item" => Deserialize::begin(&mut self.original_line_item), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { original_line_item: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let original_line_item = self.original_line_item.take()?; + + Some(Self::Out { original_line_item }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxTransactionLineItemResourceReversal { + type Builder = TaxProductResourceTaxTransactionLineItemResourceReversalBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxTransactionLineItemResourceReversal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxTransactionLineItemResourceReversalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "original_line_item" => b.original_line_item = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_tax_transaction_resource_reversal.rs b/generated/stripe_misc/src/tax_product_resource_tax_transaction_resource_reversal.rs index fee5e9769..d859c2442 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_transaction_resource_reversal.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_transaction_resource_reversal.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxTransactionResourceReversal { /// The `id` of the reversed `Transaction` object. pub original_transaction: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxTransactionResourceReversalBuilder { + original_transaction: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxTransactionResourceReversal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxTransactionResourceReversal>, + builder: TaxProductResourceTaxTransactionResourceReversalBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxTransactionResourceReversal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxTransactionResourceReversalBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxTransactionResourceReversalBuilder { + type Out = TaxProductResourceTaxTransactionResourceReversal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "original_transaction" => Deserialize::begin(&mut self.original_transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { original_transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let original_transaction = self.original_transaction.take()?; + + Some(Self::Out { original_transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxTransactionResourceReversal { + type Builder = TaxProductResourceTaxTransactionResourceReversalBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxTransactionResourceReversal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxTransactionResourceReversalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "original_transaction" => b.original_transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/tax_product_resource_tax_transaction_shipping_cost.rs b/generated/stripe_misc/src/tax_product_resource_tax_transaction_shipping_cost.rs index c23e6bb91..df7911e4e 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_transaction_shipping_cost.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_transaction_shipping_cost.rs @@ -1,24 +1,137 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxProductResourceTaxTransactionShippingCost { - /// The shipping amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The shipping amount in integer cents. /// If `tax_behavior=inclusive`, then this amount includes taxes. /// Otherwise, taxes were calculated on top of this amount. pub amount: i64, - /// The amount of tax calculated for shipping, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount of tax calculated for shipping, in integer cents. pub amount_tax: i64, /// The ID of an existing [ShippingRate](https://stripe.com/docs/api/shipping_rates/object). - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_rate: Option<String>, /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. pub tax_behavior: TaxProductResourceTaxTransactionShippingCostTaxBehavior, /// Detailed account of taxes relevant to shipping cost. /// (It is not populated for the transaction resource object and will be removed in the next API version.). - #[serde(skip_serializing_if = "Option::is_none")] pub tax_breakdown: Option<Vec<stripe_misc::TaxProductResourceLineItemTaxBreakdown>>, /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for shipping. pub tax_code: String, } +#[cfg(feature = "min-ser")] +pub struct TaxProductResourceTaxTransactionShippingCostBuilder { + amount: Option<i64>, + amount_tax: Option<i64>, + shipping_rate: Option<Option<String>>, + tax_behavior: Option<TaxProductResourceTaxTransactionShippingCostTaxBehavior>, + tax_breakdown: Option<Option<Vec<stripe_misc::TaxProductResourceLineItemTaxBreakdown>>>, + tax_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxProductResourceTaxTransactionShippingCost { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxProductResourceTaxTransactionShippingCost>, + builder: TaxProductResourceTaxTransactionShippingCostBuilder, + } + + impl Visitor for Place<TaxProductResourceTaxTransactionShippingCost> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxProductResourceTaxTransactionShippingCostBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxProductResourceTaxTransactionShippingCostBuilder { + type Out = TaxProductResourceTaxTransactionShippingCost; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "shipping_rate" => Deserialize::begin(&mut self.shipping_rate), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tax_breakdown" => Deserialize::begin(&mut self.tax_breakdown), + "tax_code" => Deserialize::begin(&mut self.tax_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_tax: Deserialize::default(), + shipping_rate: Deserialize::default(), + tax_behavior: Deserialize::default(), + tax_breakdown: Deserialize::default(), + tax_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_tax = self.amount_tax.take()?; + let shipping_rate = self.shipping_rate.take()?; + let tax_behavior = self.tax_behavior.take()?; + let tax_breakdown = self.tax_breakdown.take()?; + let tax_code = self.tax_code.take()?; + + Some(Self::Out { amount, amount_tax, shipping_rate, tax_behavior, tax_breakdown, tax_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxProductResourceTaxTransactionShippingCost { + type Builder = TaxProductResourceTaxTransactionShippingCostBuilder; + } + + impl FromValueOpt for TaxProductResourceTaxTransactionShippingCost { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxProductResourceTaxTransactionShippingCostBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "shipping_rate" => b.shipping_rate = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tax_breakdown" => b.tax_breakdown = Some(FromValueOpt::from_value(v)?), + "tax_code" => b.tax_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. #[derive(Copy, Clone, Eq, PartialEq)] @@ -70,10 +183,24 @@ impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxTransactionShippingCo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TaxProductResourceTaxTransactionShippingCostTaxBehavior", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxProductResourceTaxTransactionShippingCostTaxBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxProductResourceTaxTransactionShippingCostTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxProductResourceTaxTransactionShippingCostTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxProductResourceTaxTransactionShippingCostTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxTransactionShippingCostTaxBehavior); diff --git a/generated/stripe_misc/src/tax_registration/requests.rs b/generated/stripe_misc/src/tax_registration/requests.rs index a64b8d749..d489d7e3d 100644 --- a/generated/stripe_misc/src/tax_registration/requests.rs +++ b/generated/stripe_misc/src/tax_registration/requests.rs @@ -80,39 +80,13 @@ impl serde::Serialize for ListTaxRegistrationStatus { } impl<'a> ListTaxRegistration<'a> { /// Returns a list of Tax `Registration` objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::TaxRegistration>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::TaxRegistration>> { client.get_query("/tax/registrations", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::TaxRegistration>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::TaxRegistration>> { stripe::ListPaginator::from_list_params("/tax/registrations", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTaxRegistration<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveTaxRegistration<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveTaxRegistration<'a> { - /// Returns a Tax `Registration` object. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_misc::TaxRegistrationId, - ) -> stripe::Response<stripe_misc::TaxRegistration> { - client.get_query(&format!("/tax/registrations/{id}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistration<'a> { /// Time at which the Tax Registration becomes active. @@ -132,11 +106,7 @@ pub struct CreateTaxRegistration<'a> { pub expires_at: Option<stripe_types::Timestamp>, } impl<'a> CreateTaxRegistration<'a> { - pub fn new( - active_from: CreateTaxRegistrationActiveFrom, - country: &'a str, - country_options: CreateTaxRegistrationCountryOptions<'a>, - ) -> Self { + pub fn new(active_from: CreateTaxRegistrationActiveFrom, country: &'a str, country_options: CreateTaxRegistrationCountryOptions<'a>) -> Self { Self { active_from, country, country_options, expand: None, expires_at: None } } } @@ -308,7 +278,7 @@ impl<'a> CreateTaxRegistrationCountryOptions<'a> { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsAe { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsAeType, } impl CreateTaxRegistrationCountryOptionsAe { @@ -366,7 +336,7 @@ pub struct CreateTaxRegistrationCountryOptionsAt { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsAtStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsAtType, } impl CreateTaxRegistrationCountryOptionsAt { @@ -381,9 +351,7 @@ pub struct CreateTaxRegistrationCountryOptionsAtStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsAtStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsAtStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsAtStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsAtStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -489,7 +457,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsAtType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsAu { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsAuType, } impl CreateTaxRegistrationCountryOptionsAu { @@ -547,7 +515,7 @@ pub struct CreateTaxRegistrationCountryOptionsBe { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsBeStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsBeType, } impl CreateTaxRegistrationCountryOptionsBe { @@ -562,9 +530,7 @@ pub struct CreateTaxRegistrationCountryOptionsBeStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsBeStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsBeStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsBeStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsBeStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -673,7 +639,7 @@ pub struct CreateTaxRegistrationCountryOptionsBg { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsBgStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsBgType, } impl CreateTaxRegistrationCountryOptionsBg { @@ -688,9 +654,7 @@ pub struct CreateTaxRegistrationCountryOptionsBgStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsBgStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsBgStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsBgStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsBgStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -799,7 +763,7 @@ pub struct CreateTaxRegistrationCountryOptionsCa<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub province_standard: Option<CreateTaxRegistrationCountryOptionsCaProvinceStandard<'a>>, /// Type of registration to be created in Canada. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsCaType, } impl<'a> CreateTaxRegistrationCountryOptionsCa<'a> { @@ -871,7 +835,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsCaType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCh { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsChType, } impl CreateTaxRegistrationCountryOptionsCh { @@ -926,7 +890,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsChType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCl { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsClType, } impl CreateTaxRegistrationCountryOptionsCl { @@ -981,7 +945,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsClType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCo { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsCoType, } impl CreateTaxRegistrationCountryOptionsCo { @@ -1039,7 +1003,7 @@ pub struct CreateTaxRegistrationCountryOptionsCy { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsCyStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsCyType, } impl CreateTaxRegistrationCountryOptionsCy { @@ -1054,9 +1018,7 @@ pub struct CreateTaxRegistrationCountryOptionsCyStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsCyStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsCyStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsCyStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsCyStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -1165,7 +1127,7 @@ pub struct CreateTaxRegistrationCountryOptionsCz { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsCzStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsCzType, } impl CreateTaxRegistrationCountryOptionsCz { @@ -1180,9 +1142,7 @@ pub struct CreateTaxRegistrationCountryOptionsCzStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsCzStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsCzStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsCzStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsCzStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -1291,7 +1251,7 @@ pub struct CreateTaxRegistrationCountryOptionsDe { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsDeStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsDeType, } impl CreateTaxRegistrationCountryOptionsDe { @@ -1306,9 +1266,7 @@ pub struct CreateTaxRegistrationCountryOptionsDeStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsDeStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsDeStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsDeStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsDeStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -1417,7 +1375,7 @@ pub struct CreateTaxRegistrationCountryOptionsDk { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsDkStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsDkType, } impl CreateTaxRegistrationCountryOptionsDk { @@ -1432,9 +1390,7 @@ pub struct CreateTaxRegistrationCountryOptionsDkStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsDkStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsDkStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsDkStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsDkStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -1543,7 +1499,7 @@ pub struct CreateTaxRegistrationCountryOptionsEe { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsEeStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsEeType, } impl CreateTaxRegistrationCountryOptionsEe { @@ -1558,9 +1514,7 @@ pub struct CreateTaxRegistrationCountryOptionsEeStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsEeStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsEeStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsEeStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsEeStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -1669,7 +1623,7 @@ pub struct CreateTaxRegistrationCountryOptionsEs { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsEsStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsEsType, } impl CreateTaxRegistrationCountryOptionsEs { @@ -1684,9 +1638,7 @@ pub struct CreateTaxRegistrationCountryOptionsEsStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsEsStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsEsStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsEsStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsEsStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -1795,7 +1747,7 @@ pub struct CreateTaxRegistrationCountryOptionsFi { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsFiStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsFiType, } impl CreateTaxRegistrationCountryOptionsFi { @@ -1810,9 +1762,7 @@ pub struct CreateTaxRegistrationCountryOptionsFiStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsFiStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsFiStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsFiStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsFiStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -1921,7 +1871,7 @@ pub struct CreateTaxRegistrationCountryOptionsFr { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsFrStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsFrType, } impl CreateTaxRegistrationCountryOptionsFr { @@ -1936,9 +1886,7 @@ pub struct CreateTaxRegistrationCountryOptionsFrStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsFrStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsFrStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsFrStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsFrStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -2044,7 +1992,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsFrType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsGb { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsGbType, } impl CreateTaxRegistrationCountryOptionsGb { @@ -2102,7 +2050,7 @@ pub struct CreateTaxRegistrationCountryOptionsGr { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsGrStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsGrType, } impl CreateTaxRegistrationCountryOptionsGr { @@ -2117,9 +2065,7 @@ pub struct CreateTaxRegistrationCountryOptionsGrStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsGrStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsGrStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsGrStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsGrStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -2228,7 +2174,7 @@ pub struct CreateTaxRegistrationCountryOptionsHr { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsHrStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsHrType, } impl CreateTaxRegistrationCountryOptionsHr { @@ -2243,9 +2189,7 @@ pub struct CreateTaxRegistrationCountryOptionsHrStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsHrStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsHrStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsHrStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsHrStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -2354,7 +2298,7 @@ pub struct CreateTaxRegistrationCountryOptionsHu { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsHuStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsHuType, } impl CreateTaxRegistrationCountryOptionsHu { @@ -2369,9 +2313,7 @@ pub struct CreateTaxRegistrationCountryOptionsHuStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsHuStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsHuStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsHuStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsHuStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -2477,7 +2419,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsHuType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsId { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsIdType, } impl CreateTaxRegistrationCountryOptionsId { @@ -2535,7 +2477,7 @@ pub struct CreateTaxRegistrationCountryOptionsIe { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsIeStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsIeType, } impl CreateTaxRegistrationCountryOptionsIe { @@ -2550,9 +2492,7 @@ pub struct CreateTaxRegistrationCountryOptionsIeStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsIeStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsIeStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsIeStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsIeStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -2658,7 +2598,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsIeType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsIs { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsIsType, } impl CreateTaxRegistrationCountryOptionsIs { @@ -2716,7 +2656,7 @@ pub struct CreateTaxRegistrationCountryOptionsIt { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsItStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsItType, } impl CreateTaxRegistrationCountryOptionsIt { @@ -2731,9 +2671,7 @@ pub struct CreateTaxRegistrationCountryOptionsItStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsItStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsItStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsItStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsItStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -2839,7 +2777,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsItType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsJp { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsJpType, } impl CreateTaxRegistrationCountryOptionsJp { @@ -2894,7 +2832,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsJpType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsKr { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsKrType, } impl CreateTaxRegistrationCountryOptionsKr { @@ -2952,7 +2890,7 @@ pub struct CreateTaxRegistrationCountryOptionsLt { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsLtStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsLtType, } impl CreateTaxRegistrationCountryOptionsLt { @@ -2967,9 +2905,7 @@ pub struct CreateTaxRegistrationCountryOptionsLtStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLtStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsLtStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLtStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLtStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -3078,7 +3014,7 @@ pub struct CreateTaxRegistrationCountryOptionsLu { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsLuStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsLuType, } impl CreateTaxRegistrationCountryOptionsLu { @@ -3093,9 +3029,7 @@ pub struct CreateTaxRegistrationCountryOptionsLuStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLuStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsLuStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLuStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLuStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -3204,7 +3138,7 @@ pub struct CreateTaxRegistrationCountryOptionsLv { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsLvStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsLvType, } impl CreateTaxRegistrationCountryOptionsLv { @@ -3219,9 +3153,7 @@ pub struct CreateTaxRegistrationCountryOptionsLvStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLvStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsLvStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLvStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsLvStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -3330,7 +3262,7 @@ pub struct CreateTaxRegistrationCountryOptionsMt { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsMtStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsMtType, } impl CreateTaxRegistrationCountryOptionsMt { @@ -3345,9 +3277,7 @@ pub struct CreateTaxRegistrationCountryOptionsMtStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsMtStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsMtStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsMtStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsMtStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -3453,7 +3383,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsMtType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsMx { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsMxType, } impl CreateTaxRegistrationCountryOptionsMx { @@ -3508,7 +3438,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsMxType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsMy { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsMyType, } impl CreateTaxRegistrationCountryOptionsMy { @@ -3566,7 +3496,7 @@ pub struct CreateTaxRegistrationCountryOptionsNl { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsNlStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsNlType, } impl CreateTaxRegistrationCountryOptionsNl { @@ -3581,9 +3511,7 @@ pub struct CreateTaxRegistrationCountryOptionsNlStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsNlStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsNlStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsNlStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsNlStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -3689,7 +3617,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsNlType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsNo { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsNoType, } impl CreateTaxRegistrationCountryOptionsNo { @@ -3744,7 +3672,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsNoType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsNz { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsNzType, } impl CreateTaxRegistrationCountryOptionsNz { @@ -3802,7 +3730,7 @@ pub struct CreateTaxRegistrationCountryOptionsPl { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsPlStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsPlType, } impl CreateTaxRegistrationCountryOptionsPl { @@ -3817,9 +3745,7 @@ pub struct CreateTaxRegistrationCountryOptionsPlStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsPlStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsPlStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsPlStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsPlStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -3928,7 +3854,7 @@ pub struct CreateTaxRegistrationCountryOptionsPt { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsPtStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsPtType, } impl CreateTaxRegistrationCountryOptionsPt { @@ -3943,9 +3869,7 @@ pub struct CreateTaxRegistrationCountryOptionsPtStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsPtStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsPtStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsPtStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsPtStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -4054,7 +3978,7 @@ pub struct CreateTaxRegistrationCountryOptionsRo { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsRoStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsRoType, } impl CreateTaxRegistrationCountryOptionsRo { @@ -4069,9 +3993,7 @@ pub struct CreateTaxRegistrationCountryOptionsRoStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsRoStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsRoStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsRoStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsRoStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -4177,7 +4099,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsRoType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsSa { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsSaType, } impl CreateTaxRegistrationCountryOptionsSa { @@ -4235,7 +4157,7 @@ pub struct CreateTaxRegistrationCountryOptionsSe { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsSeStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsSeType, } impl CreateTaxRegistrationCountryOptionsSe { @@ -4250,9 +4172,7 @@ pub struct CreateTaxRegistrationCountryOptionsSeStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSeStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsSeStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSeStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSeStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -4358,7 +4278,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSeType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsSg { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsSgType, } impl CreateTaxRegistrationCountryOptionsSg { @@ -4416,7 +4336,7 @@ pub struct CreateTaxRegistrationCountryOptionsSi { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsSiStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsSiType, } impl CreateTaxRegistrationCountryOptionsSi { @@ -4431,9 +4351,7 @@ pub struct CreateTaxRegistrationCountryOptionsSiStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSiStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsSiStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSiStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSiStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -4542,7 +4460,7 @@ pub struct CreateTaxRegistrationCountryOptionsSk { #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option<CreateTaxRegistrationCountryOptionsSkStandard>, /// Type of registration to be created in an EU country. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsSkType, } impl CreateTaxRegistrationCountryOptionsSk { @@ -4557,9 +4475,7 @@ pub struct CreateTaxRegistrationCountryOptionsSkStandard { pub place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSkStandardPlaceOfSupplyScheme, } impl CreateTaxRegistrationCountryOptionsSkStandard { - pub fn new( - place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSkStandardPlaceOfSupplyScheme, - ) -> Self { + pub fn new(place_of_supply_scheme: CreateTaxRegistrationCountryOptionsSkStandardPlaceOfSupplyScheme) -> Self { Self { place_of_supply_scheme } } } @@ -4665,7 +4581,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSkType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsTh { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsThType, } impl CreateTaxRegistrationCountryOptionsTh { @@ -4720,7 +4636,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsThType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsTr { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsTrType, } impl CreateTaxRegistrationCountryOptionsTr { @@ -4783,7 +4699,7 @@ pub struct CreateTaxRegistrationCountryOptionsUs<'a> { /// Two-letter US state code ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)). pub state: &'a str, /// Type of registration to be created in the US. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsUsType, } impl<'a> CreateTaxRegistrationCountryOptionsUs<'a> { @@ -4871,7 +4787,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsUsType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsVn { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsVnType, } impl CreateTaxRegistrationCountryOptionsVn { @@ -4926,7 +4842,7 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsVnType { #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsZa { /// Type of registration to be created in `country`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTaxRegistrationCountryOptionsZaType, } impl CreateTaxRegistrationCountryOptionsZa { @@ -5025,11 +4941,7 @@ impl<'a> UpdateTaxRegistration<'a> { /// /// A registration cannot be deleted after it has been created. /// If you wish to end a registration you may do so by setting `expires_at`. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_misc::TaxRegistrationId, - ) -> stripe::Response<stripe_misc::TaxRegistration> { + pub fn send(&self, client: &stripe::Client, id: &stripe_misc::TaxRegistrationId) -> stripe::Response<stripe_misc::TaxRegistration> { client.send_form(&format!("/tax/registrations/{id}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_misc/src/tax_registration/types.rs b/generated/stripe_misc/src/tax_registration/types.rs index 74cb67139..1510b5cec 100644 --- a/generated/stripe_misc/src/tax_registration/types.rs +++ b/generated/stripe_misc/src/tax_registration/types.rs @@ -4,7 +4,9 @@ /// For more information on how to register to collect tax, see [our guide](https://stripe.com/docs/tax/registering). /// /// Related guide: [Using the Registrations API](https://stripe.com/docs/tax/registrations-api) -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxRegistration { /// Time at which the registration becomes active. Measured in seconds since the Unix epoch. pub active_from: stripe_types::Timestamp, @@ -25,6 +27,129 @@ pub struct TaxRegistration { /// This field is present for convenience and can be deduced from `active_from` and `expires_at`. pub status: TaxRegistrationStatus, } +#[cfg(feature = "min-ser")] +pub struct TaxRegistrationBuilder { + active_from: Option<stripe_types::Timestamp>, + country: Option<String>, + country_options: Option<stripe_misc::TaxProductRegistrationsResourceCountryOptions>, + created: Option<stripe_types::Timestamp>, + expires_at: Option<Option<stripe_types::Timestamp>>, + id: Option<stripe_misc::TaxRegistrationId>, + livemode: Option<bool>, + status: Option<TaxRegistrationStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxRegistration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxRegistration>, + builder: TaxRegistrationBuilder, + } + + impl Visitor for Place<TaxRegistration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxRegistrationBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxRegistrationBuilder { + type Out = TaxRegistration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active_from" => Deserialize::begin(&mut self.active_from), + "country" => Deserialize::begin(&mut self.country), + "country_options" => Deserialize::begin(&mut self.country_options), + "created" => Deserialize::begin(&mut self.created), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active_from: Deserialize::default(), + country: Deserialize::default(), + country_options: Deserialize::default(), + created: Deserialize::default(), + expires_at: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active_from = self.active_from.take()?; + let country = self.country.take()?; + let country_options = self.country_options.take()?; + let created = self.created.take()?; + let expires_at = self.expires_at.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let status = self.status.take()?; + + Some(Self::Out { active_from, country, country_options, created, expires_at, id, livemode, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxRegistration { + type Builder = TaxRegistrationBuilder; + } + + impl FromValueOpt for TaxRegistration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxRegistrationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active_from" => b.active_from = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "country_options" => b.country_options = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the registration. /// This field is present for convenience and can be deduced from `active_from` and `expires_at`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -79,10 +204,27 @@ impl<'de> serde::Deserialize<'de> for TaxRegistrationStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TaxRegistrationStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxRegistrationStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxRegistrationStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxRegistrationStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxRegistrationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxRegistrationStatus); impl stripe_types::Object for TaxRegistration { type Id = stripe_misc::TaxRegistrationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/tax_settings/types.rs b/generated/stripe_misc/src/tax_settings/types.rs index 66d271a9b..51b8b1343 100644 --- a/generated/stripe_misc/src/tax_settings/types.rs +++ b/generated/stripe_misc/src/tax_settings/types.rs @@ -3,7 +3,9 @@ /// Related guide: [Using the Settings API](https://stripe.com/docs/tax/settings-api) /// /// For more details see <<https://stripe.com/docs/api/tax/settings/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxSettings { pub defaults: stripe_misc::TaxProductResourceTaxSettingsDefaults, /// The place where your business is located. @@ -15,6 +17,108 @@ pub struct TaxSettings { pub status: TaxSettingsStatus, pub status_details: stripe_misc::TaxProductResourceTaxSettingsStatusDetails, } +#[cfg(feature = "min-ser")] +pub struct TaxSettingsBuilder { + defaults: Option<stripe_misc::TaxProductResourceTaxSettingsDefaults>, + head_office: Option<Option<stripe_misc::TaxProductResourceTaxSettingsHeadOffice>>, + livemode: Option<bool>, + status: Option<TaxSettingsStatus>, + status_details: Option<stripe_misc::TaxProductResourceTaxSettingsStatusDetails>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxSettings>, + builder: TaxSettingsBuilder, + } + + impl Visitor for Place<TaxSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxSettingsBuilder { + type Out = TaxSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "defaults" => Deserialize::begin(&mut self.defaults), + "head_office" => Deserialize::begin(&mut self.head_office), + "livemode" => Deserialize::begin(&mut self.livemode), + "status" => Deserialize::begin(&mut self.status), + "status_details" => Deserialize::begin(&mut self.status_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { defaults: Deserialize::default(), head_office: Deserialize::default(), livemode: Deserialize::default(), status: Deserialize::default(), status_details: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let defaults = self.defaults.take()?; + let head_office = self.head_office.take()?; + let livemode = self.livemode.take()?; + let status = self.status.take()?; + let status_details = self.status_details.take()?; + + Some(Self::Out { defaults, head_office, livemode, status, status_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxSettings { + type Builder = TaxSettingsBuilder; + } + + impl FromValueOpt for TaxSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "defaults" => b.defaults = Some(FromValueOpt::from_value(v)?), + "head_office" => b.head_office = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_details" => b.status_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The `active` status indicates you have all required settings to calculate tax. /// A status can transition out of `active` when new required settings are introduced. #[derive(Copy, Clone, Eq, PartialEq)] @@ -66,7 +170,24 @@ impl<'de> serde::Deserialize<'de> for TaxSettingsStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TaxSettingsStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxSettingsStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxSettingsStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxSettingsStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxSettingsStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxSettingsStatus); diff --git a/generated/stripe_misc/src/tax_transaction/requests.rs b/generated/stripe_misc/src/tax_transaction/requests.rs index f53c5a9c6..79043a1da 100644 --- a/generated/stripe_misc/src/tax_transaction/requests.rs +++ b/generated/stripe_misc/src/tax_transaction/requests.rs @@ -11,96 +11,16 @@ impl<'a> RetrieveTaxTransaction<'a> { } impl<'a> RetrieveTaxTransaction<'a> { /// Retrieves a Tax `Transaction` object. - pub fn send( - &self, - client: &stripe::Client, - transaction: &stripe_misc::TaxTransactionId, - ) -> stripe::Response<stripe_misc::TaxTransaction> { + pub fn send(&self, client: &stripe::Client, transaction: &stripe_misc::TaxTransactionId) -> stripe::Response<stripe_misc::TaxTransaction> { client.get_query(&format!("/tax/transactions/{transaction}"), self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListLineItemsTaxTransaction<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListLineItemsTaxTransaction<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListLineItemsTaxTransaction<'a> { - /// Retrieves the line items of a committed standalone transaction as a collection. - pub fn send( - &self, - client: &stripe::Client, - transaction: &stripe_misc::TaxTransactionId, - ) -> stripe::Response<stripe_types::List<stripe_misc::TaxTransactionLineItem>> { - client.get_query(&format!("/tax/transactions/{transaction}/line_items"), self) - } - pub fn paginate( - self, - transaction: &stripe_misc::TaxTransactionId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::TaxTransactionLineItem>> { - stripe::ListPaginator::from_list_params( - &format!("/tax/transactions/{transaction}/line_items"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateFromCalculationTaxTransaction<'a> { - /// Tax Calculation ID to be used as input when creating the transaction. - pub calculation: &'a str, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// A custom order or sale identifier, such as 'myOrder_123'. - /// Must be unique across all transactions, including reversals. - pub reference: &'a str, -} -impl<'a> CreateFromCalculationTaxTransaction<'a> { - pub fn new(calculation: &'a str, reference: &'a str) -> Self { - Self { calculation, expand: None, metadata: None, reference } - } -} -impl<'a> CreateFromCalculationTaxTransaction<'a> { - /// Creates a Tax `Transaction` from a calculation. - pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::TaxTransaction> { - client.send_form( - "/tax/transactions/create_from_calculation", - self, - http_types::Method::Post, - ) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateReversalTaxTransaction<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// A flat amount to reverse across the entire transaction, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) in negative. + /// A flat amount to reverse across the entire transaction, in negative integer cents. /// This value represents the total amount to refund from the transaction, including taxes. #[serde(skip_serializing_if = "Option::is_none")] pub flat_amount: Option<i64>, @@ -126,29 +46,16 @@ pub struct CreateReversalTaxTransaction<'a> { pub shipping_cost: Option<CreateReversalTaxTransactionShippingCost>, } impl<'a> CreateReversalTaxTransaction<'a> { - pub fn new( - mode: CreateReversalTaxTransactionMode, - original_transaction: &'a str, - reference: &'a str, - ) -> Self { - Self { - expand: None, - flat_amount: None, - line_items: None, - metadata: None, - mode, - original_transaction, - reference, - shipping_cost: None, - } + pub fn new(mode: CreateReversalTaxTransactionMode, original_transaction: &'a str, reference: &'a str) -> Self { + Self { expand: None, flat_amount: None, line_items: None, metadata: None, mode, original_transaction, reference, shipping_cost: None } } } /// The line item amounts to reverse. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateReversalTaxTransactionLineItems<'a> { - /// The amount to reverse, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) in negative. + /// The amount to reverse, in negative integer cents. pub amount: i64, - /// The amount of tax to reverse, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) in negative. + /// The amount of tax to reverse, in negative integer cents. pub amount_tax: i64, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. @@ -164,12 +71,7 @@ pub struct CreateReversalTaxTransactionLineItems<'a> { pub reference: &'a str, } impl<'a> CreateReversalTaxTransactionLineItems<'a> { - pub fn new( - amount: i64, - amount_tax: i64, - original_line_item: &'a str, - reference: &'a str, - ) -> Self { + pub fn new(amount: i64, amount_tax: i64, original_line_item: &'a str, reference: &'a str) -> Self { Self { amount, amount_tax, metadata: None, original_line_item, quantity: None, reference } } } @@ -223,9 +125,9 @@ impl serde::Serialize for CreateReversalTaxTransactionMode { /// The shipping cost to reverse. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateReversalTaxTransactionShippingCost { - /// The amount to reverse, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) in negative. + /// The amount to reverse, in negative integer cents. pub amount: i64, - /// The amount of tax to reverse, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) in negative. + /// The amount of tax to reverse, in negative integer cents. pub amount_tax: i64, } impl CreateReversalTaxTransactionShippingCost { @@ -239,3 +141,65 @@ impl<'a> CreateReversalTaxTransaction<'a> { client.send_form("/tax/transactions/create_reversal", self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct CreateFromCalculationTaxTransaction<'a> { + /// Tax Calculation ID to be used as input when creating the transaction. + pub calculation: &'a str, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// A custom order or sale identifier, such as 'myOrder_123'. + /// Must be unique across all transactions, including reversals. + pub reference: &'a str, +} +impl<'a> CreateFromCalculationTaxTransaction<'a> { + pub fn new(calculation: &'a str, reference: &'a str) -> Self { + Self { calculation, expand: None, metadata: None, reference } + } +} +impl<'a> CreateFromCalculationTaxTransaction<'a> { + /// Creates a Tax `Transaction` from a calculation. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_misc::TaxTransaction> { + client.send_form("/tax/transactions/create_from_calculation", self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListLineItemsTaxTransaction<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListLineItemsTaxTransaction<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListLineItemsTaxTransaction<'a> { + /// Retrieves the line items of a committed standalone transaction as a collection. + pub fn send(&self, client: &stripe::Client, transaction: &stripe_misc::TaxTransactionId) -> stripe::Response<stripe_types::List<stripe_misc::TaxTransactionLineItem>> { + client.get_query(&format!("/tax/transactions/{transaction}/line_items"), self) + } + pub fn paginate(self, transaction: &stripe_misc::TaxTransactionId) -> stripe::ListPaginator<stripe_types::List<stripe_misc::TaxTransactionLineItem>> { + stripe::ListPaginator::from_list_params(&format!("/tax/transactions/{transaction}/line_items"), self) + } +} diff --git a/generated/stripe_misc/src/tax_transaction/types.rs b/generated/stripe_misc/src/tax_transaction/types.rs index dcabfd75e..ba094c3ad 100644 --- a/generated/stripe_misc/src/tax_transaction/types.rs +++ b/generated/stripe_misc/src/tax_transaction/types.rs @@ -3,7 +3,9 @@ /// Related guide: [Calculate tax in your custom payment flow](https://stripe.com/docs/tax/custom#tax-transaction). /// /// For more details see <<https://stripe.com/docs/api/tax/transactions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxTransaction { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -31,9 +33,157 @@ pub struct TaxTransaction { /// Timestamp of date at which the tax rules and rates in effect applies for the calculation. pub tax_date: stripe_types::Timestamp, /// If `reversal`, this transaction reverses an earlier transaction. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxTransactionType, } +#[cfg(feature = "min-ser")] +pub struct TaxTransactionBuilder { + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + customer: Option<Option<String>>, + customer_details: Option<stripe_misc::TaxProductResourceCustomerDetails>, + id: Option<stripe_misc::TaxTransactionId>, + line_items: Option<Option<stripe_types::List<stripe_misc::TaxTransactionLineItem>>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + reference: Option<String>, + reversal: Option<Option<stripe_misc::TaxProductResourceTaxTransactionResourceReversal>>, + shipping_cost: Option<Option<stripe_misc::TaxProductResourceTaxTransactionShippingCost>>, + tax_date: Option<stripe_types::Timestamp>, + type_: Option<TaxTransactionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxTransaction>, + builder: TaxTransactionBuilder, + } + + impl Visitor for Place<TaxTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxTransactionBuilder { + type Out = TaxTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "customer_details" => Deserialize::begin(&mut self.customer_details), + "id" => Deserialize::begin(&mut self.id), + "line_items" => Deserialize::begin(&mut self.line_items), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "reference" => Deserialize::begin(&mut self.reference), + "reversal" => Deserialize::begin(&mut self.reversal), + "shipping_cost" => Deserialize::begin(&mut self.shipping_cost), + "tax_date" => Deserialize::begin(&mut self.tax_date), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + customer_details: Deserialize::default(), + id: Deserialize::default(), + line_items: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + reference: Deserialize::default(), + reversal: Deserialize::default(), + shipping_cost: Deserialize::default(), + tax_date: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let customer_details = self.customer_details.take()?; + let id = self.id.take()?; + let line_items = self.line_items.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let reference = self.reference.take()?; + let reversal = self.reversal.take()?; + let shipping_cost = self.shipping_cost.take()?; + let tax_date = self.tax_date.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { created, currency, customer, customer_details, id, line_items, livemode, metadata, reference, reversal, shipping_cost, tax_date, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxTransaction { + type Builder = TaxTransactionBuilder; + } + + impl FromValueOpt for TaxTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "customer_details" => b.customer_details = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "reversal" => b.reversal = Some(FromValueOpt::from_value(v)?), + "shipping_cost" => b.shipping_cost = Some(FromValueOpt::from_value(v)?), + "tax_date" => b.tax_date = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// If `reversal`, this transaction reverses an earlier transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxTransactionType { @@ -84,10 +234,27 @@ impl<'de> serde::Deserialize<'de> for TaxTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TaxTransactionType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxTransactionType); impl stripe_types::Object for TaxTransaction { type Id = stripe_misc::TaxTransactionId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/tax_transaction_line_item.rs b/generated/stripe_misc/src/tax_transaction_line_item.rs index 06dd5f86f..e02b48ea4 100644 --- a/generated/stripe_misc/src/tax_transaction_line_item.rs +++ b/generated/stripe_misc/src/tax_transaction_line_item.rs @@ -1,10 +1,12 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxTransactionLineItem { - /// The line item amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The line item amount in integer cents. /// If `tax_behavior=inclusive`, then this amount includes taxes. /// Otherwise, taxes were calculated on top of this amount. pub amount: i64, - /// The amount of tax calculated for this line item, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + /// The amount of tax calculated for this line item, in integer cents. pub amount_tax: i64, /// Unique identifier for the object. pub id: stripe_misc::TaxTransactionLineItemId, @@ -27,9 +29,152 @@ pub struct TaxTransactionLineItem { /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for this resource. pub tax_code: String, /// If `reversal`, this line item reverses an earlier transaction. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxTransactionLineItemType, } +#[cfg(feature = "min-ser")] +pub struct TaxTransactionLineItemBuilder { + amount: Option<i64>, + amount_tax: Option<i64>, + id: Option<stripe_misc::TaxTransactionLineItemId>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + product: Option<Option<String>>, + quantity: Option<u64>, + reference: Option<String>, + reversal: Option<Option<stripe_misc::TaxProductResourceTaxTransactionLineItemResourceReversal>>, + tax_behavior: Option<TaxTransactionLineItemTaxBehavior>, + tax_code: Option<String>, + type_: Option<TaxTransactionLineItemType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxTransactionLineItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxTransactionLineItem>, + builder: TaxTransactionLineItemBuilder, + } + + impl Visitor for Place<TaxTransactionLineItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxTransactionLineItemBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxTransactionLineItemBuilder { + type Out = TaxTransactionLineItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "product" => Deserialize::begin(&mut self.product), + "quantity" => Deserialize::begin(&mut self.quantity), + "reference" => Deserialize::begin(&mut self.reference), + "reversal" => Deserialize::begin(&mut self.reversal), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tax_code" => Deserialize::begin(&mut self.tax_code), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_tax: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + product: Deserialize::default(), + quantity: Deserialize::default(), + reference: Deserialize::default(), + reversal: Deserialize::default(), + tax_behavior: Deserialize::default(), + tax_code: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_tax = self.amount_tax.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let product = self.product.take()?; + let quantity = self.quantity.take()?; + let reference = self.reference.take()?; + let reversal = self.reversal.take()?; + let tax_behavior = self.tax_behavior.take()?; + let tax_code = self.tax_code.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { amount, amount_tax, id, livemode, metadata, product, quantity, reference, reversal, tax_behavior, tax_code, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxTransactionLineItem { + type Builder = TaxTransactionLineItemBuilder; + } + + impl FromValueOpt for TaxTransactionLineItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxTransactionLineItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "product" => b.product = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "reversal" => b.reversal = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tax_code" => b.tax_code = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. #[derive(Copy, Clone, Eq, PartialEq)] @@ -81,11 +226,27 @@ impl<'de> serde::Deserialize<'de> for TaxTransactionLineItemTaxBehavior { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TaxTransactionLineItemTaxBehavior") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxTransactionLineItemTaxBehavior")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxTransactionLineItemTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxTransactionLineItemTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxTransactionLineItemTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxTransactionLineItemTaxBehavior); /// If `reversal`, this line item reverses an earlier transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxTransactionLineItemType { @@ -136,10 +297,27 @@ impl<'de> serde::Deserialize<'de> for TaxTransactionLineItemType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TaxTransactionLineItemType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxTransactionLineItemType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxTransactionLineItemType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxTransactionLineItemType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxTransactionLineItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxTransactionLineItemType); impl stripe_types::Object for TaxTransactionLineItem { type Id = stripe_misc::TaxTransactionLineItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/verification_session_redaction.rs b/generated/stripe_misc/src/verification_session_redaction.rs index c0264d6c4..5b865cc08 100644 --- a/generated/stripe_misc/src/verification_session_redaction.rs +++ b/generated/stripe_misc/src/verification_session_redaction.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct VerificationSessionRedaction { /// Indicates whether this object and its related objects have been redacted or not. pub status: VerificationSessionRedactionStatus, } +#[cfg(feature = "min-ser")] +pub struct VerificationSessionRedactionBuilder { + status: Option<VerificationSessionRedactionStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for VerificationSessionRedaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<VerificationSessionRedaction>, + builder: VerificationSessionRedactionBuilder, + } + + impl Visitor for Place<VerificationSessionRedaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: VerificationSessionRedactionBuilder::deser_default() })) + } + } + + impl MapBuilder for VerificationSessionRedactionBuilder { + type Out = VerificationSessionRedaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let status = self.status.take()?; + + Some(Self::Out { status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for VerificationSessionRedaction { + type Builder = VerificationSessionRedactionBuilder; + } + + impl FromValueOpt for VerificationSessionRedaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = VerificationSessionRedactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates whether this object and its related objects have been redacted or not. #[derive(Copy, Clone, Eq, PartialEq)] pub enum VerificationSessionRedactionStatus { @@ -53,8 +141,24 @@ impl<'de> serde::Deserialize<'de> for VerificationSessionRedactionStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for VerificationSessionRedactionStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for VerificationSessionRedactionStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for VerificationSessionRedactionStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<VerificationSessionRedactionStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(VerificationSessionRedactionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(VerificationSessionRedactionStatus); diff --git a/generated/stripe_misc/src/webhook_endpoint/requests.rs b/generated/stripe_misc/src/webhook_endpoint/requests.rs index f02bee507..1b79f33e1 100644 --- a/generated/stripe_misc/src/webhook_endpoint/requests.rs +++ b/generated/stripe_misc/src/webhook_endpoint/requests.rs @@ -1,25 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteWebhookEndpoint {} -impl DeleteWebhookEndpoint { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteWebhookEndpoint { - /// You can also delete webhook endpoints via the [webhook endpoint management](https://dashboard.stripe.com/account/webhooks) page of the Stripe dashboard. - pub fn send( - &self, - client: &stripe::Client, - webhook_endpoint: &stripe_misc::WebhookEndpointId, - ) -> stripe::Response<stripe_misc::DeletedWebhookEndpoint> { - client.send_form( - &format!("/webhook_endpoints/{webhook_endpoint}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListWebhookEndpoint<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -46,15 +25,10 @@ impl<'a> ListWebhookEndpoint<'a> { } impl<'a> ListWebhookEndpoint<'a> { /// Returns a list of your webhook endpoints. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_misc::WebhookEndpoint>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_misc::WebhookEndpoint>> { client.get_query("/webhook_endpoints", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_misc::WebhookEndpoint>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_misc::WebhookEndpoint>> { stripe::ListPaginator::from_list_params("/webhook_endpoints", self) } } @@ -71,11 +45,7 @@ impl<'a> RetrieveWebhookEndpoint<'a> { } impl<'a> RetrieveWebhookEndpoint<'a> { /// Retrieves the webhook endpoint with the given ID. - pub fn send( - &self, - client: &stripe::Client, - webhook_endpoint: &stripe_misc::WebhookEndpointId, - ) -> stripe::Response<stripe_misc::WebhookEndpoint> { + pub fn send(&self, client: &stripe::Client, webhook_endpoint: &stripe_misc::WebhookEndpointId) -> stripe::Response<stripe_misc::WebhookEndpoint> { client.get_query(&format!("/webhook_endpoints/{webhook_endpoint}"), self) } } @@ -108,15 +78,7 @@ pub struct CreateWebhookEndpoint<'a> { } impl<'a> CreateWebhookEndpoint<'a> { pub fn new(enabled_events: &'a [CreateWebhookEndpointEnabledEvents], url: &'a str) -> Self { - Self { - api_version: None, - connect: None, - description: None, - enabled_events, - expand: None, - metadata: None, - url, - } + Self { api_version: None, connect: None, description: None, enabled_events, expand: None, metadata: None, url } } } /// The list of events to enable for this endpoint. @@ -157,13 +119,6 @@ pub enum CreateWebhookEndpointEnabledEvents { CheckoutSessionAsyncPaymentSucceeded, CheckoutSessionCompleted, CheckoutSessionExpired, - ClimateOrderCanceled, - ClimateOrderCreated, - ClimateOrderDelayed, - ClimateOrderDelivered, - ClimateOrderProductSubstituted, - ClimateProductCreated, - ClimateProductPricingUpdated, CouponCreated, CouponDeleted, CouponUpdated, @@ -198,7 +153,6 @@ pub enum CreateWebhookEndpointEnabledEvents { FinancialConnectionsAccountDisconnected, FinancialConnectionsAccountReactivated, FinancialConnectionsAccountRefreshedBalance, - FinancialConnectionsAccountRefreshedTransactions, IdentityVerificationSessionCanceled, IdentityVerificationSessionCreated, IdentityVerificationSessionProcessing, @@ -390,13 +344,6 @@ impl CreateWebhookEndpointEnabledEvents { CheckoutSessionAsyncPaymentSucceeded => "checkout.session.async_payment_succeeded", CheckoutSessionCompleted => "checkout.session.completed", CheckoutSessionExpired => "checkout.session.expired", - ClimateOrderCanceled => "climate.order.canceled", - ClimateOrderCreated => "climate.order.created", - ClimateOrderDelayed => "climate.order.delayed", - ClimateOrderDelivered => "climate.order.delivered", - ClimateOrderProductSubstituted => "climate.order.product_substituted", - ClimateProductCreated => "climate.product.created", - ClimateProductPricingUpdated => "climate.product.pricing_updated", CouponCreated => "coupon.created", CouponDeleted => "coupon.deleted", CouponUpdated => "coupon.updated", @@ -415,12 +362,8 @@ impl CreateWebhookEndpointEnabledEvents { CustomerSubscriptionCreated => "customer.subscription.created", CustomerSubscriptionDeleted => "customer.subscription.deleted", CustomerSubscriptionPaused => "customer.subscription.paused", - CustomerSubscriptionPendingUpdateApplied => { - "customer.subscription.pending_update_applied" - } - CustomerSubscriptionPendingUpdateExpired => { - "customer.subscription.pending_update_expired" - } + CustomerSubscriptionPendingUpdateApplied => "customer.subscription.pending_update_applied", + CustomerSubscriptionPendingUpdateExpired => "customer.subscription.pending_update_expired", CustomerSubscriptionResumed => "customer.subscription.resumed", CustomerSubscriptionTrialWillEnd => "customer.subscription.trial_will_end", CustomerSubscriptionUpdated => "customer.subscription.updated", @@ -434,19 +377,12 @@ impl CreateWebhookEndpointEnabledEvents { FinancialConnectionsAccountDeactivated => "financial_connections.account.deactivated", FinancialConnectionsAccountDisconnected => "financial_connections.account.disconnected", FinancialConnectionsAccountReactivated => "financial_connections.account.reactivated", - FinancialConnectionsAccountRefreshedBalance => { - "financial_connections.account.refreshed_balance" - } - FinancialConnectionsAccountRefreshedTransactions => { - "financial_connections.account.refreshed_transactions" - } + FinancialConnectionsAccountRefreshedBalance => "financial_connections.account.refreshed_balance", IdentityVerificationSessionCanceled => "identity.verification_session.canceled", IdentityVerificationSessionCreated => "identity.verification_session.created", IdentityVerificationSessionProcessing => "identity.verification_session.processing", IdentityVerificationSessionRedacted => "identity.verification_session.redacted", - IdentityVerificationSessionRequiresInput => { - "identity.verification_session.requires_input" - } + IdentityVerificationSessionRequiresInput => "identity.verification_session.requires_input", IdentityVerificationSessionVerified => "identity.verification_session.verified", InvoiceCreated => "invoice.created", InvoiceDeleted => "invoice.deleted", @@ -569,31 +505,23 @@ impl CreateWebhookEndpointEnabledEvents { TreasuryCreditReversalPosted => "treasury.credit_reversal.posted", TreasuryDebitReversalCompleted => "treasury.debit_reversal.completed", TreasuryDebitReversalCreated => "treasury.debit_reversal.created", - TreasuryDebitReversalInitialCreditGranted => { - "treasury.debit_reversal.initial_credit_granted" - } + TreasuryDebitReversalInitialCreditGranted => "treasury.debit_reversal.initial_credit_granted", TreasuryFinancialAccountClosed => "treasury.financial_account.closed", TreasuryFinancialAccountCreated => "treasury.financial_account.created", - TreasuryFinancialAccountFeaturesStatusUpdated => { - "treasury.financial_account.features_status_updated" - } + TreasuryFinancialAccountFeaturesStatusUpdated => "treasury.financial_account.features_status_updated", TreasuryInboundTransferCanceled => "treasury.inbound_transfer.canceled", TreasuryInboundTransferCreated => "treasury.inbound_transfer.created", TreasuryInboundTransferFailed => "treasury.inbound_transfer.failed", TreasuryInboundTransferSucceeded => "treasury.inbound_transfer.succeeded", TreasuryOutboundPaymentCanceled => "treasury.outbound_payment.canceled", TreasuryOutboundPaymentCreated => "treasury.outbound_payment.created", - TreasuryOutboundPaymentExpectedArrivalDateUpdated => { - "treasury.outbound_payment.expected_arrival_date_updated" - } + TreasuryOutboundPaymentExpectedArrivalDateUpdated => "treasury.outbound_payment.expected_arrival_date_updated", TreasuryOutboundPaymentFailed => "treasury.outbound_payment.failed", TreasuryOutboundPaymentPosted => "treasury.outbound_payment.posted", TreasuryOutboundPaymentReturned => "treasury.outbound_payment.returned", TreasuryOutboundTransferCanceled => "treasury.outbound_transfer.canceled", TreasuryOutboundTransferCreated => "treasury.outbound_transfer.created", - TreasuryOutboundTransferExpectedArrivalDateUpdated => { - "treasury.outbound_transfer.expected_arrival_date_updated" - } + TreasuryOutboundTransferExpectedArrivalDateUpdated => "treasury.outbound_transfer.expected_arrival_date_updated", TreasuryOutboundTransferFailed => "treasury.outbound_transfer.failed", TreasuryOutboundTransferPosted => "treasury.outbound_transfer.posted", TreasuryOutboundTransferReturned => "treasury.outbound_transfer.returned", @@ -644,13 +572,6 @@ impl std::str::FromStr for CreateWebhookEndpointEnabledEvents { "checkout.session.async_payment_succeeded" => Ok(CheckoutSessionAsyncPaymentSucceeded), "checkout.session.completed" => Ok(CheckoutSessionCompleted), "checkout.session.expired" => Ok(CheckoutSessionExpired), - "climate.order.canceled" => Ok(ClimateOrderCanceled), - "climate.order.created" => Ok(ClimateOrderCreated), - "climate.order.delayed" => Ok(ClimateOrderDelayed), - "climate.order.delivered" => Ok(ClimateOrderDelivered), - "climate.order.product_substituted" => Ok(ClimateOrderProductSubstituted), - "climate.product.created" => Ok(ClimateProductCreated), - "climate.product.pricing_updated" => Ok(ClimateProductPricingUpdated), "coupon.created" => Ok(CouponCreated), "coupon.deleted" => Ok(CouponDeleted), "coupon.updated" => Ok(CouponUpdated), @@ -669,12 +590,8 @@ impl std::str::FromStr for CreateWebhookEndpointEnabledEvents { "customer.subscription.created" => Ok(CustomerSubscriptionCreated), "customer.subscription.deleted" => Ok(CustomerSubscriptionDeleted), "customer.subscription.paused" => Ok(CustomerSubscriptionPaused), - "customer.subscription.pending_update_applied" => { - Ok(CustomerSubscriptionPendingUpdateApplied) - } - "customer.subscription.pending_update_expired" => { - Ok(CustomerSubscriptionPendingUpdateExpired) - } + "customer.subscription.pending_update_applied" => Ok(CustomerSubscriptionPendingUpdateApplied), + "customer.subscription.pending_update_expired" => Ok(CustomerSubscriptionPendingUpdateExpired), "customer.subscription.resumed" => Ok(CustomerSubscriptionResumed), "customer.subscription.trial_will_end" => Ok(CustomerSubscriptionTrialWillEnd), "customer.subscription.updated" => Ok(CustomerSubscriptionUpdated), @@ -682,33 +599,18 @@ impl std::str::FromStr for CreateWebhookEndpointEnabledEvents { "customer.tax_id.deleted" => Ok(CustomerTaxIdDeleted), "customer.tax_id.updated" => Ok(CustomerTaxIdUpdated), "customer.updated" => Ok(CustomerUpdated), - "customer_cash_balance_transaction.created" => { - Ok(CustomerCashBalanceTransactionCreated) - } + "customer_cash_balance_transaction.created" => Ok(CustomerCashBalanceTransactionCreated), "file.created" => Ok(FileCreated), "financial_connections.account.created" => Ok(FinancialConnectionsAccountCreated), - "financial_connections.account.deactivated" => { - Ok(FinancialConnectionsAccountDeactivated) - } - "financial_connections.account.disconnected" => { - Ok(FinancialConnectionsAccountDisconnected) - } - "financial_connections.account.reactivated" => { - Ok(FinancialConnectionsAccountReactivated) - } - "financial_connections.account.refreshed_balance" => { - Ok(FinancialConnectionsAccountRefreshedBalance) - } - "financial_connections.account.refreshed_transactions" => { - Ok(FinancialConnectionsAccountRefreshedTransactions) - } + "financial_connections.account.deactivated" => Ok(FinancialConnectionsAccountDeactivated), + "financial_connections.account.disconnected" => Ok(FinancialConnectionsAccountDisconnected), + "financial_connections.account.reactivated" => Ok(FinancialConnectionsAccountReactivated), + "financial_connections.account.refreshed_balance" => Ok(FinancialConnectionsAccountRefreshedBalance), "identity.verification_session.canceled" => Ok(IdentityVerificationSessionCanceled), "identity.verification_session.created" => Ok(IdentityVerificationSessionCreated), "identity.verification_session.processing" => Ok(IdentityVerificationSessionProcessing), "identity.verification_session.redacted" => Ok(IdentityVerificationSessionRedacted), - "identity.verification_session.requires_input" => { - Ok(IdentityVerificationSessionRequiresInput) - } + "identity.verification_session.requires_input" => Ok(IdentityVerificationSessionRequiresInput), "identity.verification_session.verified" => Ok(IdentityVerificationSessionVerified), "invoice.created" => Ok(InvoiceCreated), "invoice.deleted" => Ok(InvoiceDeleted), @@ -831,31 +733,23 @@ impl std::str::FromStr for CreateWebhookEndpointEnabledEvents { "treasury.credit_reversal.posted" => Ok(TreasuryCreditReversalPosted), "treasury.debit_reversal.completed" => Ok(TreasuryDebitReversalCompleted), "treasury.debit_reversal.created" => Ok(TreasuryDebitReversalCreated), - "treasury.debit_reversal.initial_credit_granted" => { - Ok(TreasuryDebitReversalInitialCreditGranted) - } + "treasury.debit_reversal.initial_credit_granted" => Ok(TreasuryDebitReversalInitialCreditGranted), "treasury.financial_account.closed" => Ok(TreasuryFinancialAccountClosed), "treasury.financial_account.created" => Ok(TreasuryFinancialAccountCreated), - "treasury.financial_account.features_status_updated" => { - Ok(TreasuryFinancialAccountFeaturesStatusUpdated) - } + "treasury.financial_account.features_status_updated" => Ok(TreasuryFinancialAccountFeaturesStatusUpdated), "treasury.inbound_transfer.canceled" => Ok(TreasuryInboundTransferCanceled), "treasury.inbound_transfer.created" => Ok(TreasuryInboundTransferCreated), "treasury.inbound_transfer.failed" => Ok(TreasuryInboundTransferFailed), "treasury.inbound_transfer.succeeded" => Ok(TreasuryInboundTransferSucceeded), "treasury.outbound_payment.canceled" => Ok(TreasuryOutboundPaymentCanceled), "treasury.outbound_payment.created" => Ok(TreasuryOutboundPaymentCreated), - "treasury.outbound_payment.expected_arrival_date_updated" => { - Ok(TreasuryOutboundPaymentExpectedArrivalDateUpdated) - } + "treasury.outbound_payment.expected_arrival_date_updated" => Ok(TreasuryOutboundPaymentExpectedArrivalDateUpdated), "treasury.outbound_payment.failed" => Ok(TreasuryOutboundPaymentFailed), "treasury.outbound_payment.posted" => Ok(TreasuryOutboundPaymentPosted), "treasury.outbound_payment.returned" => Ok(TreasuryOutboundPaymentReturned), "treasury.outbound_transfer.canceled" => Ok(TreasuryOutboundTransferCanceled), "treasury.outbound_transfer.created" => Ok(TreasuryOutboundTransferCreated), - "treasury.outbound_transfer.expected_arrival_date_updated" => { - Ok(TreasuryOutboundTransferExpectedArrivalDateUpdated) - } + "treasury.outbound_transfer.expected_arrival_date_updated" => Ok(TreasuryOutboundTransferExpectedArrivalDateUpdated), "treasury.outbound_transfer.failed" => Ok(TreasuryOutboundTransferFailed), "treasury.outbound_transfer.posted" => Ok(TreasuryOutboundTransferPosted), "treasury.outbound_transfer.returned" => Ok(TreasuryOutboundTransferReturned), @@ -963,13 +857,6 @@ pub enum UpdateWebhookEndpointEnabledEvents { CheckoutSessionAsyncPaymentSucceeded, CheckoutSessionCompleted, CheckoutSessionExpired, - ClimateOrderCanceled, - ClimateOrderCreated, - ClimateOrderDelayed, - ClimateOrderDelivered, - ClimateOrderProductSubstituted, - ClimateProductCreated, - ClimateProductPricingUpdated, CouponCreated, CouponDeleted, CouponUpdated, @@ -1004,7 +891,6 @@ pub enum UpdateWebhookEndpointEnabledEvents { FinancialConnectionsAccountDisconnected, FinancialConnectionsAccountReactivated, FinancialConnectionsAccountRefreshedBalance, - FinancialConnectionsAccountRefreshedTransactions, IdentityVerificationSessionCanceled, IdentityVerificationSessionCreated, IdentityVerificationSessionProcessing, @@ -1196,13 +1082,6 @@ impl UpdateWebhookEndpointEnabledEvents { CheckoutSessionAsyncPaymentSucceeded => "checkout.session.async_payment_succeeded", CheckoutSessionCompleted => "checkout.session.completed", CheckoutSessionExpired => "checkout.session.expired", - ClimateOrderCanceled => "climate.order.canceled", - ClimateOrderCreated => "climate.order.created", - ClimateOrderDelayed => "climate.order.delayed", - ClimateOrderDelivered => "climate.order.delivered", - ClimateOrderProductSubstituted => "climate.order.product_substituted", - ClimateProductCreated => "climate.product.created", - ClimateProductPricingUpdated => "climate.product.pricing_updated", CouponCreated => "coupon.created", CouponDeleted => "coupon.deleted", CouponUpdated => "coupon.updated", @@ -1221,12 +1100,8 @@ impl UpdateWebhookEndpointEnabledEvents { CustomerSubscriptionCreated => "customer.subscription.created", CustomerSubscriptionDeleted => "customer.subscription.deleted", CustomerSubscriptionPaused => "customer.subscription.paused", - CustomerSubscriptionPendingUpdateApplied => { - "customer.subscription.pending_update_applied" - } - CustomerSubscriptionPendingUpdateExpired => { - "customer.subscription.pending_update_expired" - } + CustomerSubscriptionPendingUpdateApplied => "customer.subscription.pending_update_applied", + CustomerSubscriptionPendingUpdateExpired => "customer.subscription.pending_update_expired", CustomerSubscriptionResumed => "customer.subscription.resumed", CustomerSubscriptionTrialWillEnd => "customer.subscription.trial_will_end", CustomerSubscriptionUpdated => "customer.subscription.updated", @@ -1240,19 +1115,12 @@ impl UpdateWebhookEndpointEnabledEvents { FinancialConnectionsAccountDeactivated => "financial_connections.account.deactivated", FinancialConnectionsAccountDisconnected => "financial_connections.account.disconnected", FinancialConnectionsAccountReactivated => "financial_connections.account.reactivated", - FinancialConnectionsAccountRefreshedBalance => { - "financial_connections.account.refreshed_balance" - } - FinancialConnectionsAccountRefreshedTransactions => { - "financial_connections.account.refreshed_transactions" - } + FinancialConnectionsAccountRefreshedBalance => "financial_connections.account.refreshed_balance", IdentityVerificationSessionCanceled => "identity.verification_session.canceled", IdentityVerificationSessionCreated => "identity.verification_session.created", IdentityVerificationSessionProcessing => "identity.verification_session.processing", IdentityVerificationSessionRedacted => "identity.verification_session.redacted", - IdentityVerificationSessionRequiresInput => { - "identity.verification_session.requires_input" - } + IdentityVerificationSessionRequiresInput => "identity.verification_session.requires_input", IdentityVerificationSessionVerified => "identity.verification_session.verified", InvoiceCreated => "invoice.created", InvoiceDeleted => "invoice.deleted", @@ -1375,31 +1243,23 @@ impl UpdateWebhookEndpointEnabledEvents { TreasuryCreditReversalPosted => "treasury.credit_reversal.posted", TreasuryDebitReversalCompleted => "treasury.debit_reversal.completed", TreasuryDebitReversalCreated => "treasury.debit_reversal.created", - TreasuryDebitReversalInitialCreditGranted => { - "treasury.debit_reversal.initial_credit_granted" - } + TreasuryDebitReversalInitialCreditGranted => "treasury.debit_reversal.initial_credit_granted", TreasuryFinancialAccountClosed => "treasury.financial_account.closed", TreasuryFinancialAccountCreated => "treasury.financial_account.created", - TreasuryFinancialAccountFeaturesStatusUpdated => { - "treasury.financial_account.features_status_updated" - } + TreasuryFinancialAccountFeaturesStatusUpdated => "treasury.financial_account.features_status_updated", TreasuryInboundTransferCanceled => "treasury.inbound_transfer.canceled", TreasuryInboundTransferCreated => "treasury.inbound_transfer.created", TreasuryInboundTransferFailed => "treasury.inbound_transfer.failed", TreasuryInboundTransferSucceeded => "treasury.inbound_transfer.succeeded", TreasuryOutboundPaymentCanceled => "treasury.outbound_payment.canceled", TreasuryOutboundPaymentCreated => "treasury.outbound_payment.created", - TreasuryOutboundPaymentExpectedArrivalDateUpdated => { - "treasury.outbound_payment.expected_arrival_date_updated" - } + TreasuryOutboundPaymentExpectedArrivalDateUpdated => "treasury.outbound_payment.expected_arrival_date_updated", TreasuryOutboundPaymentFailed => "treasury.outbound_payment.failed", TreasuryOutboundPaymentPosted => "treasury.outbound_payment.posted", TreasuryOutboundPaymentReturned => "treasury.outbound_payment.returned", TreasuryOutboundTransferCanceled => "treasury.outbound_transfer.canceled", TreasuryOutboundTransferCreated => "treasury.outbound_transfer.created", - TreasuryOutboundTransferExpectedArrivalDateUpdated => { - "treasury.outbound_transfer.expected_arrival_date_updated" - } + TreasuryOutboundTransferExpectedArrivalDateUpdated => "treasury.outbound_transfer.expected_arrival_date_updated", TreasuryOutboundTransferFailed => "treasury.outbound_transfer.failed", TreasuryOutboundTransferPosted => "treasury.outbound_transfer.posted", TreasuryOutboundTransferReturned => "treasury.outbound_transfer.returned", @@ -1450,13 +1310,6 @@ impl std::str::FromStr for UpdateWebhookEndpointEnabledEvents { "checkout.session.async_payment_succeeded" => Ok(CheckoutSessionAsyncPaymentSucceeded), "checkout.session.completed" => Ok(CheckoutSessionCompleted), "checkout.session.expired" => Ok(CheckoutSessionExpired), - "climate.order.canceled" => Ok(ClimateOrderCanceled), - "climate.order.created" => Ok(ClimateOrderCreated), - "climate.order.delayed" => Ok(ClimateOrderDelayed), - "climate.order.delivered" => Ok(ClimateOrderDelivered), - "climate.order.product_substituted" => Ok(ClimateOrderProductSubstituted), - "climate.product.created" => Ok(ClimateProductCreated), - "climate.product.pricing_updated" => Ok(ClimateProductPricingUpdated), "coupon.created" => Ok(CouponCreated), "coupon.deleted" => Ok(CouponDeleted), "coupon.updated" => Ok(CouponUpdated), @@ -1475,12 +1328,8 @@ impl std::str::FromStr for UpdateWebhookEndpointEnabledEvents { "customer.subscription.created" => Ok(CustomerSubscriptionCreated), "customer.subscription.deleted" => Ok(CustomerSubscriptionDeleted), "customer.subscription.paused" => Ok(CustomerSubscriptionPaused), - "customer.subscription.pending_update_applied" => { - Ok(CustomerSubscriptionPendingUpdateApplied) - } - "customer.subscription.pending_update_expired" => { - Ok(CustomerSubscriptionPendingUpdateExpired) - } + "customer.subscription.pending_update_applied" => Ok(CustomerSubscriptionPendingUpdateApplied), + "customer.subscription.pending_update_expired" => Ok(CustomerSubscriptionPendingUpdateExpired), "customer.subscription.resumed" => Ok(CustomerSubscriptionResumed), "customer.subscription.trial_will_end" => Ok(CustomerSubscriptionTrialWillEnd), "customer.subscription.updated" => Ok(CustomerSubscriptionUpdated), @@ -1488,33 +1337,18 @@ impl std::str::FromStr for UpdateWebhookEndpointEnabledEvents { "customer.tax_id.deleted" => Ok(CustomerTaxIdDeleted), "customer.tax_id.updated" => Ok(CustomerTaxIdUpdated), "customer.updated" => Ok(CustomerUpdated), - "customer_cash_balance_transaction.created" => { - Ok(CustomerCashBalanceTransactionCreated) - } + "customer_cash_balance_transaction.created" => Ok(CustomerCashBalanceTransactionCreated), "file.created" => Ok(FileCreated), "financial_connections.account.created" => Ok(FinancialConnectionsAccountCreated), - "financial_connections.account.deactivated" => { - Ok(FinancialConnectionsAccountDeactivated) - } - "financial_connections.account.disconnected" => { - Ok(FinancialConnectionsAccountDisconnected) - } - "financial_connections.account.reactivated" => { - Ok(FinancialConnectionsAccountReactivated) - } - "financial_connections.account.refreshed_balance" => { - Ok(FinancialConnectionsAccountRefreshedBalance) - } - "financial_connections.account.refreshed_transactions" => { - Ok(FinancialConnectionsAccountRefreshedTransactions) - } + "financial_connections.account.deactivated" => Ok(FinancialConnectionsAccountDeactivated), + "financial_connections.account.disconnected" => Ok(FinancialConnectionsAccountDisconnected), + "financial_connections.account.reactivated" => Ok(FinancialConnectionsAccountReactivated), + "financial_connections.account.refreshed_balance" => Ok(FinancialConnectionsAccountRefreshedBalance), "identity.verification_session.canceled" => Ok(IdentityVerificationSessionCanceled), "identity.verification_session.created" => Ok(IdentityVerificationSessionCreated), "identity.verification_session.processing" => Ok(IdentityVerificationSessionProcessing), "identity.verification_session.redacted" => Ok(IdentityVerificationSessionRedacted), - "identity.verification_session.requires_input" => { - Ok(IdentityVerificationSessionRequiresInput) - } + "identity.verification_session.requires_input" => Ok(IdentityVerificationSessionRequiresInput), "identity.verification_session.verified" => Ok(IdentityVerificationSessionVerified), "invoice.created" => Ok(InvoiceCreated), "invoice.deleted" => Ok(InvoiceDeleted), @@ -1637,31 +1471,23 @@ impl std::str::FromStr for UpdateWebhookEndpointEnabledEvents { "treasury.credit_reversal.posted" => Ok(TreasuryCreditReversalPosted), "treasury.debit_reversal.completed" => Ok(TreasuryDebitReversalCompleted), "treasury.debit_reversal.created" => Ok(TreasuryDebitReversalCreated), - "treasury.debit_reversal.initial_credit_granted" => { - Ok(TreasuryDebitReversalInitialCreditGranted) - } + "treasury.debit_reversal.initial_credit_granted" => Ok(TreasuryDebitReversalInitialCreditGranted), "treasury.financial_account.closed" => Ok(TreasuryFinancialAccountClosed), "treasury.financial_account.created" => Ok(TreasuryFinancialAccountCreated), - "treasury.financial_account.features_status_updated" => { - Ok(TreasuryFinancialAccountFeaturesStatusUpdated) - } + "treasury.financial_account.features_status_updated" => Ok(TreasuryFinancialAccountFeaturesStatusUpdated), "treasury.inbound_transfer.canceled" => Ok(TreasuryInboundTransferCanceled), "treasury.inbound_transfer.created" => Ok(TreasuryInboundTransferCreated), "treasury.inbound_transfer.failed" => Ok(TreasuryInboundTransferFailed), "treasury.inbound_transfer.succeeded" => Ok(TreasuryInboundTransferSucceeded), "treasury.outbound_payment.canceled" => Ok(TreasuryOutboundPaymentCanceled), "treasury.outbound_payment.created" => Ok(TreasuryOutboundPaymentCreated), - "treasury.outbound_payment.expected_arrival_date_updated" => { - Ok(TreasuryOutboundPaymentExpectedArrivalDateUpdated) - } + "treasury.outbound_payment.expected_arrival_date_updated" => Ok(TreasuryOutboundPaymentExpectedArrivalDateUpdated), "treasury.outbound_payment.failed" => Ok(TreasuryOutboundPaymentFailed), "treasury.outbound_payment.posted" => Ok(TreasuryOutboundPaymentPosted), "treasury.outbound_payment.returned" => Ok(TreasuryOutboundPaymentReturned), "treasury.outbound_transfer.canceled" => Ok(TreasuryOutboundTransferCanceled), "treasury.outbound_transfer.created" => Ok(TreasuryOutboundTransferCreated), - "treasury.outbound_transfer.expected_arrival_date_updated" => { - Ok(TreasuryOutboundTransferExpectedArrivalDateUpdated) - } + "treasury.outbound_transfer.expected_arrival_date_updated" => Ok(TreasuryOutboundTransferExpectedArrivalDateUpdated), "treasury.outbound_transfer.failed" => Ok(TreasuryOutboundTransferFailed), "treasury.outbound_transfer.posted" => Ok(TreasuryOutboundTransferPosted), "treasury.outbound_transfer.returned" => Ok(TreasuryOutboundTransferReturned), @@ -1695,15 +1521,20 @@ impl serde::Serialize for UpdateWebhookEndpointEnabledEvents { impl<'a> UpdateWebhookEndpoint<'a> { /// Updates the webhook endpoint. /// You may edit the `url`, the list of `enabled_events`, and the status of your endpoint. - pub fn send( - &self, - client: &stripe::Client, - webhook_endpoint: &stripe_misc::WebhookEndpointId, - ) -> stripe::Response<stripe_misc::WebhookEndpoint> { - client.send_form( - &format!("/webhook_endpoints/{webhook_endpoint}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, webhook_endpoint: &stripe_misc::WebhookEndpointId) -> stripe::Response<stripe_misc::WebhookEndpoint> { + client.send_form(&format!("/webhook_endpoints/{webhook_endpoint}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteWebhookEndpoint {} +impl DeleteWebhookEndpoint { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteWebhookEndpoint { + /// You can also delete webhook endpoints via the [webhook endpoint management](https://dashboard.stripe.com/account/webhooks) page of the Stripe dashboard. + pub fn send(&self, client: &stripe::Client, webhook_endpoint: &stripe_misc::WebhookEndpointId) -> stripe::Response<stripe_misc::DeletedWebhookEndpoint> { + client.send_form(&format!("/webhook_endpoints/{webhook_endpoint}"), self, http_types::Method::Delete) } } diff --git a/generated/stripe_misc/src/webhook_endpoint/types.rs b/generated/stripe_misc/src/webhook_endpoint/types.rs index 9eae76e71..843a020ef 100644 --- a/generated/stripe_misc/src/webhook_endpoint/types.rs +++ b/generated/stripe_misc/src/webhook_endpoint/types.rs @@ -7,7 +7,9 @@ /// Related guide: [Setting up webhooks](https://stripe.com/docs/webhooks/configure) /// /// For more details see <<https://stripe.com/docs/api/webhook_endpoints/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct WebhookEndpoint { /// The API version events are rendered as for this webhook endpoint. pub api_version: Option<String>, @@ -29,13 +31,150 @@ pub struct WebhookEndpoint { pub metadata: std::collections::HashMap<String, String>, /// The endpoint's secret, used to generate [webhook signatures](https://stripe.com/docs/webhooks/signatures). /// Only returned at creation. - #[serde(skip_serializing_if = "Option::is_none")] pub secret: Option<String>, /// The status of the webhook. It can be `enabled` or `disabled`. pub status: String, /// The URL of the webhook endpoint. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct WebhookEndpointBuilder { + api_version: Option<Option<String>>, + application: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + description: Option<Option<String>>, + enabled_events: Option<Vec<String>>, + id: Option<stripe_misc::WebhookEndpointId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + secret: Option<Option<String>>, + status: Option<String>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for WebhookEndpoint { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<WebhookEndpoint>, + builder: WebhookEndpointBuilder, + } + + impl Visitor for Place<WebhookEndpoint> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: WebhookEndpointBuilder::deser_default() })) + } + } + + impl MapBuilder for WebhookEndpointBuilder { + type Out = WebhookEndpoint; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "api_version" => Deserialize::begin(&mut self.api_version), + "application" => Deserialize::begin(&mut self.application), + "created" => Deserialize::begin(&mut self.created), + "description" => Deserialize::begin(&mut self.description), + "enabled_events" => Deserialize::begin(&mut self.enabled_events), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "secret" => Deserialize::begin(&mut self.secret), + "status" => Deserialize::begin(&mut self.status), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + api_version: Deserialize::default(), + application: Deserialize::default(), + created: Deserialize::default(), + description: Deserialize::default(), + enabled_events: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + secret: Deserialize::default(), + status: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let api_version = self.api_version.take()?; + let application = self.application.take()?; + let created = self.created.take()?; + let description = self.description.take()?; + let enabled_events = self.enabled_events.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let secret = self.secret.take()?; + let status = self.status.take()?; + let url = self.url.take()?; + + Some(Self::Out { api_version, application, created, description, enabled_events, id, livemode, metadata, secret, status, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for WebhookEndpoint { + type Builder = WebhookEndpointBuilder; + } + + impl FromValueOpt for WebhookEndpoint { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = WebhookEndpointBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "api_version" => b.api_version = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "enabled_events" => b.enabled_events = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "secret" => b.secret = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for WebhookEndpoint { type Id = stripe_misc::WebhookEndpointId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_payment/.rustfmt.toml b/generated/stripe_payment/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_payment/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_payment/Cargo.toml b/generated/stripe_payment/Cargo.toml index 5776be916..ac473ffbf 100644 --- a/generated/stripe_payment/Cargo.toml +++ b/generated/stripe_payment/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_payment/src/bank_account/requests.rs b/generated/stripe_payment/src/bank_account/requests.rs index 908638b89..0fccfa021 100644 --- a/generated/stripe_payment/src/bank_account/requests.rs +++ b/generated/stripe_payment/src/bank_account/requests.rs @@ -1,25 +1,252 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteAccountBankAccount {} -impl DeleteAccountBankAccount { +pub struct UpdateCustomerBankAccount<'a> { + /// The name of the person or business that owns the bank account. + #[serde(skip_serializing_if = "Option::is_none")] + pub account_holder_name: Option<&'a str>, + /// The type of entity that holds the account. This can be either `individual` or `company`. + #[serde(skip_serializing_if = "Option::is_none")] + pub account_holder_type: Option<UpdateCustomerBankAccountAccountHolderType>, + /// City/District/Suburb/Town/Village. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_city: Option<&'a str>, + /// Billing address country, if provided when creating card. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_country: Option<&'a str>, + /// Address line 1 (Street address/PO Box/Company name). + #[serde(skip_serializing_if = "Option::is_none")] + pub address_line1: Option<&'a str>, + /// Address line 2 (Apartment/Suite/Unit/Building). + #[serde(skip_serializing_if = "Option::is_none")] + pub address_line2: Option<&'a str>, + /// State/County/Province/Region. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_state: Option<&'a str>, + /// ZIP or postal code. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_zip: Option<&'a str>, + /// Two digit number representing the card’s expiration month. + #[serde(skip_serializing_if = "Option::is_none")] + pub exp_month: Option<&'a str>, + /// Four digit number representing the card’s expiration year. + #[serde(skip_serializing_if = "Option::is_none")] + pub exp_year: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// Cardholder name. + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option<&'a str>, + #[serde(skip_serializing_if = "Option::is_none")] + pub owner: Option<UpdateCustomerBankAccountOwner<'a>>, +} +impl<'a> UpdateCustomerBankAccount<'a> { pub fn new() -> Self { Self::default() } } -impl DeleteAccountBankAccount { - /// Delete a specified external account for a given account. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - id: &str, - ) -> stripe::Response<stripe_shared::DeletedExternalAccount> { - client.send_form( - &format!("/accounts/{account}/external_accounts/{id}"), - self, - http_types::Method::Delete, - ) +/// The type of entity that holds the account. This can be either `individual` or `company`. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum UpdateCustomerBankAccountAccountHolderType { + Company, + Individual, +} +impl UpdateCustomerBankAccountAccountHolderType { + pub fn as_str(self) -> &'static str { + use UpdateCustomerBankAccountAccountHolderType::*; + match self { + Company => "company", + Individual => "individual", + } + } +} + +impl std::str::FromStr for UpdateCustomerBankAccountAccountHolderType { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use UpdateCustomerBankAccountAccountHolderType::*; + match s { + "company" => Ok(Company), + "individual" => Ok(Individual), + _ => Err(()), + } + } +} +impl std::fmt::Display for UpdateCustomerBankAccountAccountHolderType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for UpdateCustomerBankAccountAccountHolderType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for UpdateCustomerBankAccountAccountHolderType { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateCustomerBankAccountOwner<'a> { + /// Owner's address. + #[serde(skip_serializing_if = "Option::is_none")] + pub address: Option<UpdateCustomerBankAccountOwnerAddress<'a>>, + /// Owner's email address. + #[serde(skip_serializing_if = "Option::is_none")] + pub email: Option<&'a str>, + /// Owner's full name. + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option<&'a str>, + /// Owner's phone number. + #[serde(skip_serializing_if = "Option::is_none")] + pub phone: Option<&'a str>, +} +impl<'a> UpdateCustomerBankAccountOwner<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Owner's address. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateCustomerBankAccountOwnerAddress<'a> { + /// City, district, suburb, town, or village. + #[serde(skip_serializing_if = "Option::is_none")] + pub city: Option<&'a str>, + /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + #[serde(skip_serializing_if = "Option::is_none")] + pub country: Option<&'a str>, + /// Address line 1 (e.g., street, PO Box, or company name). + #[serde(skip_serializing_if = "Option::is_none")] + pub line1: Option<&'a str>, + /// Address line 2 (e.g., apartment, suite, unit, or building). + #[serde(skip_serializing_if = "Option::is_none")] + pub line2: Option<&'a str>, + /// ZIP or postal code. + #[serde(skip_serializing_if = "Option::is_none")] + pub postal_code: Option<&'a str>, + /// State, county, province, or region. + #[serde(skip_serializing_if = "Option::is_none")] + pub state: Option<&'a str>, +} +impl<'a> UpdateCustomerBankAccountOwnerAddress<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> UpdateCustomerBankAccount<'a> { + /// Update a specified source for a given customer. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<UpdateCustomerBankAccountReturned> { + client.send_form(&format!("/customers/{customer}/sources/{id}"), self, http_types::Method::Post) } } +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] +pub enum UpdateCustomerBankAccountReturned { + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] + Card(stripe_shared::Card), + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] + BankAccount(stripe_shared::BankAccount), + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] + Source(stripe_shared::Source), +} + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct UpdateCustomerBankAccountReturnedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<UpdateCustomerBankAccountReturned>, + builder: UpdateCustomerBankAccountReturnedBuilder, + } + + impl Deserialize for UpdateCustomerBankAccountReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<UpdateCustomerBankAccountReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for UpdateCustomerBankAccountReturnedBuilder { + type Out = UpdateCustomerBankAccountReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + UpdateCustomerBankAccountReturned::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for UpdateCustomerBankAccountReturned { + type Builder = UpdateCustomerBankAccountReturnedBuilder; + } + impl UpdateCustomerBankAccountReturned { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for UpdateCustomerBankAccountReturned { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct DeleteCustomerBankAccount<'a> { /// Specifies which fields in the response should be expanded. @@ -33,25 +260,110 @@ impl<'a> DeleteCustomerBankAccount<'a> { } impl<'a> DeleteCustomerBankAccount<'a> { /// Delete a specified source for a given customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<DeleteCustomerBankAccountReturned> { - client.send_form( - &format!("/customers/{customer}/sources/{id}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<DeleteCustomerBankAccountReturned> { + client.send_form(&format!("/customers/{customer}/sources/{id}"), self, http_types::Method::Delete) + } +} +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum DeleteCustomerBankAccountReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct DeleteCustomerBankAccountReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<DeleteCustomerBankAccountReturned>, + builder: DeleteCustomerBankAccountReturnedBuilder, + } + + impl Deserialize for DeleteCustomerBankAccountReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<DeleteCustomerBankAccountReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for DeleteCustomerBankAccountReturnedBuilder { + type Out = DeleteCustomerBankAccountReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + DeleteCustomerBankAccountReturned::DeletedPaymentSource(FromValueOpt::from_value(Value::Object(o))?) + } else { + DeleteCustomerBankAccountReturned::PaymentSource(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for DeleteCustomerBankAccountReturned { + type Builder = DeleteCustomerBankAccountReturnedBuilder; + } +}; + +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct VerifyBankAccount<'a> { + /// Two positive integers, in *cents*, equal to the values of the microdeposits sent to the bank account. + #[serde(skip_serializing_if = "Option::is_none")] + pub amounts: Option<&'a [i64]>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> VerifyBankAccount<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> VerifyBankAccount<'a> { + /// Verify a specified bank account for a given customer. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<stripe_shared::BankAccount> { + client.send_form(&format!("/customers/{customer}/sources/{id}/verify"), self, http_types::Method::Post) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateAccountBankAccount<'a> { /// The name of the person or business that owns the bank account. @@ -219,8 +531,7 @@ pub struct UpdateAccountBankAccountDocuments<'a> { /// One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement. /// Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a voided check. #[serde(skip_serializing_if = "Option::is_none")] - pub bank_account_ownership_verification: - Option<UpdateAccountBankAccountDocumentsBankAccountOwnershipVerification<'a>>, + pub bank_account_ownership_verification: Option<UpdateAccountBankAccountDocumentsBankAccountOwnershipVerification<'a>>, } impl<'a> UpdateAccountBankAccountDocuments<'a> { pub fn new() -> Self { @@ -245,215 +556,20 @@ impl<'a> UpdateAccountBankAccount<'a> { /// Other bank account details are not editable by design. /// /// You can re-enable a disabled bank account by performing an update call without providing any arguments or changes. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - id: &str, - ) -> stripe::Response<stripe_shared::ExternalAccount> { - client.send_form( - &format!("/accounts/{account}/external_accounts/{id}"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerBankAccount<'a> { - /// The name of the person or business that owns the bank account. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_name: Option<&'a str>, - /// The type of entity that holds the account. This can be either `individual` or `company`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: Option<UpdateCustomerBankAccountAccountHolderType>, - /// City/District/Suburb/Town/Village. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_city: Option<&'a str>, - /// Billing address country, if provided when creating card. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_country: Option<&'a str>, - /// Address line 1 (Street address/PO Box/Company name). - #[serde(skip_serializing_if = "Option::is_none")] - pub address_line1: Option<&'a str>, - /// Address line 2 (Apartment/Suite/Unit/Building). - #[serde(skip_serializing_if = "Option::is_none")] - pub address_line2: Option<&'a str>, - /// State/County/Province/Region. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_state: Option<&'a str>, - /// ZIP or postal code. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_zip: Option<&'a str>, - /// Two digit number representing the card’s expiration month. - #[serde(skip_serializing_if = "Option::is_none")] - pub exp_month: Option<&'a str>, - /// Four digit number representing the card’s expiration year. - #[serde(skip_serializing_if = "Option::is_none")] - pub exp_year: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Cardholder name. - #[serde(skip_serializing_if = "Option::is_none")] - pub name: Option<&'a str>, - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<UpdateCustomerBankAccountOwner<'a>>, -} -impl<'a> UpdateCustomerBankAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The type of entity that holds the account. This can be either `individual` or `company`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateCustomerBankAccountAccountHolderType { - Company, - Individual, -} -impl UpdateCustomerBankAccountAccountHolderType { - pub fn as_str(self) -> &'static str { - use UpdateCustomerBankAccountAccountHolderType::*; - match self { - Company => "company", - Individual => "individual", - } + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, id: &str) -> stripe::Response<stripe_shared::ExternalAccount> { + client.send_form(&format!("/accounts/{account}/external_accounts/{id}"), self, http_types::Method::Post) } } - -impl std::str::FromStr for UpdateCustomerBankAccountAccountHolderType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateCustomerBankAccountAccountHolderType::*; - match s { - "company" => Ok(Company), - "individual" => Ok(Individual), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateCustomerBankAccountAccountHolderType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateCustomerBankAccountAccountHolderType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateCustomerBankAccountAccountHolderType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerBankAccountOwner<'a> { - /// Owner's address. - #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option<UpdateCustomerBankAccountOwnerAddress<'a>>, - /// Owner's email address. - #[serde(skip_serializing_if = "Option::is_none")] - pub email: Option<&'a str>, - /// Owner's full name. - #[serde(skip_serializing_if = "Option::is_none")] - pub name: Option<&'a str>, - /// Owner's phone number. - #[serde(skip_serializing_if = "Option::is_none")] - pub phone: Option<&'a str>, -} -impl<'a> UpdateCustomerBankAccountOwner<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Owner's address. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerBankAccountOwnerAddress<'a> { - /// City, district, suburb, town, or village. - #[serde(skip_serializing_if = "Option::is_none")] - pub city: Option<&'a str>, - /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - #[serde(skip_serializing_if = "Option::is_none")] - pub country: Option<&'a str>, - /// Address line 1 (e.g., street, PO Box, or company name). - #[serde(skip_serializing_if = "Option::is_none")] - pub line1: Option<&'a str>, - /// Address line 2 (e.g., apartment, suite, unit, or building). - #[serde(skip_serializing_if = "Option::is_none")] - pub line2: Option<&'a str>, - /// ZIP or postal code. - #[serde(skip_serializing_if = "Option::is_none")] - pub postal_code: Option<&'a str>, - /// State, county, province, or region. - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option<&'a str>, -} -impl<'a> UpdateCustomerBankAccountOwnerAddress<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> UpdateCustomerBankAccount<'a> { - /// Update a specified source for a given customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<UpdateCustomerBankAccountReturned> { - client.send_form( - &format!("/customers/{customer}/sources/{id}"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum UpdateCustomerBankAccountReturned { - #[serde(rename = "card")] - Card(stripe_shared::Card), - #[serde(rename = "bank_account")] - BankAccount(stripe_shared::BankAccount), - #[serde(rename = "source")] - Source(stripe_shared::Source), -} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct VerifyBankAccount<'a> { - /// Two positive integers, in *cents*, equal to the values of the microdeposits sent to the bank account. - #[serde(skip_serializing_if = "Option::is_none")] - pub amounts: Option<&'a [i64]>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> VerifyBankAccount<'a> { +pub struct DeleteAccountBankAccount {} +impl DeleteAccountBankAccount { pub fn new() -> Self { Self::default() } } -impl<'a> VerifyBankAccount<'a> { - /// Verify a specified bank account for a given customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<stripe_shared::BankAccount> { - client.send_form( - &format!("/customers/{customer}/sources/{id}/verify"), - self, - http_types::Method::Post, - ) +impl DeleteAccountBankAccount { + /// Delete a specified external account for a given account. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, id: &str) -> stripe::Response<stripe_shared::DeletedExternalAccount> { + client.send_form(&format!("/accounts/{account}/external_accounts/{id}"), self, http_types::Method::Delete) } } diff --git a/generated/stripe_payment/src/card/requests.rs b/generated/stripe_payment/src/card/requests.rs index 37fe3124b..2b387ce2f 100644 --- a/generated/stripe_payment/src/card/requests.rs +++ b/generated/stripe_payment/src/card/requests.rs @@ -1,25 +1,252 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteAccountCard {} -impl DeleteAccountCard { +pub struct UpdateCustomerCard<'a> { + /// The name of the person or business that owns the bank account. + #[serde(skip_serializing_if = "Option::is_none")] + pub account_holder_name: Option<&'a str>, + /// The type of entity that holds the account. This can be either `individual` or `company`. + #[serde(skip_serializing_if = "Option::is_none")] + pub account_holder_type: Option<UpdateCustomerCardAccountHolderType>, + /// City/District/Suburb/Town/Village. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_city: Option<&'a str>, + /// Billing address country, if provided when creating card. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_country: Option<&'a str>, + /// Address line 1 (Street address/PO Box/Company name). + #[serde(skip_serializing_if = "Option::is_none")] + pub address_line1: Option<&'a str>, + /// Address line 2 (Apartment/Suite/Unit/Building). + #[serde(skip_serializing_if = "Option::is_none")] + pub address_line2: Option<&'a str>, + /// State/County/Province/Region. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_state: Option<&'a str>, + /// ZIP or postal code. + #[serde(skip_serializing_if = "Option::is_none")] + pub address_zip: Option<&'a str>, + /// Two digit number representing the card’s expiration month. + #[serde(skip_serializing_if = "Option::is_none")] + pub exp_month: Option<&'a str>, + /// Four digit number representing the card’s expiration year. + #[serde(skip_serializing_if = "Option::is_none")] + pub exp_year: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// Cardholder name. + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option<&'a str>, + #[serde(skip_serializing_if = "Option::is_none")] + pub owner: Option<UpdateCustomerCardOwner<'a>>, +} +impl<'a> UpdateCustomerCard<'a> { pub fn new() -> Self { Self::default() } } -impl DeleteAccountCard { - /// Delete a specified external account for a given account. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - id: &str, - ) -> stripe::Response<stripe_shared::DeletedExternalAccount> { - client.send_form( - &format!("/accounts/{account}/external_accounts/{id}"), - self, - http_types::Method::Delete, - ) +/// The type of entity that holds the account. This can be either `individual` or `company`. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum UpdateCustomerCardAccountHolderType { + Company, + Individual, +} +impl UpdateCustomerCardAccountHolderType { + pub fn as_str(self) -> &'static str { + use UpdateCustomerCardAccountHolderType::*; + match self { + Company => "company", + Individual => "individual", + } + } +} + +impl std::str::FromStr for UpdateCustomerCardAccountHolderType { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use UpdateCustomerCardAccountHolderType::*; + match s { + "company" => Ok(Company), + "individual" => Ok(Individual), + _ => Err(()), + } + } +} +impl std::fmt::Display for UpdateCustomerCardAccountHolderType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for UpdateCustomerCardAccountHolderType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for UpdateCustomerCardAccountHolderType { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateCustomerCardOwner<'a> { + /// Owner's address. + #[serde(skip_serializing_if = "Option::is_none")] + pub address: Option<UpdateCustomerCardOwnerAddress<'a>>, + /// Owner's email address. + #[serde(skip_serializing_if = "Option::is_none")] + pub email: Option<&'a str>, + /// Owner's full name. + #[serde(skip_serializing_if = "Option::is_none")] + pub name: Option<&'a str>, + /// Owner's phone number. + #[serde(skip_serializing_if = "Option::is_none")] + pub phone: Option<&'a str>, +} +impl<'a> UpdateCustomerCardOwner<'a> { + pub fn new() -> Self { + Self::default() } } +/// Owner's address. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct UpdateCustomerCardOwnerAddress<'a> { + /// City, district, suburb, town, or village. + #[serde(skip_serializing_if = "Option::is_none")] + pub city: Option<&'a str>, + /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + #[serde(skip_serializing_if = "Option::is_none")] + pub country: Option<&'a str>, + /// Address line 1 (e.g., street, PO Box, or company name). + #[serde(skip_serializing_if = "Option::is_none")] + pub line1: Option<&'a str>, + /// Address line 2 (e.g., apartment, suite, unit, or building). + #[serde(skip_serializing_if = "Option::is_none")] + pub line2: Option<&'a str>, + /// ZIP or postal code. + #[serde(skip_serializing_if = "Option::is_none")] + pub postal_code: Option<&'a str>, + /// State, county, province, or region. + #[serde(skip_serializing_if = "Option::is_none")] + pub state: Option<&'a str>, +} +impl<'a> UpdateCustomerCardOwnerAddress<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> UpdateCustomerCard<'a> { + /// Update a specified source for a given customer. + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<UpdateCustomerCardReturned> { + client.send_form(&format!("/customers/{customer}/sources/{id}"), self, http_types::Method::Post) + } +} +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] +pub enum UpdateCustomerCardReturned { + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] + Card(stripe_shared::Card), + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] + BankAccount(stripe_shared::BankAccount), + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] + Source(stripe_shared::Source), +} + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct UpdateCustomerCardReturnedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<UpdateCustomerCardReturned>, + builder: UpdateCustomerCardReturnedBuilder, + } + + impl Deserialize for UpdateCustomerCardReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<UpdateCustomerCardReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for UpdateCustomerCardReturnedBuilder { + type Out = UpdateCustomerCardReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + UpdateCustomerCardReturned::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for UpdateCustomerCardReturned { + type Builder = UpdateCustomerCardReturnedBuilder; + } + impl UpdateCustomerCardReturned { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for UpdateCustomerCardReturned { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct DeleteCustomerCard<'a> { /// Specifies which fields in the response should be expanded. @@ -33,25 +260,90 @@ impl<'a> DeleteCustomerCard<'a> { } impl<'a> DeleteCustomerCard<'a> { /// Delete a specified source for a given customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<DeleteCustomerCardReturned> { - client.send_form( - &format!("/customers/{customer}/sources/{id}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<DeleteCustomerCardReturned> { + client.send_form(&format!("/customers/{customer}/sources/{id}"), self, http_types::Method::Delete) + } +} +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum DeleteCustomerCardReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct DeleteCustomerCardReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<DeleteCustomerCardReturned>, + builder: DeleteCustomerCardReturnedBuilder, + } + + impl Deserialize for DeleteCustomerCardReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<DeleteCustomerCardReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for DeleteCustomerCardReturnedBuilder { + type Out = DeleteCustomerCardReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + DeleteCustomerCardReturned::DeletedPaymentSource(FromValueOpt::from_value(Value::Object(o))?) + } else { + DeleteCustomerCardReturned::PaymentSource(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for DeleteCustomerCardReturned { + type Builder = DeleteCustomerCardReturnedBuilder; + } +}; + #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateAccountCard<'a> { /// The name of the person or business that owns the bank account. @@ -219,8 +511,7 @@ pub struct UpdateAccountCardDocuments<'a> { /// One or more documents that support the [Bank account ownership verification](https://support.stripe.com/questions/bank-account-ownership-verification) requirement. /// Must be a document associated with the bank account that displays the last 4 digits of the account number, either a statement or a voided check. #[serde(skip_serializing_if = "Option::is_none")] - pub bank_account_ownership_verification: - Option<UpdateAccountCardDocumentsBankAccountOwnershipVerification<'a>>, + pub bank_account_ownership_verification: Option<UpdateAccountCardDocumentsBankAccountOwnershipVerification<'a>>, } impl<'a> UpdateAccountCardDocuments<'a> { pub fn new() -> Self { @@ -245,186 +536,20 @@ impl<'a> UpdateAccountCard<'a> { /// Other bank account details are not editable by design. /// /// You can re-enable a disabled bank account by performing an update call without providing any arguments or changes. - pub fn send( - &self, - client: &stripe::Client, - account: &stripe_shared::AccountId, - id: &str, - ) -> stripe::Response<stripe_shared::ExternalAccount> { - client.send_form( - &format!("/accounts/{account}/external_accounts/{id}"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerCard<'a> { - /// The name of the person or business that owns the bank account. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_name: Option<&'a str>, - /// The type of entity that holds the account. This can be either `individual` or `company`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: Option<UpdateCustomerCardAccountHolderType>, - /// City/District/Suburb/Town/Village. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_city: Option<&'a str>, - /// Billing address country, if provided when creating card. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_country: Option<&'a str>, - /// Address line 1 (Street address/PO Box/Company name). - #[serde(skip_serializing_if = "Option::is_none")] - pub address_line1: Option<&'a str>, - /// Address line 2 (Apartment/Suite/Unit/Building). - #[serde(skip_serializing_if = "Option::is_none")] - pub address_line2: Option<&'a str>, - /// State/County/Province/Region. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_state: Option<&'a str>, - /// ZIP or postal code. - #[serde(skip_serializing_if = "Option::is_none")] - pub address_zip: Option<&'a str>, - /// Two digit number representing the card’s expiration month. - #[serde(skip_serializing_if = "Option::is_none")] - pub exp_month: Option<&'a str>, - /// Four digit number representing the card’s expiration year. - #[serde(skip_serializing_if = "Option::is_none")] - pub exp_year: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Cardholder name. - #[serde(skip_serializing_if = "Option::is_none")] - pub name: Option<&'a str>, - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<UpdateCustomerCardOwner<'a>>, -} -impl<'a> UpdateCustomerCard<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The type of entity that holds the account. This can be either `individual` or `company`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateCustomerCardAccountHolderType { - Company, - Individual, -} -impl UpdateCustomerCardAccountHolderType { - pub fn as_str(self) -> &'static str { - use UpdateCustomerCardAccountHolderType::*; - match self { - Company => "company", - Individual => "individual", - } - } -} - -impl std::str::FromStr for UpdateCustomerCardAccountHolderType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdateCustomerCardAccountHolderType::*; - match s { - "company" => Ok(Company), - "individual" => Ok(Individual), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdateCustomerCardAccountHolderType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdateCustomerCardAccountHolderType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdateCustomerCardAccountHolderType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, id: &str) -> stripe::Response<stripe_shared::ExternalAccount> { + client.send_form(&format!("/accounts/{account}/external_accounts/{id}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerCardOwner<'a> { - /// Owner's address. - #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option<UpdateCustomerCardOwnerAddress<'a>>, - /// Owner's email address. - #[serde(skip_serializing_if = "Option::is_none")] - pub email: Option<&'a str>, - /// Owner's full name. - #[serde(skip_serializing_if = "Option::is_none")] - pub name: Option<&'a str>, - /// Owner's phone number. - #[serde(skip_serializing_if = "Option::is_none")] - pub phone: Option<&'a str>, -} -impl<'a> UpdateCustomerCardOwner<'a> { +pub struct DeleteAccountCard {} +impl DeleteAccountCard { pub fn new() -> Self { Self::default() } } -/// Owner's address. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateCustomerCardOwnerAddress<'a> { - /// City, district, suburb, town, or village. - #[serde(skip_serializing_if = "Option::is_none")] - pub city: Option<&'a str>, - /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). - #[serde(skip_serializing_if = "Option::is_none")] - pub country: Option<&'a str>, - /// Address line 1 (e.g., street, PO Box, or company name). - #[serde(skip_serializing_if = "Option::is_none")] - pub line1: Option<&'a str>, - /// Address line 2 (e.g., apartment, suite, unit, or building). - #[serde(skip_serializing_if = "Option::is_none")] - pub line2: Option<&'a str>, - /// ZIP or postal code. - #[serde(skip_serializing_if = "Option::is_none")] - pub postal_code: Option<&'a str>, - /// State, county, province, or region. - #[serde(skip_serializing_if = "Option::is_none")] - pub state: Option<&'a str>, -} -impl<'a> UpdateCustomerCardOwnerAddress<'a> { - pub fn new() -> Self { - Self::default() +impl DeleteAccountCard { + /// Delete a specified external account for a given account. + pub fn send(&self, client: &stripe::Client, account: &stripe_shared::AccountId, id: &str) -> stripe::Response<stripe_shared::DeletedExternalAccount> { + client.send_form(&format!("/accounts/{account}/external_accounts/{id}"), self, http_types::Method::Delete) } } -impl<'a> UpdateCustomerCard<'a> { - /// Update a specified source for a given customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<UpdateCustomerCardReturned> { - client.send_form( - &format!("/customers/{customer}/sources/{id}"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] -pub enum UpdateCustomerCardReturned { - #[serde(rename = "card")] - Card(stripe_shared::Card), - #[serde(rename = "bank_account")] - BankAccount(stripe_shared::BankAccount), - #[serde(rename = "source")] - Source(stripe_shared::Source), -} diff --git a/generated/stripe_payment/src/mod.rs b/generated/stripe_payment/src/mod.rs index 523419582..e7a31049f 100644 --- a/generated/stripe_payment/src/mod.rs +++ b/generated/stripe_payment/src/mod.rs @@ -8,15 +8,32 @@ //! of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_payment; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub mod bank_account; pub use stripe_shared::bank_account::*; pub mod card; -pub use stripe_shared::card::*;pub use stripe_shared::card_issuing_account_terms_of_service::*;pub use stripe_shared::card_mandate_payment_method_details::*;pub use stripe_shared::deleted_bank_account::*;pub use stripe_shared::deleted_card::*;pub use stripe_shared::deleted_external_account::*;pub use stripe_shared::deleted_payment_source::*;pub use stripe_shared::external_account_requirements::*;pub use stripe_shared::networks::*;pub use stripe_shared::payment_flows_private_payment_methods_alipay::*;pub use stripe_shared::payment_flows_private_payment_methods_alipay_details::*;pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_extended_authorization_extended_authorization::*;pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_incremental_authorization_incremental_authorization::*;pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_overcapture_overcapture::*;pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_multicapture::*;pub use stripe_shared::payment_flows_private_payment_methods_klarna_dob::*; +pub use stripe_shared::card::*; +pub use stripe_shared::card_issuing_account_terms_of_service::*; +pub use stripe_shared::card_mandate_payment_method_details::*; +pub use stripe_shared::deleted_bank_account::*; +pub use stripe_shared::deleted_card::*; +pub use stripe_shared::deleted_external_account::*; +pub use stripe_shared::deleted_payment_source::*; +pub use stripe_shared::external_account_requirements::*; +pub use stripe_shared::networks::*; +pub use stripe_shared::payment_flows_private_payment_methods_alipay::*; +pub use stripe_shared::payment_flows_private_payment_methods_alipay_details::*; +pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_extended_authorization_extended_authorization::*; +pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_incremental_authorization_incremental_authorization::*; +pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_overcapture_overcapture::*; +pub use stripe_shared::payment_flows_private_payment_methods_card_details_api_resource_multicapture::*; +pub use stripe_shared::payment_flows_private_payment_methods_klarna_dob::*; pub mod payment_link; pub use stripe_shared::payment_link::*; pub use stripe_shared::payment_links_resource_after_completion::*; pub use stripe_shared::payment_links_resource_automatic_tax::*; -pub use stripe_shared::payment_links_resource_completed_sessions::*; pub use stripe_shared::payment_links_resource_completion_behavior_confirmation_page::*; pub use stripe_shared::payment_links_resource_completion_behavior_redirect::*; pub use stripe_shared::payment_links_resource_consent_collection::*; @@ -31,13 +48,10 @@ pub use stripe_shared::payment_links_resource_custom_text_position::*; pub use stripe_shared::payment_links_resource_invoice_creation::*; pub use stripe_shared::payment_links_resource_invoice_settings::*; pub use stripe_shared::payment_links_resource_payment_intent_data::*; -pub use stripe_shared::payment_links_resource_payment_method_reuse_agreement::*; pub use stripe_shared::payment_links_resource_phone_number_collection::*; -pub use stripe_shared::payment_links_resource_restrictions::*; pub use stripe_shared::payment_links_resource_shipping_address_collection::*; pub use stripe_shared::payment_links_resource_shipping_option::*; pub use stripe_shared::payment_links_resource_subscription_data::*; -pub use stripe_shared::payment_links_resource_subscription_data_invoice_settings::*; pub use stripe_shared::payment_links_resource_tax_id_collection::*; pub use stripe_shared::payment_links_resource_transfer_data::*; pub mod payment_method; @@ -128,7 +142,6 @@ pub use stripe_shared::payment_method_details_sepa_credit_transfer::*; pub use stripe_shared::payment_method_details_sepa_debit::*; pub use stripe_shared::payment_method_details_sofort::*; pub use stripe_shared::payment_method_details_stripe_account::*; -pub use stripe_shared::payment_method_details_swish::*; pub use stripe_shared::payment_method_details_us_bank_account::*; pub use stripe_shared::payment_method_details_wechat::*; pub use stripe_shared::payment_method_details_wechat_pay::*; @@ -179,7 +192,6 @@ pub use stripe_shared::payment_method_options_pix::*; pub use stripe_shared::payment_method_options_promptpay::*; pub use stripe_shared::payment_method_options_revolut_pay::*; pub use stripe_shared::payment_method_options_sofort::*; -pub use stripe_shared::payment_method_options_us_bank_account_mandate_options::*; pub use stripe_shared::payment_method_options_wechat_pay::*; pub use stripe_shared::payment_method_options_zip::*; pub use stripe_shared::payment_method_oxxo::*; @@ -191,7 +203,6 @@ pub use stripe_shared::payment_method_promptpay::*; pub use stripe_shared::payment_method_revolut_pay::*; pub use stripe_shared::payment_method_sepa_debit::*; pub use stripe_shared::payment_method_sofort::*; -pub use stripe_shared::payment_method_swish::*; pub use stripe_shared::payment_method_us_bank_account::*; pub use stripe_shared::payment_method_us_bank_account_blocked::*; pub use stripe_shared::payment_method_us_bank_account_status_details::*; diff --git a/generated/stripe_payment/src/payment_link/requests.rs b/generated/stripe_payment/src/payment_link/requests.rs index 14fde7ad6..e976c30a2 100644 --- a/generated/stripe_payment/src/payment_link/requests.rs +++ b/generated/stripe_payment/src/payment_link/requests.rs @@ -28,10 +28,7 @@ impl<'a> ListPaymentLink<'a> { } impl<'a> ListPaymentLink<'a> { /// Returns a list of your payment links. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::PaymentLink>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::PaymentLink>> { client.get_query("/payment_links", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentLink>> { @@ -51,11 +48,7 @@ impl<'a> RetrievePaymentLink<'a> { } impl<'a> RetrievePaymentLink<'a> { /// Retrieve a payment link. - pub fn send( - &self, - client: &stripe::Client, - payment_link: &stripe_shared::PaymentLinkId, - ) -> stripe::Response<stripe_shared::PaymentLink> { + pub fn send(&self, client: &stripe::Client, payment_link: &stripe_shared::PaymentLinkId) -> stripe::Response<stripe_shared::PaymentLink> { client.get_query(&format!("/payment_links/{payment_link}"), self) } } @@ -87,21 +80,11 @@ impl<'a> ListLineItemsPaymentLink<'a> { impl<'a> ListLineItemsPaymentLink<'a> { /// When retrieving a payment link, there is an includable **line_items** property containing the first handful of those items. /// There is also a URL where you can retrieve the full (paginated) list of line items. - pub fn send( - &self, - client: &stripe::Client, - payment_link: &stripe_shared::PaymentLinkId, - ) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + pub fn send(&self, client: &stripe::Client, payment_link: &stripe_shared::PaymentLinkId) -> stripe::Response<stripe_types::List<stripe_shared::CheckoutSessionItem>> { client.get_query(&format!("/payment_links/{payment_link}/line_items"), self) } - pub fn paginate( - self, - payment_link: &stripe_shared::PaymentLinkId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { - stripe::ListPaginator::from_list_params( - &format!("/payment_links/{payment_link}/line_items"), - self, - ) + pub fn paginate(self, payment_link: &stripe_shared::PaymentLinkId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::CheckoutSessionItem>> { + stripe::ListPaginator::from_list_params(&format!("/payment_links/{payment_link}/line_items"), self) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -123,7 +106,7 @@ pub struct CreatePaymentLink<'a> { pub application_fee_percent: Option<f64>, /// Configuration for automatic tax collection. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<CreatePaymentLinkAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxParams>, /// Configuration for collecting the customer's billing address. #[serde(skip_serializing_if = "Option::is_none")] pub billing_address_collection: Option<stripe_shared::PaymentLinkBillingAddressCollection>, @@ -135,7 +118,7 @@ pub struct CreatePaymentLink<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<stripe_types::Currency>, /// Collect additional information from your customer using custom fields. - /// Up to 3 fields are supported. + /// Up to 2 fields are supported. #[serde(skip_serializing_if = "Option::is_none")] pub custom_fields: Option<&'a [CreatePaymentLinkCustomFields<'a>]>, /// Display additional text for your customers using custom text. @@ -147,9 +130,6 @@ pub struct CreatePaymentLink<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// The custom message to be displayed to a customer when a payment link is no longer active. - #[serde(skip_serializing_if = "Option::is_none")] - pub inactive_message: Option<&'a str>, /// Generate a post-purchase Invoice for one-time payments. #[serde(skip_serializing_if = "Option::is_none")] pub invoice_creation: Option<CreatePaymentLinkInvoiceCreation<'a>>, @@ -187,9 +167,6 @@ pub struct CreatePaymentLink<'a> { /// We recommend that you review your privacy policy and check with your legal contacts. #[serde(skip_serializing_if = "Option::is_none")] pub phone_number_collection: Option<CreatePaymentLinkPhoneNumberCollection>, - /// Settings that restrict the usage of a payment link. - #[serde(skip_serializing_if = "Option::is_none")] - pub restrictions: Option<RestrictionsParams>, /// Configuration for collecting the customer's shipping address. #[serde(skip_serializing_if = "Option::is_none")] pub shipping_address_collection: Option<CreatePaymentLinkShippingAddressCollection<'a>>, @@ -226,7 +203,6 @@ impl<'a> CreatePaymentLink<'a> { custom_text: None, customer_creation: None, expand: None, - inactive_message: None, invoice_creation: None, line_items, metadata: None, @@ -235,7 +211,6 @@ impl<'a> CreatePaymentLink<'a> { payment_method_collection: None, payment_method_types: None, phone_number_collection: None, - restrictions: None, shipping_address_collection: None, shipping_options: None, submit_type: None, @@ -255,7 +230,7 @@ pub struct CreatePaymentLinkAfterCompletion<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option<AfterCompletionRedirectParams<'a>>, /// The specified behavior after the purchase is complete. Either `redirect` or `hosted_confirmation`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreatePaymentLinkAfterCompletionType, } impl<'a> CreatePaymentLinkAfterCompletion<'a> { @@ -309,93 +284,9 @@ impl serde::Serialize for CreatePaymentLinkAfterCompletionType { serializer.serialize_str(self.as_str()) } } -/// Configuration for automatic tax collection. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentLinkAutomaticTax<'a> { - /// If `true`, tax will be calculated automatically using the customer's location. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<CreatePaymentLinkAutomaticTaxLiability<'a>>, -} -impl<'a> CreatePaymentLinkAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentLinkAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreatePaymentLinkAutomaticTaxLiabilityType, -} -impl<'a> CreatePaymentLinkAutomaticTaxLiability<'a> { - pub fn new(type_: CreatePaymentLinkAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentLinkAutomaticTaxLiabilityType { - Account, - Self_, -} -impl CreatePaymentLinkAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use CreatePaymentLinkAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreatePaymentLinkAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentLinkAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentLinkAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentLinkAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentLinkAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Configure fields to gather active consent from customers. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentLinkConsentCollection { - /// Determines the display of payment method reuse agreement text in the UI. - /// If set to `hidden`, it will hide legal text related to the reuse of a payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_method_reuse_agreement: - Option<CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreement>, /// If set to `auto`, enables the collection of customer consent for promotional communications. /// The Checkout. /// Session will determine whether to display an option to opt into promotional communication @@ -412,72 +303,6 @@ impl CreatePaymentLinkConsentCollection { Self::default() } } -/// Determines the display of payment method reuse agreement text in the UI. -/// If set to `hidden`, it will hide legal text related to the reuse of a payment method. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreement { - /// Determines the position and visibility of the payment method reuse agreement in the UI. - /// When set to `auto`, Stripe's. - /// defaults will be used. - /// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. - pub position: CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition, -} -impl CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreement { - pub fn new( - position: CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition, - ) -> Self { - Self { position } - } -} -/// Determines the position and visibility of the payment method reuse agreement in the UI. -/// When set to `auto`, Stripe's. -/// defaults will be used. -/// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition { - Auto, - Hidden, -} -impl CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition { - pub fn as_str(self) -> &'static str { - use CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition::*; - match self { - Auto => "auto", - Hidden => "hidden", - } - } -} - -impl std::str::FromStr for CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition::*; - match s { - "auto" => Ok(Auto), - "hidden" => Ok(Hidden), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// If set to `auto`, enables the collection of customer consent for promotional communications. /// The Checkout. /// Session will determine whether to display an option to opt into promotional communication @@ -575,7 +400,7 @@ impl serde::Serialize for CreatePaymentLinkConsentCollectionTermsOfService { } } /// Collect additional information from your customer using custom fields. -/// Up to 3 fields are supported. +/// Up to 2 fields are supported. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentLinkCustomFields<'a> { /// Configuration for `type=dropdown` fields. @@ -597,15 +422,11 @@ pub struct CreatePaymentLinkCustomFields<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub text: Option<CreatePaymentLinkCustomFieldsText>, /// The type of the field. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreatePaymentLinkCustomFieldsType, } impl<'a> CreatePaymentLinkCustomFields<'a> { - pub fn new( - key: &'a str, - label: CreatePaymentLinkCustomFieldsLabel<'a>, - type_: CreatePaymentLinkCustomFieldsType, - ) -> Self { + pub fn new(key: &'a str, label: CreatePaymentLinkCustomFieldsLabel<'a>, type_: CreatePaymentLinkCustomFieldsType) -> Self { Self { dropdown: None, key, label, numeric: None, optional: None, text: None, type_ } } } @@ -615,7 +436,7 @@ pub struct CreatePaymentLinkCustomFieldsLabel<'a> { /// Custom text for the label, displayed to the customer. Up to 50 characters. pub custom: &'a str, /// The type of the label. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreatePaymentLinkCustomFieldsLabelType, } impl<'a> CreatePaymentLinkCustomFieldsLabel<'a> { @@ -820,10 +641,6 @@ pub struct CreatePaymentLinkInvoiceCreationInvoiceData<'a> { /// Default footer to be displayed on invoices for this customer. #[serde(skip_serializing_if = "Option::is_none")] pub footer: Option<&'a str>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreatePaymentLinkInvoiceCreationInvoiceDataIssuer<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -839,68 +656,6 @@ impl<'a> CreatePaymentLinkInvoiceCreationInvoiceData<'a> { Self::default() } } -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentLinkInvoiceCreationInvoiceDataIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType, -} -impl<'a> CreatePaymentLinkInvoiceCreationInvoiceDataIssuer<'a> { - pub fn new(type_: CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - Account, - Self_, -} -impl CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - pub fn as_str(self) -> &'static str { - use CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Default options for invoice PDF rendering for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { @@ -909,8 +664,7 @@ pub struct CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: - Option<CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay>, + pub amount_tax_display: Option<CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay>, } impl CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { pub fn new() -> Self { @@ -936,9 +690,7 @@ impl CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay } } -impl std::str::FromStr - for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::str::FromStr for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay::*; @@ -949,24 +701,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::fmt::Display for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::fmt::Debug for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl serde::Serialize for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1029,10 +775,6 @@ pub struct CreatePaymentLinkPaymentIntentData<'a> { /// Maximum 22 characters for the concatenated descriptor. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix: Option<&'a str>, - /// A string that identifies the resulting payment as part of a group. - /// See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/connect/separate-charges-and-transfers) for details. - #[serde(skip_serializing_if = "Option::is_none")] - pub transfer_group: Option<&'a str>, } impl<'a> CreatePaymentLinkPaymentIntentData<'a> { pub fn new() -> Self { @@ -1218,9 +960,7 @@ pub struct CreatePaymentLinkShippingAddressCollection<'a> { pub allowed_countries: &'a [CreatePaymentLinkShippingAddressCollectionAllowedCountries], } impl<'a> CreatePaymentLinkShippingAddressCollection<'a> { - pub fn new( - allowed_countries: &'a [CreatePaymentLinkShippingAddressCollectionAllowedCountries], - ) -> Self { + pub fn new(allowed_countries: &'a [CreatePaymentLinkShippingAddressCollectionAllowedCountries]) -> Self { Self { allowed_countries } } } @@ -2001,9 +1741,6 @@ pub struct CreatePaymentLinkSubscriptionData<'a> { /// Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<&'a str>, - /// All invoices will be billed using the specified settings. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<CreatePaymentLinkSubscriptionDataInvoiceSettings<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that will declaratively set metadata on [Subscriptions](https://stripe.com/docs/api/subscriptions) generated from this payment link. /// Unlike object-level metadata, this field is declarative. /// Updates will clear prior values. @@ -2013,172 +1750,12 @@ pub struct CreatePaymentLinkSubscriptionData<'a> { /// Has to be at least 1. #[serde(skip_serializing_if = "Option::is_none")] pub trial_period_days: Option<u32>, - /// Settings related to subscription trials. - #[serde(skip_serializing_if = "Option::is_none")] - pub trial_settings: Option<CreatePaymentLinkSubscriptionDataTrialSettings>, } impl<'a> CreatePaymentLinkSubscriptionData<'a> { pub fn new() -> Self { Self::default() } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentLinkSubscriptionDataInvoiceSettings<'a> { - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuer<'a>>, -} -impl<'a> CreatePaymentLinkSubscriptionDataInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType, -} -impl<'a> CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuer<'a> { - pub fn new(type_: CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - Account, - Self_, -} -impl CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Settings related to subscription trials. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentLinkSubscriptionDataTrialSettings { - /// Defines how the subscription should behave when the user's free trial ends. - pub end_behavior: CreatePaymentLinkSubscriptionDataTrialSettingsEndBehavior, -} -impl CreatePaymentLinkSubscriptionDataTrialSettings { - pub fn new(end_behavior: CreatePaymentLinkSubscriptionDataTrialSettingsEndBehavior) -> Self { - Self { end_behavior } - } -} -/// Defines how the subscription should behave when the user's free trial ends. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreatePaymentLinkSubscriptionDataTrialSettingsEndBehavior { - /// Indicates how the subscription should change when the trial ends if the user did not provide a payment method. - pub missing_payment_method: - CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod, -} -impl CreatePaymentLinkSubscriptionDataTrialSettingsEndBehavior { - pub fn new( - missing_payment_method: CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod, - ) -> Self { - Self { missing_payment_method } - } -} -/// Indicates how the subscription should change when the trial ends if the user did not provide a payment method. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { - Cancel, - CreateInvoice, - Pause, -} -impl CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { - pub fn as_str(self) -> &'static str { - use CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::*; - match self { - Cancel => "cancel", - CreateInvoice => "create_invoice", - Pause => "pause", - } - } -} - -impl std::str::FromStr - for CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::*; - match s { - "cancel" => Ok(Cancel), - "create_invoice" => Ok(CreateInvoice), - "pause" => Ok(Pause), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Controls tax ID collection during checkout. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentLinkTaxIdCollection { @@ -2227,12 +1804,12 @@ pub struct UpdatePaymentLink<'a> { pub allow_promotion_codes: Option<bool>, /// Configuration for automatic tax collection. #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: Option<UpdatePaymentLinkAutomaticTax<'a>>, + pub automatic_tax: Option<AutomaticTaxParams>, /// Configuration for collecting the customer's billing address. #[serde(skip_serializing_if = "Option::is_none")] pub billing_address_collection: Option<stripe_shared::PaymentLinkBillingAddressCollection>, /// Collect additional information from your customer using custom fields. - /// Up to 3 fields are supported. + /// Up to 2 fields are supported. #[serde(skip_serializing_if = "Option::is_none")] pub custom_fields: Option<&'a [UpdatePaymentLinkCustomFields<'a>]>, /// Display additional text for your customers using custom text. @@ -2244,9 +1821,6 @@ pub struct UpdatePaymentLink<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// The custom message to be displayed to a customer when a payment link is no longer active. - #[serde(skip_serializing_if = "Option::is_none")] - pub inactive_message: Option<&'a str>, /// Generate a post-purchase Invoice for one-time payments. #[serde(skip_serializing_if = "Option::is_none")] pub invoice_creation: Option<UpdatePaymentLinkInvoiceCreation<'a>>, @@ -2277,9 +1851,6 @@ pub struct UpdatePaymentLink<'a> { /// Pass an empty string to enable dynamic payment methods that use your [payment method settings](https://dashboard.stripe.com/settings/payment_methods). #[serde(skip_serializing_if = "Option::is_none")] pub payment_method_types: Option<&'a [stripe_shared::PaymentLinkPaymentMethodTypes]>, - /// Settings that restrict the usage of a payment link. - #[serde(skip_serializing_if = "Option::is_none")] - pub restrictions: Option<RestrictionsParams>, /// Configuration for collecting the customer's shipping address. #[serde(skip_serializing_if = "Option::is_none")] pub shipping_address_collection: Option<UpdatePaymentLinkShippingAddressCollection<'a>>, @@ -2303,7 +1874,7 @@ pub struct UpdatePaymentLinkAfterCompletion<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option<AfterCompletionRedirectParams<'a>>, /// The specified behavior after the purchase is complete. Either `redirect` or `hosted_confirmation`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: UpdatePaymentLinkAfterCompletionType, } impl<'a> UpdatePaymentLinkAfterCompletion<'a> { @@ -2357,87 +1928,8 @@ impl serde::Serialize for UpdatePaymentLinkAfterCompletionType { serializer.serialize_str(self.as_str()) } } -/// Configuration for automatic tax collection. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentLinkAutomaticTax<'a> { - /// If `true`, tax will be calculated automatically using the customer's location. - pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - #[serde(skip_serializing_if = "Option::is_none")] - pub liability: Option<UpdatePaymentLinkAutomaticTaxLiability<'a>>, -} -impl<'a> UpdatePaymentLinkAutomaticTax<'a> { - pub fn new(enabled: bool) -> Self { - Self { enabled, liability: None } - } -} -/// The account that's liable for tax. -/// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. -/// The tax transaction is returned in the report of the connected account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentLinkAutomaticTaxLiability<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdatePaymentLinkAutomaticTaxLiabilityType, -} -impl<'a> UpdatePaymentLinkAutomaticTaxLiability<'a> { - pub fn new(type_: UpdatePaymentLinkAutomaticTaxLiabilityType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentLinkAutomaticTaxLiabilityType { - Account, - Self_, -} -impl UpdatePaymentLinkAutomaticTaxLiabilityType { - pub fn as_str(self) -> &'static str { - use UpdatePaymentLinkAutomaticTaxLiabilityType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdatePaymentLinkAutomaticTaxLiabilityType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentLinkAutomaticTaxLiabilityType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentLinkAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentLinkAutomaticTaxLiabilityType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentLinkAutomaticTaxLiabilityType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Collect additional information from your customer using custom fields. -/// Up to 3 fields are supported. +/// Up to 2 fields are supported. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentLinkCustomFields<'a> { /// Configuration for `type=dropdown` fields. @@ -2459,15 +1951,11 @@ pub struct UpdatePaymentLinkCustomFields<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub text: Option<UpdatePaymentLinkCustomFieldsText>, /// The type of the field. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: UpdatePaymentLinkCustomFieldsType, } impl<'a> UpdatePaymentLinkCustomFields<'a> { - pub fn new( - key: &'a str, - label: UpdatePaymentLinkCustomFieldsLabel<'a>, - type_: UpdatePaymentLinkCustomFieldsType, - ) -> Self { + pub fn new(key: &'a str, label: UpdatePaymentLinkCustomFieldsLabel<'a>, type_: UpdatePaymentLinkCustomFieldsType) -> Self { Self { dropdown: None, key, label, numeric: None, optional: None, text: None, type_ } } } @@ -2477,7 +1965,7 @@ pub struct UpdatePaymentLinkCustomFieldsLabel<'a> { /// Custom text for the label, displayed to the customer. Up to 50 characters. pub custom: &'a str, /// The type of the label. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: UpdatePaymentLinkCustomFieldsLabelType, } impl<'a> UpdatePaymentLinkCustomFieldsLabel<'a> { @@ -2682,10 +2170,6 @@ pub struct UpdatePaymentLinkInvoiceCreationInvoiceData<'a> { /// Default footer to be displayed on invoices for this customer. #[serde(skip_serializing_if = "Option::is_none")] pub footer: Option<&'a str>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpdatePaymentLinkInvoiceCreationInvoiceDataIssuer<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. /// Individual keys can be unset by posting an empty value to them. @@ -2701,68 +2185,6 @@ impl<'a> UpdatePaymentLinkInvoiceCreationInvoiceData<'a> { Self::default() } } -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentLinkInvoiceCreationInvoiceDataIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType, -} -impl<'a> UpdatePaymentLinkInvoiceCreationInvoiceDataIssuer<'a> { - pub fn new(type_: UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - Account, - Self_, -} -impl UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - pub fn as_str(self) -> &'static str { - use UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} /// Default options for invoice PDF rendering for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { @@ -2771,8 +2193,7 @@ pub struct UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts. /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts. #[serde(skip_serializing_if = "Option::is_none")] - pub amount_tax_display: - Option<UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay>, + pub amount_tax_display: Option<UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay>, } impl UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { pub fn new() -> Self { @@ -2798,9 +2219,7 @@ impl UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay } } -impl std::str::FromStr - for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::str::FromStr for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay::*; @@ -2811,24 +2230,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::fmt::Display for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl std::fmt::Debug for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay -{ +impl serde::Serialize for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2875,10 +2288,6 @@ pub struct UpdatePaymentLinkPaymentIntentData<'a> { /// Maximum 22 characters for the concatenated descriptor. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix: Option<&'a str>, - /// A string that identifies the resulting payment as part of a group. - /// See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/connect/separate-charges-and-transfers) for details. - #[serde(skip_serializing_if = "Option::is_none")] - pub transfer_group: Option<&'a str>, } impl<'a> UpdatePaymentLinkPaymentIntentData<'a> { pub fn new() -> Self { @@ -2945,9 +2354,7 @@ pub struct UpdatePaymentLinkShippingAddressCollection<'a> { pub allowed_countries: &'a [UpdatePaymentLinkShippingAddressCollectionAllowedCountries], } impl<'a> UpdatePaymentLinkShippingAddressCollection<'a> { - pub fn new( - allowed_countries: &'a [UpdatePaymentLinkShippingAddressCollectionAllowedCountries], - ) -> Self { + pub fn new(allowed_countries: &'a [UpdatePaymentLinkShippingAddressCollectionAllowedCountries]) -> Self { Self { allowed_countries } } } @@ -3712,187 +3119,20 @@ impl serde::Serialize for UpdatePaymentLinkShippingAddressCollectionAllowedCount /// There must be at least one line item with a recurring price to use `subscription_data`. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentLinkSubscriptionData<'a> { - /// All invoices will be billed using the specified settings. - #[serde(skip_serializing_if = "Option::is_none")] - pub invoice_settings: Option<UpdatePaymentLinkSubscriptionDataInvoiceSettings<'a>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that will declaratively set metadata on [Subscriptions](https://stripe.com/docs/api/subscriptions) generated from this payment link. /// Unlike object-level metadata, this field is declarative. /// Updates will clear prior values. #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Settings related to subscription trials. - #[serde(skip_serializing_if = "Option::is_none")] - pub trial_settings: Option<UpdatePaymentLinkSubscriptionDataTrialSettings>, } impl<'a> UpdatePaymentLinkSubscriptionData<'a> { pub fn new() -> Self { Self::default() } } -/// All invoices will be billed using the specified settings. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentLinkSubscriptionDataInvoiceSettings<'a> { - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - #[serde(skip_serializing_if = "Option::is_none")] - pub issuer: Option<UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuer<'a>>, -} -impl<'a> UpdatePaymentLinkSubscriptionDataInvoiceSettings<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// The connected account that issues the invoice. -/// The invoice is presented with the branding and support information of the specified account. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuer<'a> { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<&'a str>, - /// Type of the account referenced in the request. - #[serde(rename = "type")] - pub type_: UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType, -} -impl<'a> UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuer<'a> { - pub fn new(type_: UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType) -> Self { - Self { account: None, type_ } - } -} -/// Type of the account referenced in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - Account, - Self_, -} -impl UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - pub fn as_str(self) -> &'static str { - use UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Settings related to subscription trials. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentLinkSubscriptionDataTrialSettings { - /// Defines how the subscription should behave when the user's free trial ends. - pub end_behavior: UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehavior, -} -impl UpdatePaymentLinkSubscriptionDataTrialSettings { - pub fn new(end_behavior: UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehavior) -> Self { - Self { end_behavior } - } -} -/// Defines how the subscription should behave when the user's free trial ends. -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehavior { - /// Indicates how the subscription should change when the trial ends if the user did not provide a payment method. - pub missing_payment_method: - UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod, -} -impl UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehavior { - pub fn new( - missing_payment_method: UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod, - ) -> Self { - Self { missing_payment_method } - } -} -/// Indicates how the subscription should change when the trial ends if the user did not provide a payment method. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { - Cancel, - CreateInvoice, - Pause, -} -impl UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod { - pub fn as_str(self) -> &'static str { - use UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::*; - match self { - Cancel => "cancel", - CreateInvoice => "create_invoice", - Pause => "pause", - } - } -} - -impl std::str::FromStr - for UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::*; - match s { - "cancel" => Ok(Cancel), - "create_invoice" => Ok(CreateInvoice), - "pause" => Ok(Pause), - _ => Err(()), - } - } -} -impl std::fmt::Display - for UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} impl<'a> UpdatePaymentLink<'a> { /// Updates a payment link. - pub fn send( - &self, - client: &stripe::Client, - payment_link: &stripe_shared::PaymentLinkId, - ) -> stripe::Response<stripe_shared::PaymentLink> { + pub fn send(&self, client: &stripe::Client, payment_link: &stripe_shared::PaymentLinkId) -> stripe::Response<stripe_shared::PaymentLink> { client.send_form(&format!("/payment_links/{payment_link}"), self, http_types::Method::Post) } } @@ -3919,6 +3159,16 @@ impl<'a> AfterCompletionRedirectParams<'a> { } } #[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct AutomaticTaxParams { + /// If `true`, tax will be calculated automatically using the customer's location. + pub enabled: bool, +} +impl AutomaticTaxParams { + pub fn new(enabled: bool) -> Self { + Self { enabled } + } +} +#[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CustomFieldOptionParam<'a> { /// The label for the option, displayed to the customer. Up to 100 characters. pub label: &'a str, @@ -3974,16 +3224,6 @@ impl AdjustableQuantityParams { } } #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CompletedSessionsParams { - /// The maximum number of checkout sessions that can be completed for the `completed_sessions` restriction to be met. - pub limit: i64, -} -impl CompletedSessionsParams { - pub fn new(limit: i64) -> Self { - Self { limit } - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CustomFieldDropdownParam<'a> { /// The options available for the customer to select. Up to 200 options allowed. pub options: &'a [CustomFieldOptionParam<'a>], @@ -3995,9 +3235,6 @@ impl<'a> CustomFieldDropdownParam<'a> { } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CustomTextParam<'a> { - /// Custom text that should be displayed after the payment confirmation button. - #[serde(skip_serializing_if = "Option::is_none")] - pub after_submit: Option<CustomTextPositionParam<'a>>, /// Custom text that should be displayed alongside shipping address collection. #[serde(skip_serializing_if = "Option::is_none")] pub shipping_address: Option<CustomTextPositionParam<'a>>, @@ -4013,13 +3250,3 @@ impl<'a> CustomTextParam<'a> { Self::default() } } -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct RestrictionsParams { - /// Configuration for the `completed_sessions` restriction type. - pub completed_sessions: CompletedSessionsParams, -} -impl RestrictionsParams { - pub fn new(completed_sessions: CompletedSessionsParams) -> Self { - Self { completed_sessions } - } -} diff --git a/generated/stripe_payment/src/payment_method/requests.rs b/generated/stripe_payment/src/payment_method/requests.rs index 9e1f1f17b..0b5bddf5e 100644 --- a/generated/stripe_payment/src/payment_method/requests.rs +++ b/generated/stripe_payment/src/payment_method/requests.rs @@ -1,220 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListPaymentMethod<'a> { - /// The ID of the customer whose PaymentMethods will be retrieved. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// An optional filter on the list, based on the object `type` field. - /// Without the filter, the list includes all current and future payment method types. - /// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub type_: Option<ListPaymentMethodType>, -} -impl<'a> ListPaymentMethod<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// An optional filter on the list, based on the object `type` field. -/// Without the filter, the list includes all current and future payment method types. -/// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. -#[derive(Copy, Clone, Eq, PartialEq)] -#[non_exhaustive] -pub enum ListPaymentMethodType { - AcssDebit, - Affirm, - AfterpayClearpay, - Alipay, - AuBecsDebit, - BacsDebit, - Bancontact, - Blik, - Boleto, - Card, - Cashapp, - CustomerBalance, - Eps, - Fpx, - Giropay, - Grabpay, - Ideal, - Klarna, - Konbini, - Link, - Oxxo, - P24, - Paynow, - Paypal, - Pix, - Promptpay, - RevolutPay, - SepaDebit, - Sofort, - Swish, - UsBankAccount, - WechatPay, - Zip, - /// An unrecognized value from Stripe. Should not be used as a request parameter. - Unknown, -} -impl ListPaymentMethodType { - pub fn as_str(self) -> &'static str { - use ListPaymentMethodType::*; - match self { - AcssDebit => "acss_debit", - Affirm => "affirm", - AfterpayClearpay => "afterpay_clearpay", - Alipay => "alipay", - AuBecsDebit => "au_becs_debit", - BacsDebit => "bacs_debit", - Bancontact => "bancontact", - Blik => "blik", - Boleto => "boleto", - Card => "card", - Cashapp => "cashapp", - CustomerBalance => "customer_balance", - Eps => "eps", - Fpx => "fpx", - Giropay => "giropay", - Grabpay => "grabpay", - Ideal => "ideal", - Klarna => "klarna", - Konbini => "konbini", - Link => "link", - Oxxo => "oxxo", - P24 => "p24", - Paynow => "paynow", - Paypal => "paypal", - Pix => "pix", - Promptpay => "promptpay", - RevolutPay => "revolut_pay", - SepaDebit => "sepa_debit", - Sofort => "sofort", - Swish => "swish", - UsBankAccount => "us_bank_account", - WechatPay => "wechat_pay", - Zip => "zip", - Unknown => "unknown", - } - } -} - -impl std::str::FromStr for ListPaymentMethodType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ListPaymentMethodType::*; - match s { - "acss_debit" => Ok(AcssDebit), - "affirm" => Ok(Affirm), - "afterpay_clearpay" => Ok(AfterpayClearpay), - "alipay" => Ok(Alipay), - "au_becs_debit" => Ok(AuBecsDebit), - "bacs_debit" => Ok(BacsDebit), - "bancontact" => Ok(Bancontact), - "blik" => Ok(Blik), - "boleto" => Ok(Boleto), - "card" => Ok(Card), - "cashapp" => Ok(Cashapp), - "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), - "fpx" => Ok(Fpx), - "giropay" => Ok(Giropay), - "grabpay" => Ok(Grabpay), - "ideal" => Ok(Ideal), - "klarna" => Ok(Klarna), - "konbini" => Ok(Konbini), - "link" => Ok(Link), - "oxxo" => Ok(Oxxo), - "p24" => Ok(P24), - "paynow" => Ok(Paynow), - "paypal" => Ok(Paypal), - "pix" => Ok(Pix), - "promptpay" => Ok(Promptpay), - "revolut_pay" => Ok(RevolutPay), - "sepa_debit" => Ok(SepaDebit), - "sofort" => Ok(Sofort), - "swish" => Ok(Swish), - "us_bank_account" => Ok(UsBankAccount), - "wechat_pay" => Ok(WechatPay), - "zip" => Ok(Zip), - _ => Err(()), - } - } -} -impl std::fmt::Display for ListPaymentMethodType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ListPaymentMethodType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ListPaymentMethodType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> ListPaymentMethod<'a> { - /// Returns a list of PaymentMethods for Treasury flows. - /// If you want to list the PaymentMethods attached to a Customer for payments, you should use the [List a Customer’s PaymentMethods](https://stripe.com/docs/api/payment_methods/customer_list) API instead. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::PaymentMethod>> { - client.get_query("/payment_methods", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentMethod>> { - stripe::ListPaginator::from_list_params("/payment_methods", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrievePaymentMethod<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrievePaymentMethod<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrievePaymentMethod<'a> { - /// Retrieves a PaymentMethod object attached to the StripeAccount. - /// To retrieve a payment method attached to a Customer, you should use [Retrieve a Customer’s PaymentMethods](https://stripe.com/docs/api/payment_methods/customer). - pub fn send( - &self, - client: &stripe::Client, - payment_method: &stripe_shared::PaymentMethodId, - ) -> stripe::Response<stripe_shared::PaymentMethod> { - client.get_query(&format!("/payment_methods/{payment_method}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentMethod<'a> { /// If this is an `acss_debit` PaymentMethod, this hash contains details about the ACSS Debit payment method. #[serde(skip_serializing_if = "Option::is_none")] @@ -331,13 +115,10 @@ pub struct CreatePaymentMethod<'a> { /// If this is a `sofort` PaymentMethod, this hash contains details about the SOFORT payment method. #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<CreatePaymentMethodSofort>, - /// If this is a `swish` PaymentMethod, this hash contains details about the Swish payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<&'a serde_json::Value>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CreatePaymentMethodType>, /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. @@ -366,11 +147,7 @@ pub struct CreatePaymentMethodAcssDebit<'a> { pub transit_number: &'a str, } impl<'a> CreatePaymentMethodAcssDebit<'a> { - pub fn new( - account_number: &'a str, - institution_number: &'a str, - transit_number: &'a str, - ) -> Self { + pub fn new(account_number: &'a str, institution_number: &'a str, transit_number: &'a str) -> Self { Self { account_number, institution_number, transit_number } } } @@ -792,7 +569,6 @@ pub enum CreatePaymentMethodIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -815,7 +591,6 @@ impl CreatePaymentMethodIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -841,7 +616,6 @@ impl std::str::FromStr for CreatePaymentMethodIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -939,7 +713,6 @@ pub enum CreatePaymentMethodP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -972,7 +745,6 @@ impl CreatePaymentMethodP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -1008,7 +780,6 @@ impl std::str::FromStr for CreatePaymentMethodP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -1161,7 +932,6 @@ pub enum CreatePaymentMethodType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -1201,7 +971,6 @@ impl CreatePaymentMethodType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -1244,7 +1013,6 @@ impl std::str::FromStr for CreatePaymentMethodType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -1397,6 +1165,24 @@ impl<'a> CreatePaymentMethod<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrievePaymentMethod<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrievePaymentMethod<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrievePaymentMethod<'a> { + /// Retrieves a PaymentMethod object attached to the StripeAccount. + /// To retrieve a payment method attached to a Customer, you should use [Retrieve a Customer’s PaymentMethods](https://stripe.com/docs/api/payment_methods/customer). + pub fn send(&self, client: &stripe::Client, payment_method: &stripe_shared::PaymentMethodId) -> stripe::Response<stripe_shared::PaymentMethod> { + client.get_query(&format!("/payment_methods/{payment_method}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentMethod<'a> { /// Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods. #[serde(skip_serializing_if = "Option::is_none")] @@ -1443,19 +1229,16 @@ impl UpdatePaymentMethodCard { /// If this is an `us_bank_account` PaymentMethod, this hash contains details about the US bank account payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentMethodUsBankAccount { - /// Bank account holder type. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: Option<UpdatePaymentMethodUsBankAccountAccountHolderType>, /// Bank account type. #[serde(skip_serializing_if = "Option::is_none")] - pub account_type: Option<UpdatePaymentMethodUsBankAccountAccountType>, + pub account_holder_type: Option<UpdatePaymentMethodUsBankAccountAccountHolderType>, } impl UpdatePaymentMethodUsBankAccount { pub fn new() -> Self { Self::default() } } -/// Bank account holder type. +/// Bank account type. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentMethodUsBankAccountAccountHolderType { Company, @@ -1501,45 +1284,181 @@ impl serde::Serialize for UpdatePaymentMethodUsBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } -/// Bank account type. +impl<'a> UpdatePaymentMethod<'a> { + /// Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated. + pub fn send(&self, client: &stripe::Client, payment_method: &stripe_shared::PaymentMethodId) -> stripe::Response<stripe_shared::PaymentMethod> { + client.send_form(&format!("/payment_methods/{payment_method}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListPaymentMethod<'a> { + /// The ID of the customer whose PaymentMethods will be retrieved. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// An optional filter on the list, based on the object `type` field. + /// Without the filter, the list includes all current and future payment method types. + /// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + #[serde(skip_serializing_if = "Option::is_none")] + pub type_: Option<ListPaymentMethodType>, +} +impl<'a> ListPaymentMethod<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// An optional filter on the list, based on the object `type` field. +/// Without the filter, the list includes all current and future payment method types. +/// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodUsBankAccountAccountType { - Checking, - Savings, +#[non_exhaustive] +pub enum ListPaymentMethodType { + AcssDebit, + Affirm, + AfterpayClearpay, + Alipay, + AuBecsDebit, + BacsDebit, + Bancontact, + Blik, + Boleto, + Card, + Cashapp, + CustomerBalance, + Eps, + Fpx, + Giropay, + Grabpay, + Ideal, + Klarna, + Konbini, + Link, + Oxxo, + P24, + Paynow, + Paypal, + Pix, + Promptpay, + RevolutPay, + SepaDebit, + Sofort, + UsBankAccount, + WechatPay, + Zip, + /// An unrecognized value from Stripe. Should not be used as a request parameter. + Unknown, } -impl UpdatePaymentMethodUsBankAccountAccountType { +impl ListPaymentMethodType { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodUsBankAccountAccountType::*; + use ListPaymentMethodType::*; match self { - Checking => "checking", - Savings => "savings", + AcssDebit => "acss_debit", + Affirm => "affirm", + AfterpayClearpay => "afterpay_clearpay", + Alipay => "alipay", + AuBecsDebit => "au_becs_debit", + BacsDebit => "bacs_debit", + Bancontact => "bancontact", + Blik => "blik", + Boleto => "boleto", + Card => "card", + Cashapp => "cashapp", + CustomerBalance => "customer_balance", + Eps => "eps", + Fpx => "fpx", + Giropay => "giropay", + Grabpay => "grabpay", + Ideal => "ideal", + Klarna => "klarna", + Konbini => "konbini", + Link => "link", + Oxxo => "oxxo", + P24 => "p24", + Paynow => "paynow", + Paypal => "paypal", + Pix => "pix", + Promptpay => "promptpay", + RevolutPay => "revolut_pay", + SepaDebit => "sepa_debit", + Sofort => "sofort", + UsBankAccount => "us_bank_account", + WechatPay => "wechat_pay", + Zip => "zip", + Unknown => "unknown", } } } -impl std::str::FromStr for UpdatePaymentMethodUsBankAccountAccountType { +impl std::str::FromStr for ListPaymentMethodType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodUsBankAccountAccountType::*; + use ListPaymentMethodType::*; match s { - "checking" => Ok(Checking), - "savings" => Ok(Savings), + "acss_debit" => Ok(AcssDebit), + "affirm" => Ok(Affirm), + "afterpay_clearpay" => Ok(AfterpayClearpay), + "alipay" => Ok(Alipay), + "au_becs_debit" => Ok(AuBecsDebit), + "bacs_debit" => Ok(BacsDebit), + "bancontact" => Ok(Bancontact), + "blik" => Ok(Blik), + "boleto" => Ok(Boleto), + "card" => Ok(Card), + "cashapp" => Ok(Cashapp), + "customer_balance" => Ok(CustomerBalance), + "eps" => Ok(Eps), + "fpx" => Ok(Fpx), + "giropay" => Ok(Giropay), + "grabpay" => Ok(Grabpay), + "ideal" => Ok(Ideal), + "klarna" => Ok(Klarna), + "konbini" => Ok(Konbini), + "link" => Ok(Link), + "oxxo" => Ok(Oxxo), + "p24" => Ok(P24), + "paynow" => Ok(Paynow), + "paypal" => Ok(Paypal), + "pix" => Ok(Pix), + "promptpay" => Ok(Promptpay), + "revolut_pay" => Ok(RevolutPay), + "sepa_debit" => Ok(SepaDebit), + "sofort" => Ok(Sofort), + "us_bank_account" => Ok(UsBankAccount), + "wechat_pay" => Ok(WechatPay), + "zip" => Ok(Zip), _ => Err(()), } } } -impl std::fmt::Display for UpdatePaymentMethodUsBankAccountAccountType { +impl std::fmt::Display for ListPaymentMethodType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodUsBankAccountAccountType { +impl std::fmt::Debug for ListPaymentMethodType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodUsBankAccountAccountType { +impl serde::Serialize for ListPaymentMethodType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1547,18 +1466,14 @@ impl serde::Serialize for UpdatePaymentMethodUsBankAccountAccountType { serializer.serialize_str(self.as_str()) } } -impl<'a> UpdatePaymentMethod<'a> { - /// Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated. - pub fn send( - &self, - client: &stripe::Client, - payment_method: &stripe_shared::PaymentMethodId, - ) -> stripe::Response<stripe_shared::PaymentMethod> { - client.send_form( - &format!("/payment_methods/{payment_method}"), - self, - http_types::Method::Post, - ) +impl<'a> ListPaymentMethod<'a> { + /// Returns a list of PaymentMethods for Treasury flows. + /// If you want to list the PaymentMethods attached to a Customer for payments, you should use the [List a Customer’s PaymentMethods](https://stripe.com/docs/api/payment_methods/customer_list) API instead. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::PaymentMethod>> { + client.get_query("/payment_methods", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PaymentMethod>> { + stripe::ListPaginator::from_list_params("/payment_methods", self) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -1589,16 +1504,8 @@ impl<'a> AttachPaymentMethod<'a> { /// To use this PaymentMethod as the default for invoice or subscription payments, /// set <a href="/docs/api/customers/update#update_customer-invoice_settings-default_payment_method">`invoice_settings.default_payment_method`</a>,. /// on the Customer to the PaymentMethod’s ID. - pub fn send( - &self, - client: &stripe::Client, - payment_method: &stripe_shared::PaymentMethodId, - ) -> stripe::Response<stripe_shared::PaymentMethod> { - client.send_form( - &format!("/payment_methods/{payment_method}/attach"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, payment_method: &stripe_shared::PaymentMethodId) -> stripe::Response<stripe_shared::PaymentMethod> { + client.send_form(&format!("/payment_methods/{payment_method}/attach"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -1615,16 +1522,8 @@ impl<'a> DetachPaymentMethod<'a> { impl<'a> DetachPaymentMethod<'a> { /// Detaches a PaymentMethod object from a Customer. /// After a PaymentMethod is detached, it can no longer be used for a payment or re-attached to a Customer. - pub fn send( - &self, - client: &stripe::Client, - payment_method: &stripe_shared::PaymentMethodId, - ) -> stripe::Response<stripe_shared::PaymentMethod> { - client.send_form( - &format!("/payment_methods/{payment_method}/detach"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, payment_method: &stripe_shared::PaymentMethodId) -> stripe::Response<stripe_shared::PaymentMethod> { + client.send_form(&format!("/payment_methods/{payment_method}/detach"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_payment/src/payment_method_config_resource_display_preference.rs b/generated/stripe_payment/src/payment_method_config_resource_display_preference.rs index 53b6167f9..fe55ff4a9 100644 --- a/generated/stripe_payment/src/payment_method_config_resource_display_preference.rs +++ b/generated/stripe_payment/src/payment_method_config_resource_display_preference.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodConfigResourceDisplayPreference { /// For child configs, whether or not the account's preference will be observed. /// If `false`, the parent configuration's default is used. @@ -8,6 +10,100 @@ pub struct PaymentMethodConfigResourceDisplayPreference { /// The effective display preference value. pub value: PaymentMethodConfigResourceDisplayPreferenceValue, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodConfigResourceDisplayPreferenceBuilder { + overridable: Option<Option<bool>>, + preference: Option<PaymentMethodConfigResourceDisplayPreferencePreference>, + value: Option<PaymentMethodConfigResourceDisplayPreferenceValue>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodConfigResourceDisplayPreference { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodConfigResourceDisplayPreference>, + builder: PaymentMethodConfigResourceDisplayPreferenceBuilder, + } + + impl Visitor for Place<PaymentMethodConfigResourceDisplayPreference> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodConfigResourceDisplayPreferenceBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodConfigResourceDisplayPreferenceBuilder { + type Out = PaymentMethodConfigResourceDisplayPreference; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "overridable" => Deserialize::begin(&mut self.overridable), + "preference" => Deserialize::begin(&mut self.preference), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { overridable: Deserialize::default(), preference: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let overridable = self.overridable.take()?; + let preference = self.preference.take()?; + let value = self.value.take()?; + + Some(Self::Out { overridable, preference, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodConfigResourceDisplayPreference { + type Builder = PaymentMethodConfigResourceDisplayPreferenceBuilder; + } + + impl FromValueOpt for PaymentMethodConfigResourceDisplayPreference { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodConfigResourceDisplayPreferenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "overridable" => b.overridable = Some(FromValueOpt::from_value(v)?), + "preference" => b.preference = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The account's display preference. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodConfigResourceDisplayPreferencePreference { @@ -61,13 +157,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodConfigResourceDisplayPreferen fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodConfigResourceDisplayPreferencePreference", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodConfigResourceDisplayPreferencePreference")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodConfigResourceDisplayPreferencePreference { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodConfigResourceDisplayPreferencePreference> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodConfigResourceDisplayPreferencePreference::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodConfigResourceDisplayPreferencePreference); /// The effective display preference value. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodConfigResourceDisplayPreferenceValue { @@ -118,10 +228,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodConfigResourceDisplayPreferen fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodConfigResourceDisplayPreferenceValue", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodConfigResourceDisplayPreferenceValue")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodConfigResourceDisplayPreferenceValue { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodConfigResourceDisplayPreferenceValue> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodConfigResourceDisplayPreferenceValue::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodConfigResourceDisplayPreferenceValue); diff --git a/generated/stripe_payment/src/payment_method_config_resource_payment_method_properties.rs b/generated/stripe_payment/src/payment_method_config_resource_payment_method_properties.rs index ef32708bc..cf243e8e0 100644 --- a/generated/stripe_payment/src/payment_method_config_resource_payment_method_properties.rs +++ b/generated/stripe_payment/src/payment_method_config_resource_payment_method_properties.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodConfigResourcePaymentMethodProperties { /// Whether this payment method may be offered at checkout. /// True if `display_preference` is `on` and the payment method's capability is active. pub available: bool, pub display_preference: stripe_payment::PaymentMethodConfigResourceDisplayPreference, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodConfigResourcePaymentMethodPropertiesBuilder { + available: Option<bool>, + display_preference: Option<stripe_payment::PaymentMethodConfigResourceDisplayPreference>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodConfigResourcePaymentMethodProperties { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodConfigResourcePaymentMethodProperties>, + builder: PaymentMethodConfigResourcePaymentMethodPropertiesBuilder, + } + + impl Visitor for Place<PaymentMethodConfigResourcePaymentMethodProperties> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodConfigResourcePaymentMethodPropertiesBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodConfigResourcePaymentMethodPropertiesBuilder { + type Out = PaymentMethodConfigResourcePaymentMethodProperties; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available" => Deserialize::begin(&mut self.available), + "display_preference" => Deserialize::begin(&mut self.display_preference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default(), display_preference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available = self.available.take()?; + let display_preference = self.display_preference.take()?; + + Some(Self::Out { available, display_preference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodConfigResourcePaymentMethodProperties { + type Builder = PaymentMethodConfigResourcePaymentMethodPropertiesBuilder; + } + + impl FromValueOpt for PaymentMethodConfigResourcePaymentMethodProperties { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodConfigResourcePaymentMethodPropertiesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available" => b.available = Some(FromValueOpt::from_value(v)?), + "display_preference" => b.display_preference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_payment/src/payment_method_configuration/requests.rs b/generated/stripe_payment/src/payment_method_configuration/requests.rs index 363c4bb5b..7ae871bd2 100644 --- a/generated/stripe_payment/src/payment_method_configuration/requests.rs +++ b/generated/stripe_payment/src/payment_method_configuration/requests.rs @@ -14,15 +14,10 @@ impl<'a> ListPaymentMethodConfiguration<'a> { } impl<'a> ListPaymentMethodConfiguration<'a> { /// List payment method configurations - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_payment::PaymentMethodConfiguration>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_payment::PaymentMethodConfiguration>> { client.get_query("/payment_method_configurations", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_payment::PaymentMethodConfiguration>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_payment::PaymentMethodConfiguration>> { stripe::ListPaginator::from_list_params("/payment_method_configurations", self) } } @@ -39,86 +34,80 @@ impl<'a> RetrievePaymentMethodConfiguration<'a> { } impl<'a> RetrievePaymentMethodConfiguration<'a> { /// Retrieve payment method configuration - pub fn send( - &self, - client: &stripe::Client, - configuration: &stripe_payment::PaymentMethodConfigurationId, - ) -> stripe::Response<stripe_payment::PaymentMethodConfiguration> { + pub fn send(&self, client: &stripe::Client, configuration: &stripe_payment::PaymentMethodConfigurationId) -> stripe::Response<stripe_payment::PaymentMethodConfiguration> { client.get_query(&format!("/payment_method_configurations/{configuration}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfiguration<'a> { +pub struct UpdatePaymentMethodConfiguration<'a> { /// Canadian pre-authorized debit payments, check this [page](https://stripe.com/docs/payments/acss-debit) for more details like country availability. #[serde(skip_serializing_if = "Option::is_none")] - pub acss_debit: Option<CreatePaymentMethodConfigurationAcssDebit>, + pub acss_debit: Option<UpdatePaymentMethodConfigurationAcssDebit>, + /// Whether the configuration can be used for new payments. + #[serde(skip_serializing_if = "Option::is_none")] + pub active: Option<bool>, /// [Affirm](https://www.affirm.com/) gives your customers a way to split purchases over a series of payments. /// Depending on the purchase, they can pay with four interest-free payments (Split Pay) or pay over a longer term (Installments), which might include interest. /// Check this [page](https://stripe.com/docs/payments/affirm) for more details like country availability. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<CreatePaymentMethodConfigurationAffirm>, + pub affirm: Option<UpdatePaymentMethodConfigurationAffirm>, /// Afterpay gives your customers a way to pay for purchases in installments, check this [page](https://stripe.com/docs/payments/afterpay-clearpay) for more details like country availability. /// Afterpay is particularly popular among businesses selling fashion, beauty, and sports products. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<CreatePaymentMethodConfigurationAfterpayClearpay>, + pub afterpay_clearpay: Option<UpdatePaymentMethodConfigurationAfterpayClearpay>, /// Alipay is a digital wallet in China that has more than a billion active users worldwide. /// Alipay users can pay on the web or on a mobile device using login credentials or their Alipay app. /// Alipay has a low dispute rate and reduces fraud by authenticating payments using the customer's login credentials. /// Check this [page](https://stripe.com/docs/payments/alipay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<CreatePaymentMethodConfigurationAlipay>, + pub alipay: Option<UpdatePaymentMethodConfigurationAlipay>, /// Stripe users can accept [Apple Pay](/payments/apple-pay) in iOS applications in iOS 9 and later, and on the web in Safari starting with iOS 10 or macOS Sierra. /// There are no additional fees to process Apple Pay payments, and the [pricing](/pricing) is the same as other card transactions. /// Check this [page](https://stripe.com/docs/apple-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub apple_pay: Option<CreatePaymentMethodConfigurationApplePay>, + pub apple_pay: Option<UpdatePaymentMethodConfigurationApplePay>, /// Apple Pay Later, a payment method for customers to buy now and pay later, gives your customers a way to split purchases into four installments across six weeks. #[serde(skip_serializing_if = "Option::is_none")] - pub apple_pay_later: Option<CreatePaymentMethodConfigurationApplePayLater>, + pub apple_pay_later: Option<UpdatePaymentMethodConfigurationApplePayLater>, /// Stripe users in Australia can accept Bulk Electronic Clearing System (BECS) direct debit payments from customers with an Australian bank account. /// Check this [page](https://stripe.com/docs/payments/au-becs-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub au_becs_debit: Option<CreatePaymentMethodConfigurationAuBecsDebit>, + pub au_becs_debit: Option<UpdatePaymentMethodConfigurationAuBecsDebit>, /// Stripe users in the UK can accept Bacs Direct Debit payments from customers with a UK bank account, check this [page](https://stripe.com/docs/payments/payment-methods/bacs-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub bacs_debit: Option<CreatePaymentMethodConfigurationBacsDebit>, + pub bacs_debit: Option<UpdatePaymentMethodConfigurationBacsDebit>, /// Bancontact is the most popular online payment method in Belgium, with over 15 million cards in circulation. /// [Customers](https://stripe.com/docs/api/customers) use a Bancontact card or mobile app linked to a Belgian bank account to make online payments that are secure, guaranteed, and confirmed immediately. /// Check this [page](https://stripe.com/docs/payments/bancontact) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<CreatePaymentMethodConfigurationBancontact>, + pub bancontact: Option<UpdatePaymentMethodConfigurationBancontact>, /// BLIK is a [single use](https://stripe.com/docs/payments/payment-methods#usage) payment method that requires customers to authenticate their payments. /// When customers want to pay online using BLIK, they request a six-digit code from their banking application and enter it into the payment collection form. /// Check this [page](https://stripe.com/docs/payments/blik) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<CreatePaymentMethodConfigurationBlik>, + pub blik: Option<UpdatePaymentMethodConfigurationBlik>, /// Boleto is an official (regulated by the Central Bank of Brazil) payment method in Brazil. /// Check this [page](https://stripe.com/docs/payments/boleto) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub boleto: Option<CreatePaymentMethodConfigurationBoleto>, + pub boleto: Option<UpdatePaymentMethodConfigurationBoleto>, /// Cards are a popular way for consumers and businesses to pay online or in person. /// Stripe supports global and local card networks. #[serde(skip_serializing_if = "Option::is_none")] - pub card: Option<CreatePaymentMethodConfigurationCard>, + pub card: Option<UpdatePaymentMethodConfigurationCard>, /// Cartes Bancaires is France's local card network. /// More than 95% of these cards are co-branded with either Visa or Mastercard, meaning you can process these cards over either Cartes Bancaires or the Visa or Mastercard networks. /// Check this [page](https://stripe.com/docs/payments/cartes-bancaires) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option<CreatePaymentMethodConfigurationCartesBancaires>, + pub cartes_bancaires: Option<UpdatePaymentMethodConfigurationCartesBancaires>, /// Cash App is a popular consumer app in the US that allows customers to bank, invest, send, and receive money using their digital wallet. /// Check this [page](https://stripe.com/docs/payments/cash-app-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<CreatePaymentMethodConfigurationCashapp>, - /// Uses a customer’s [cash balance](https://stripe.com/docs/payments/customer-balance) for the payment. - /// The cash balance can be funded via a bank transfer. - /// Check this [page](https://stripe.com/docs/payments/bank-transfers) for more details. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<CreatePaymentMethodConfigurationCustomerBalance>, + pub cashapp: Option<UpdatePaymentMethodConfigurationCashapp>, /// EPS is an Austria-based payment method that allows customers to complete transactions online using their bank credentials. /// EPS is supported by all Austrian banks and is accepted by over 80% of Austrian online retailers. /// Check this [page](https://stripe.com/docs/payments/eps) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub eps: Option<CreatePaymentMethodConfigurationEps>, + pub eps: Option<UpdatePaymentMethodConfigurationEps>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -127,48 +116,48 @@ pub struct CreatePaymentMethodConfiguration<'a> { /// It is one of the most popular online payment methods in Malaysia, with nearly 90 million transactions in 2018 according to BNM. /// Check this [page](https://stripe.com/docs/payments/fpx) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub fpx: Option<CreatePaymentMethodConfigurationFpx>, + pub fpx: Option<UpdatePaymentMethodConfigurationFpx>, /// giropay is a German payment method based on online banking, introduced in 2006. /// It allows customers to complete transactions online using their online banking environment, with funds debited from their bank account. /// Depending on their bank, customers confirm payments on giropay using a second factor of authentication or a PIN. /// giropay accounts for 10% of online checkouts in Germany. /// Check this [page](https://stripe.com/docs/payments/giropay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<CreatePaymentMethodConfigurationGiropay>, + pub giropay: Option<UpdatePaymentMethodConfigurationGiropay>, /// Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. /// Use the Google Pay API to request any credit or debit card stored in your customer's Google account. /// Check this [page](https://stripe.com/docs/google-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub google_pay: Option<CreatePaymentMethodConfigurationGooglePay>, + pub google_pay: Option<UpdatePaymentMethodConfigurationGooglePay>, /// GrabPay is a payment method developed by [Grab](https://www.grab.com/sg/consumer/finance/pay/). /// GrabPay is a digital wallet - customers maintain a balance in their wallets that they pay out with. /// Check this [page](https://stripe.com/docs/payments/grabpay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<CreatePaymentMethodConfigurationGrabpay>, + pub grabpay: Option<UpdatePaymentMethodConfigurationGrabpay>, /// iDEAL is a Netherlands-based payment method that allows customers to complete transactions online using their bank credentials. /// All major Dutch banks are members of Currence, the scheme that operates iDEAL, making it the most popular online payment method in the Netherlands with a share of online transactions close to 55%. /// Check this [page](https://stripe.com/docs/payments/ideal) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub ideal: Option<CreatePaymentMethodConfigurationIdeal>, + pub ideal: Option<UpdatePaymentMethodConfigurationIdeal>, /// JCB is a credit card company based in Japan. /// JCB is currently available in Japan to businesses approved by JCB, and available to all businesses in Australia, Canada, Hong Kong, Japan, New Zealand, Singapore, Switzerland, United Kingdom, United States, and all countries in the European Economic Area except Iceland. /// Check this [page](https://support.stripe.com/questions/accepting-japan-credit-bureau-%28jcb%29-payments) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub jcb: Option<CreatePaymentMethodConfigurationJcb>, + pub jcb: Option<UpdatePaymentMethodConfigurationJcb>, /// Klarna gives customers a range of [payment options](https://stripe.com/docs/payments/klarna#payment-options) during checkout. /// Available payment options vary depending on the customer's billing address and the transaction amount. /// These payment options make it convenient for customers to purchase items in all price ranges. /// Check this [page](https://stripe.com/docs/payments/klarna) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub klarna: Option<CreatePaymentMethodConfigurationKlarna>, + pub klarna: Option<UpdatePaymentMethodConfigurationKlarna>, /// Konbini allows customers in Japan to pay for bills and online purchases at convenience stores with cash. /// Check this [page](https://stripe.com/docs/payments/konbini) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<CreatePaymentMethodConfigurationKonbini>, + pub konbini: Option<UpdatePaymentMethodConfigurationKonbini>, /// [Link](https://stripe.com/docs/payments/link) is a payment method network. /// With Link, users save their payment details once, then reuse that information to pay with one click for any business on the network. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<CreatePaymentMethodConfigurationLink>, + pub link: Option<UpdatePaymentMethodConfigurationLink>, /// Configuration name. #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<&'a str>, @@ -176,89 +165,82 @@ pub struct CreatePaymentMethodConfiguration<'a> { /// OXXO allows customers to pay bills and online purchases in-store with cash. /// Check this [page](https://stripe.com/docs/payments/oxxo) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<CreatePaymentMethodConfigurationOxxo>, + pub oxxo: Option<UpdatePaymentMethodConfigurationOxxo>, /// Przelewy24 is a Poland-based payment method aggregator that allows customers to complete transactions online using bank transfers and other methods. /// Bank transfers account for 30% of online payments in Poland and Przelewy24 provides a way for customers to pay with over 165 banks. /// Check this [page](https://stripe.com/docs/payments/p24) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub p24: Option<CreatePaymentMethodConfigurationP24>, - /// Configuration's parent configuration. Specify to create a child configuration. - #[serde(skip_serializing_if = "Option::is_none")] - pub parent: Option<&'a str>, + pub p24: Option<UpdatePaymentMethodConfigurationP24>, /// PayNow is a Singapore-based payment method that allows customers to make a payment using their preferred app from participating banks and participating non-bank financial institutions. /// Check this [page](https://stripe.com/docs/payments/paynow) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<CreatePaymentMethodConfigurationPaynow>, + pub paynow: Option<UpdatePaymentMethodConfigurationPaynow>, /// PayPal, a digital wallet popular with customers in Europe, allows your customers worldwide to pay using their PayPal account. /// Check this [page](https://stripe.com/docs/payments/paypal) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<CreatePaymentMethodConfigurationPaypal>, + pub paypal: Option<UpdatePaymentMethodConfigurationPaypal>, /// PromptPay is a Thailand-based payment method that allows customers to make a payment using their preferred app from participating banks. /// Check this [page](https://stripe.com/docs/payments/promptpay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<CreatePaymentMethodConfigurationPromptpay>, - /// Revolut Pay, developed by Revolut, a global finance app, is a digital wallet payment method. - /// Revolut Pay uses the customer’s stored balance or cards to fund the payment, and offers the option for non-Revolut customers to save their details after their first purchase. - #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<CreatePaymentMethodConfigurationRevolutPay>, + pub promptpay: Option<UpdatePaymentMethodConfigurationPromptpay>, /// The [Single Euro Payments Area (SEPA)](https://en.wikipedia.org/wiki/Single_Euro_Payments_Area) is an initiative of the European Union to simplify payments within and across member countries. /// SEPA established and enforced banking standards to allow for the direct debiting of every EUR-denominated bank account within the SEPA region, check this [page](https://stripe.com/docs/payments/sepa-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option<CreatePaymentMethodConfigurationSepaDebit>, + pub sepa_debit: Option<UpdatePaymentMethodConfigurationSepaDebit>, /// Stripe users in Europe and the United States can use the [Payment Intents API](https://stripe.com/docs/payments/payment-intents)—a single integration path for creating payments using any supported method—to accept [Sofort](https://www.sofort.com/) payments from customers. /// Check this [page](https://stripe.com/docs/payments/sofort) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub sofort: Option<CreatePaymentMethodConfigurationSofort>, + pub sofort: Option<UpdatePaymentMethodConfigurationSofort>, /// Stripe users in the United States can accept ACH direct debit payments from customers with a US bank account using the Automated Clearing House (ACH) payments system operated by Nacha. /// Check this [page](https://stripe.com/docs/payments/ach-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: Option<CreatePaymentMethodConfigurationUsBankAccount>, + pub us_bank_account: Option<UpdatePaymentMethodConfigurationUsBankAccount>, /// WeChat, owned by Tencent, is China's leading mobile app with over 1 billion monthly active users. /// Chinese consumers can use WeChat Pay to pay for goods and services inside of businesses' apps and websites. /// WeChat Pay users buy most frequently in gaming, e-commerce, travel, online education, and food/nutrition. /// Check this [page](https://stripe.com/docs/payments/wechat-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<CreatePaymentMethodConfigurationWechatPay>, + pub wechat_pay: Option<UpdatePaymentMethodConfigurationWechatPay>, } -impl<'a> CreatePaymentMethodConfiguration<'a> { +impl<'a> UpdatePaymentMethodConfiguration<'a> { pub fn new() -> Self { Self::default() } } /// Canadian pre-authorized debit payments, check this [page](https://stripe.com/docs/payments/acss-debit) for more details like country availability. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAcssDebit { +pub struct UpdatePaymentMethodConfigurationAcssDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationAcssDebitDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationAcssDebitDisplayPreference>, } -impl CreatePaymentMethodConfigurationAcssDebit { +impl UpdatePaymentMethodConfigurationAcssDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAcssDebitDisplayPreference { +pub struct UpdatePaymentMethodConfigurationAcssDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationAcssDebitDisplayPreference { +impl UpdatePaymentMethodConfigurationAcssDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -267,10 +249,10 @@ impl CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -279,18 +261,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationAcssDebitDisplayPrefe } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -302,38 +284,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAcssDebitDisplayPrefer /// Depending on the purchase, they can pay with four interest-free payments (Split Pay) or pay over a longer term (Installments), which might include interest. /// Check this [page](https://stripe.com/docs/payments/affirm) for more details like country availability. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAffirm { +pub struct UpdatePaymentMethodConfigurationAffirm { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationAffirmDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationAffirmDisplayPreference>, } -impl CreatePaymentMethodConfigurationAffirm { +impl UpdatePaymentMethodConfigurationAffirm { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAffirmDisplayPreference { +pub struct UpdatePaymentMethodConfigurationAffirmDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationAffirmDisplayPreference { +impl UpdatePaymentMethodConfigurationAffirmDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -342,10 +324,10 @@ impl CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -354,18 +336,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationAffirmDisplayPreferen } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -376,40 +358,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAffirmDisplayPreferenc /// Afterpay gives your customers a way to pay for purchases in installments, check this [page](https://stripe.com/docs/payments/afterpay-clearpay) for more details like country availability. /// Afterpay is particularly popular among businesses selling fashion, beauty, and sports products. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAfterpayClearpay { +pub struct UpdatePaymentMethodConfigurationAfterpayClearpay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: - Option<CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreference>, } -impl CreatePaymentMethodConfigurationAfterpayClearpay { +impl UpdatePaymentMethodConfigurationAfterpayClearpay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { +impl UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -418,12 +398,10 @@ impl CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference } } -impl std::str::FromStr - for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl std::str::FromStr for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -432,24 +410,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl std::fmt::Display for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl std::fmt::Debug for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl serde::Serialize for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -462,38 +434,38 @@ impl serde::Serialize /// Alipay has a low dispute rate and reduces fraud by authenticating payments using the customer's login credentials. /// Check this [page](https://stripe.com/docs/payments/alipay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAlipay { +pub struct UpdatePaymentMethodConfigurationAlipay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationAlipayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationAlipayDisplayPreference>, } -impl CreatePaymentMethodConfigurationAlipay { +impl UpdatePaymentMethodConfigurationAlipay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAlipayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationAlipayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationAlipayDisplayPreference { +impl UpdatePaymentMethodConfigurationAlipayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -502,10 +474,10 @@ impl CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -514,18 +486,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationAlipayDisplayPreferen } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -537,38 +509,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAlipayDisplayPreferenc /// There are no additional fees to process Apple Pay payments, and the [pricing](/pricing) is the same as other card transactions. /// Check this [page](https://stripe.com/docs/apple-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationApplePay { +pub struct UpdatePaymentMethodConfigurationApplePay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationApplePayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationApplePayDisplayPreference>, } -impl CreatePaymentMethodConfigurationApplePay { +impl UpdatePaymentMethodConfigurationApplePay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationApplePayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationApplePayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationApplePayDisplayPreference { +impl UpdatePaymentMethodConfigurationApplePayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -577,10 +549,10 @@ impl CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -589,18 +561,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationApplePayDisplayPrefer } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -610,39 +582,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationApplePayDisplayPrefere } /// Apple Pay Later, a payment method for customers to buy now and pay later, gives your customers a way to split purchases into four installments across six weeks. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationApplePayLater { +pub struct UpdatePaymentMethodConfigurationApplePayLater { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationApplePayLaterDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationApplePayLaterDisplayPreference>, } -impl CreatePaymentMethodConfigurationApplePayLater { +impl UpdatePaymentMethodConfigurationApplePayLater { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationApplePayLaterDisplayPreference { +pub struct UpdatePaymentMethodConfigurationApplePayLaterDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationApplePayLaterDisplayPreference { +impl UpdatePaymentMethodConfigurationApplePayLaterDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -651,12 +622,10 @@ impl CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { } } -impl std::str::FromStr - for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference -{ +impl std::str::FromStr for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -665,20 +634,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference -{ +impl std::fmt::Display for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -689,38 +656,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationApplePayLaterDisplayPr /// Stripe users in Australia can accept Bulk Electronic Clearing System (BECS) direct debit payments from customers with an Australian bank account. /// Check this [page](https://stripe.com/docs/payments/au-becs-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAuBecsDebit { +pub struct UpdatePaymentMethodConfigurationAuBecsDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationAuBecsDebitDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreference>, } -impl CreatePaymentMethodConfigurationAuBecsDebit { +impl UpdatePaymentMethodConfigurationAuBecsDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationAuBecsDebitDisplayPreference { +pub struct UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationAuBecsDebitDisplayPreference { +impl UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -729,10 +696,10 @@ impl CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -741,18 +708,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationAuBecsDebitDisplayPre } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -762,38 +729,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAuBecsDebitDisplayPref } /// Stripe users in the UK can accept Bacs Direct Debit payments from customers with a UK bank account, check this [page](https://stripe.com/docs/payments/payment-methods/bacs-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBacsDebit { +pub struct UpdatePaymentMethodConfigurationBacsDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationBacsDebitDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationBacsDebitDisplayPreference>, } -impl CreatePaymentMethodConfigurationBacsDebit { +impl UpdatePaymentMethodConfigurationBacsDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBacsDebitDisplayPreference { +pub struct UpdatePaymentMethodConfigurationBacsDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationBacsDebitDisplayPreference { +impl UpdatePaymentMethodConfigurationBacsDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -802,10 +769,10 @@ impl CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -814,18 +781,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationBacsDebitDisplayPrefe } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -837,38 +804,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBacsDebitDisplayPrefer /// [Customers](https://stripe.com/docs/api/customers) use a Bancontact card or mobile app linked to a Belgian bank account to make online payments that are secure, guaranteed, and confirmed immediately. /// Check this [page](https://stripe.com/docs/payments/bancontact) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBancontact { +pub struct UpdatePaymentMethodConfigurationBancontact { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationBancontactDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationBancontactDisplayPreference>, } -impl CreatePaymentMethodConfigurationBancontact { +impl UpdatePaymentMethodConfigurationBancontact { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBancontactDisplayPreference { +pub struct UpdatePaymentMethodConfigurationBancontactDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationBancontactDisplayPreference { +impl UpdatePaymentMethodConfigurationBancontactDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -877,10 +844,10 @@ impl CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -889,18 +856,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationBancontactDisplayPref } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -912,38 +879,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBancontactDisplayPrefe /// When customers want to pay online using BLIK, they request a six-digit code from their banking application and enter it into the payment collection form. /// Check this [page](https://stripe.com/docs/payments/blik) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBlik { +pub struct UpdatePaymentMethodConfigurationBlik { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationBlikDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationBlikDisplayPreference>, } -impl CreatePaymentMethodConfigurationBlik { +impl UpdatePaymentMethodConfigurationBlik { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBlikDisplayPreference { +pub struct UpdatePaymentMethodConfigurationBlikDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationBlikDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationBlikDisplayPreference { +impl UpdatePaymentMethodConfigurationBlikDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -952,10 +919,10 @@ impl CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -964,18 +931,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationBlikDisplayPreference } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -986,38 +953,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBlikDisplayPreferenceP /// Boleto is an official (regulated by the Central Bank of Brazil) payment method in Brazil. /// Check this [page](https://stripe.com/docs/payments/boleto) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBoleto { +pub struct UpdatePaymentMethodConfigurationBoleto { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationBoletoDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationBoletoDisplayPreference>, } -impl CreatePaymentMethodConfigurationBoleto { +impl UpdatePaymentMethodConfigurationBoleto { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationBoletoDisplayPreference { +pub struct UpdatePaymentMethodConfigurationBoletoDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationBoletoDisplayPreference { +impl UpdatePaymentMethodConfigurationBoletoDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1026,10 +993,10 @@ impl CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1038,18 +1005,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationBoletoDisplayPreferen } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1060,38 +1027,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBoletoDisplayPreferenc /// Cards are a popular way for consumers and businesses to pay online or in person. /// Stripe supports global and local card networks. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCard { +pub struct UpdatePaymentMethodConfigurationCard { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationCardDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationCardDisplayPreference>, } -impl CreatePaymentMethodConfigurationCard { +impl UpdatePaymentMethodConfigurationCard { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCardDisplayPreference { +pub struct UpdatePaymentMethodConfigurationCardDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationCardDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationCardDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationCardDisplayPreference { +impl UpdatePaymentMethodConfigurationCardDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationCardDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationCardDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationCardDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1100,10 +1067,10 @@ impl CreatePaymentMethodConfigurationCardDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationCardDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationCardDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1112,18 +1079,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationCardDisplayPreference } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1135,40 +1102,38 @@ impl serde::Serialize for CreatePaymentMethodConfigurationCardDisplayPreferenceP /// More than 95% of these cards are co-branded with either Visa or Mastercard, meaning you can process these cards over either Cartes Bancaires or the Visa or Mastercard networks. /// Check this [page](https://stripe.com/docs/payments/cartes-bancaires) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCartesBancaires { +pub struct UpdatePaymentMethodConfigurationCartesBancaires { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: - Option<CreatePaymentMethodConfigurationCartesBancairesDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationCartesBancairesDisplayPreference>, } -impl CreatePaymentMethodConfigurationCartesBancaires { +impl UpdatePaymentMethodConfigurationCartesBancaires { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCartesBancairesDisplayPreference { +pub struct UpdatePaymentMethodConfigurationCartesBancairesDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationCartesBancairesDisplayPreference { +impl UpdatePaymentMethodConfigurationCartesBancairesDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1177,12 +1142,10 @@ impl CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference } } -impl std::str::FromStr - for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl std::str::FromStr for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1191,24 +1154,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl std::fmt::Display for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl std::fmt::Debug for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl serde::Serialize for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1219,38 +1176,38 @@ impl serde::Serialize /// Cash App is a popular consumer app in the US that allows customers to bank, invest, send, and receive money using their digital wallet. /// Check this [page](https://stripe.com/docs/payments/cash-app-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCashapp { +pub struct UpdatePaymentMethodConfigurationCashapp { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationCashappDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationCashappDisplayPreference>, } -impl CreatePaymentMethodConfigurationCashapp { +impl UpdatePaymentMethodConfigurationCashapp { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCashappDisplayPreference { +pub struct UpdatePaymentMethodConfigurationCashappDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationCashappDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationCashappDisplayPreference { +impl UpdatePaymentMethodConfigurationCashappDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1259,10 +1216,10 @@ impl CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1271,18 +1228,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationCashappDisplayPrefere } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1290,44 +1247,42 @@ impl serde::Serialize for CreatePaymentMethodConfigurationCashappDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// Uses a customer’s [cash balance](https://stripe.com/docs/payments/customer-balance) for the payment. -/// The cash balance can be funded via a bank transfer. -/// Check this [page](https://stripe.com/docs/payments/bank-transfers) for more details. +/// EPS is an Austria-based payment method that allows customers to complete transactions online using their bank credentials. +/// EPS is supported by all Austrian banks and is accepted by over 80% of Austrian online retailers. +/// Check this [page](https://stripe.com/docs/payments/eps) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCustomerBalance { +pub struct UpdatePaymentMethodConfigurationEps { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: - Option<CreatePaymentMethodConfigurationCustomerBalanceDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationEpsDisplayPreference>, } -impl CreatePaymentMethodConfigurationCustomerBalance { +impl UpdatePaymentMethodConfigurationEps { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationCustomerBalanceDisplayPreference { +pub struct UpdatePaymentMethodConfigurationEpsDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationCustomerBalanceDisplayPreference { +impl UpdatePaymentMethodConfigurationEpsDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1336,12 +1291,10 @@ impl CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference } } -impl std::str::FromStr - for CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl std::str::FromStr for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1350,24 +1303,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl std::fmt::Display for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl std::fmt::Debug for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl serde::Serialize for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1375,42 +1322,43 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// EPS is an Austria-based payment method that allows customers to complete transactions online using their bank credentials. -/// EPS is supported by all Austrian banks and is accepted by over 80% of Austrian online retailers. -/// Check this [page](https://stripe.com/docs/payments/eps) for more details. +/// Financial Process Exchange (FPX) is a Malaysia-based payment method that allows customers to complete transactions online using their bank credentials. +/// Bank Negara Malaysia (BNM), the Central Bank of Malaysia, and eleven other major Malaysian financial institutions are members of the PayNet Group, which owns and operates FPX. +/// It is one of the most popular online payment methods in Malaysia, with nearly 90 million transactions in 2018 according to BNM. +/// Check this [page](https://stripe.com/docs/payments/fpx) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationEps { +pub struct UpdatePaymentMethodConfigurationFpx { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationEpsDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationFpxDisplayPreference>, } -impl CreatePaymentMethodConfigurationEps { +impl UpdatePaymentMethodConfigurationFpx { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationEpsDisplayPreference { +pub struct UpdatePaymentMethodConfigurationFpxDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationEpsDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationEpsDisplayPreference { +impl UpdatePaymentMethodConfigurationFpxDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1419,10 +1367,10 @@ impl CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1431,18 +1379,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationEpsDisplayPreferenceP } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1450,43 +1398,44 @@ impl serde::Serialize for CreatePaymentMethodConfigurationEpsDisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// Financial Process Exchange (FPX) is a Malaysia-based payment method that allows customers to complete transactions online using their bank credentials. -/// Bank Negara Malaysia (BNM), the Central Bank of Malaysia, and eleven other major Malaysian financial institutions are members of the PayNet Group, which owns and operates FPX. -/// It is one of the most popular online payment methods in Malaysia, with nearly 90 million transactions in 2018 according to BNM. -/// Check this [page](https://stripe.com/docs/payments/fpx) for more details. +/// giropay is a German payment method based on online banking, introduced in 2006. +/// It allows customers to complete transactions online using their online banking environment, with funds debited from their bank account. +/// Depending on their bank, customers confirm payments on giropay using a second factor of authentication or a PIN. +/// giropay accounts for 10% of online checkouts in Germany. +/// Check this [page](https://stripe.com/docs/payments/giropay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationFpx { +pub struct UpdatePaymentMethodConfigurationGiropay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationFpxDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationGiropayDisplayPreference>, } -impl CreatePaymentMethodConfigurationFpx { +impl UpdatePaymentMethodConfigurationGiropay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationFpxDisplayPreference { +pub struct UpdatePaymentMethodConfigurationGiropayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationFpxDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationFpxDisplayPreference { +impl UpdatePaymentMethodConfigurationGiropayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1495,10 +1444,10 @@ impl CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1507,18 +1456,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationFpxDisplayPreferenceP } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1526,44 +1475,42 @@ impl serde::Serialize for CreatePaymentMethodConfigurationFpxDisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// giropay is a German payment method based on online banking, introduced in 2006. -/// It allows customers to complete transactions online using their online banking environment, with funds debited from their bank account. -/// Depending on their bank, customers confirm payments on giropay using a second factor of authentication or a PIN. -/// giropay accounts for 10% of online checkouts in Germany. -/// Check this [page](https://stripe.com/docs/payments/giropay) for more details. +/// Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. +/// Use the Google Pay API to request any credit or debit card stored in your customer's Google account. +/// Check this [page](https://stripe.com/docs/google-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationGiropay { +pub struct UpdatePaymentMethodConfigurationGooglePay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationGiropayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationGooglePayDisplayPreference>, } -impl CreatePaymentMethodConfigurationGiropay { +impl UpdatePaymentMethodConfigurationGooglePay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationGiropayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationGooglePayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationGiropayDisplayPreference { +impl UpdatePaymentMethodConfigurationGooglePayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1572,10 +1519,10 @@ impl CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1584,18 +1531,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationGiropayDisplayPrefere } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1603,42 +1550,42 @@ impl serde::Serialize for CreatePaymentMethodConfigurationGiropayDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. -/// Use the Google Pay API to request any credit or debit card stored in your customer's Google account. -/// Check this [page](https://stripe.com/docs/google-pay) for more details. +/// GrabPay is a payment method developed by [Grab](https://www.grab.com/sg/consumer/finance/pay/). +/// GrabPay is a digital wallet - customers maintain a balance in their wallets that they pay out with. +/// Check this [page](https://stripe.com/docs/payments/grabpay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationGooglePay { +pub struct UpdatePaymentMethodConfigurationGrabpay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationGooglePayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationGrabpayDisplayPreference>, } -impl CreatePaymentMethodConfigurationGooglePay { +impl UpdatePaymentMethodConfigurationGrabpay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationGooglePayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationGrabpayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationGooglePayDisplayPreference { +impl UpdatePaymentMethodConfigurationGrabpayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1647,10 +1594,10 @@ impl CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1659,18 +1606,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationGooglePayDisplayPrefe } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1678,42 +1625,42 @@ impl serde::Serialize for CreatePaymentMethodConfigurationGooglePayDisplayPrefer serializer.serialize_str(self.as_str()) } } -/// GrabPay is a payment method developed by [Grab](https://www.grab.com/sg/consumer/finance/pay/). -/// GrabPay is a digital wallet - customers maintain a balance in their wallets that they pay out with. -/// Check this [page](https://stripe.com/docs/payments/grabpay) for more details. +/// iDEAL is a Netherlands-based payment method that allows customers to complete transactions online using their bank credentials. +/// All major Dutch banks are members of Currence, the scheme that operates iDEAL, making it the most popular online payment method in the Netherlands with a share of online transactions close to 55%. +/// Check this [page](https://stripe.com/docs/payments/ideal) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationGrabpay { +pub struct UpdatePaymentMethodConfigurationIdeal { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationGrabpayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationIdealDisplayPreference>, } -impl CreatePaymentMethodConfigurationGrabpay { +impl UpdatePaymentMethodConfigurationIdeal { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationGrabpayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationIdealDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationGrabpayDisplayPreference { +impl UpdatePaymentMethodConfigurationIdealDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1722,10 +1669,10 @@ impl CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1734,18 +1681,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationGrabpayDisplayPrefere } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1753,42 +1700,42 @@ impl serde::Serialize for CreatePaymentMethodConfigurationGrabpayDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// iDEAL is a Netherlands-based payment method that allows customers to complete transactions online using their bank credentials. -/// All major Dutch banks are members of Currence, the scheme that operates iDEAL, making it the most popular online payment method in the Netherlands with a share of online transactions close to 55%. -/// Check this [page](https://stripe.com/docs/payments/ideal) for more details. +/// JCB is a credit card company based in Japan. +/// JCB is currently available in Japan to businesses approved by JCB, and available to all businesses in Australia, Canada, Hong Kong, Japan, New Zealand, Singapore, Switzerland, United Kingdom, United States, and all countries in the European Economic Area except Iceland. +/// Check this [page](https://support.stripe.com/questions/accepting-japan-credit-bureau-%28jcb%29-payments) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationIdeal { +pub struct UpdatePaymentMethodConfigurationJcb { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationIdealDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationJcbDisplayPreference>, } -impl CreatePaymentMethodConfigurationIdeal { +impl UpdatePaymentMethodConfigurationJcb { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationIdealDisplayPreference { +pub struct UpdatePaymentMethodConfigurationJcbDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationIdealDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationIdealDisplayPreference { +impl UpdatePaymentMethodConfigurationJcbDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1797,10 +1744,10 @@ impl CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1809,18 +1756,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationIdealDisplayPreferenc } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1828,42 +1775,43 @@ impl serde::Serialize for CreatePaymentMethodConfigurationIdealDisplayPreference serializer.serialize_str(self.as_str()) } } -/// JCB is a credit card company based in Japan. -/// JCB is currently available in Japan to businesses approved by JCB, and available to all businesses in Australia, Canada, Hong Kong, Japan, New Zealand, Singapore, Switzerland, United Kingdom, United States, and all countries in the European Economic Area except Iceland. -/// Check this [page](https://support.stripe.com/questions/accepting-japan-credit-bureau-%28jcb%29-payments) for more details. +/// Klarna gives customers a range of [payment options](https://stripe.com/docs/payments/klarna#payment-options) during checkout. +/// Available payment options vary depending on the customer's billing address and the transaction amount. +/// These payment options make it convenient for customers to purchase items in all price ranges. +/// Check this [page](https://stripe.com/docs/payments/klarna) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationJcb { +pub struct UpdatePaymentMethodConfigurationKlarna { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationJcbDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationKlarnaDisplayPreference>, } -impl CreatePaymentMethodConfigurationJcb { +impl UpdatePaymentMethodConfigurationKlarna { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationJcbDisplayPreference { +pub struct UpdatePaymentMethodConfigurationKlarnaDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationJcbDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationJcbDisplayPreference { +impl UpdatePaymentMethodConfigurationKlarnaDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1872,10 +1820,10 @@ impl CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1884,18 +1832,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationJcbDisplayPreferenceP } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1903,43 +1851,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationJcbDisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// Klarna gives customers a range of [payment options](https://stripe.com/docs/payments/klarna#payment-options) during checkout. -/// Available payment options vary depending on the customer's billing address and the transaction amount. -/// These payment options make it convenient for customers to purchase items in all price ranges. -/// Check this [page](https://stripe.com/docs/payments/klarna) for more details. +/// Konbini allows customers in Japan to pay for bills and online purchases at convenience stores with cash. +/// Check this [page](https://stripe.com/docs/payments/konbini) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationKlarna { +pub struct UpdatePaymentMethodConfigurationKonbini { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationKlarnaDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationKonbiniDisplayPreference>, } -impl CreatePaymentMethodConfigurationKlarna { +impl UpdatePaymentMethodConfigurationKonbini { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationKlarnaDisplayPreference { +pub struct UpdatePaymentMethodConfigurationKonbiniDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationKlarnaDisplayPreference { +impl UpdatePaymentMethodConfigurationKonbiniDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -1948,10 +1894,10 @@ impl CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -1960,18 +1906,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationKlarnaDisplayPreferen } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -1979,41 +1925,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationKlarnaDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// Konbini allows customers in Japan to pay for bills and online purchases at convenience stores with cash. -/// Check this [page](https://stripe.com/docs/payments/konbini) for more details. +/// [Link](https://stripe.com/docs/payments/link) is a payment method network. +/// With Link, users save their payment details once, then reuse that information to pay with one click for any business on the network. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationKonbini { +pub struct UpdatePaymentMethodConfigurationLink { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationKonbiniDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationLinkDisplayPreference>, } -impl CreatePaymentMethodConfigurationKonbini { +impl UpdatePaymentMethodConfigurationLink { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationKonbiniDisplayPreference { +pub struct UpdatePaymentMethodConfigurationLinkDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationKonbiniDisplayPreference { +impl UpdatePaymentMethodConfigurationLinkDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2022,10 +1968,10 @@ impl CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2034,18 +1980,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationKonbiniDisplayPrefere } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2053,41 +1999,42 @@ impl serde::Serialize for CreatePaymentMethodConfigurationKonbiniDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// [Link](https://stripe.com/docs/payments/link) is a payment method network. -/// With Link, users save their payment details once, then reuse that information to pay with one click for any business on the network. +/// OXXO is a Mexican chain of convenience stores with thousands of locations across Latin America and represents nearly 20% of online transactions in Mexico. +/// OXXO allows customers to pay bills and online purchases in-store with cash. +/// Check this [page](https://stripe.com/docs/payments/oxxo) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationLink { +pub struct UpdatePaymentMethodConfigurationOxxo { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationLinkDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationOxxoDisplayPreference>, } -impl CreatePaymentMethodConfigurationLink { +impl UpdatePaymentMethodConfigurationOxxo { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationLinkDisplayPreference { +pub struct UpdatePaymentMethodConfigurationOxxoDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationLinkDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationLinkDisplayPreference { +impl UpdatePaymentMethodConfigurationOxxoDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2096,10 +2043,10 @@ impl CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2108,18 +2055,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationLinkDisplayPreference } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2127,42 +2074,42 @@ impl serde::Serialize for CreatePaymentMethodConfigurationLinkDisplayPreferenceP serializer.serialize_str(self.as_str()) } } -/// OXXO is a Mexican chain of convenience stores with thousands of locations across Latin America and represents nearly 20% of online transactions in Mexico. -/// OXXO allows customers to pay bills and online purchases in-store with cash. -/// Check this [page](https://stripe.com/docs/payments/oxxo) for more details. +/// Przelewy24 is a Poland-based payment method aggregator that allows customers to complete transactions online using bank transfers and other methods. +/// Bank transfers account for 30% of online payments in Poland and Przelewy24 provides a way for customers to pay with over 165 banks. +/// Check this [page](https://stripe.com/docs/payments/p24) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationOxxo { +pub struct UpdatePaymentMethodConfigurationP24 { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationOxxoDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationP24DisplayPreference>, } -impl CreatePaymentMethodConfigurationOxxo { +impl UpdatePaymentMethodConfigurationP24 { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationOxxoDisplayPreference { +pub struct UpdatePaymentMethodConfigurationP24DisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationP24DisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationOxxoDisplayPreference { +impl UpdatePaymentMethodConfigurationP24DisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationP24DisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2171,10 +2118,10 @@ impl CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationP24DisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2183,18 +2130,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationOxxoDisplayPreference } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2202,42 +2149,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationOxxoDisplayPreferenceP serializer.serialize_str(self.as_str()) } } -/// Przelewy24 is a Poland-based payment method aggregator that allows customers to complete transactions online using bank transfers and other methods. -/// Bank transfers account for 30% of online payments in Poland and Przelewy24 provides a way for customers to pay with over 165 banks. -/// Check this [page](https://stripe.com/docs/payments/p24) for more details. +/// PayNow is a Singapore-based payment method that allows customers to make a payment using their preferred app from participating banks and participating non-bank financial institutions. +/// Check this [page](https://stripe.com/docs/payments/paynow) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationP24 { +pub struct UpdatePaymentMethodConfigurationPaynow { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationP24DisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationPaynowDisplayPreference>, } -impl CreatePaymentMethodConfigurationP24 { +impl UpdatePaymentMethodConfigurationPaynow { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationP24DisplayPreference { +pub struct UpdatePaymentMethodConfigurationPaynowDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationP24DisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationP24DisplayPreference { +impl UpdatePaymentMethodConfigurationPaynowDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationP24DisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationP24DisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2246,10 +2192,10 @@ impl CreatePaymentMethodConfigurationP24DisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationP24DisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2258,18 +2204,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationP24DisplayPreferenceP } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2277,41 +2223,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationP24DisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// PayNow is a Singapore-based payment method that allows customers to make a payment using their preferred app from participating banks and participating non-bank financial institutions. -/// Check this [page](https://stripe.com/docs/payments/paynow) for more details. +/// PayPal, a digital wallet popular with customers in Europe, allows your customers worldwide to pay using their PayPal account. +/// Check this [page](https://stripe.com/docs/payments/paypal) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationPaynow { +pub struct UpdatePaymentMethodConfigurationPaypal { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationPaynowDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationPaypalDisplayPreference>, } -impl CreatePaymentMethodConfigurationPaynow { +impl UpdatePaymentMethodConfigurationPaypal { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationPaynowDisplayPreference { +pub struct UpdatePaymentMethodConfigurationPaypalDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationPaynowDisplayPreference { +impl UpdatePaymentMethodConfigurationPaypalDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2320,10 +2266,10 @@ impl CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2332,18 +2278,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationPaynowDisplayPreferen } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2351,41 +2297,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationPaynowDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// PayPal, a digital wallet popular with customers in Europe, allows your customers worldwide to pay using their PayPal account. -/// Check this [page](https://stripe.com/docs/payments/paypal) for more details. +/// PromptPay is a Thailand-based payment method that allows customers to make a payment using their preferred app from participating banks. +/// Check this [page](https://stripe.com/docs/payments/promptpay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationPaypal { +pub struct UpdatePaymentMethodConfigurationPromptpay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationPaypalDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationPromptpayDisplayPreference>, } -impl CreatePaymentMethodConfigurationPaypal { +impl UpdatePaymentMethodConfigurationPromptpay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationPaypalDisplayPreference { +pub struct UpdatePaymentMethodConfigurationPromptpayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationPaypalDisplayPreference { +impl UpdatePaymentMethodConfigurationPromptpayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2394,10 +2340,10 @@ impl CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2406,18 +2352,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationPaypalDisplayPreferen } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2425,41 +2371,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationPaypalDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// PromptPay is a Thailand-based payment method that allows customers to make a payment using their preferred app from participating banks. -/// Check this [page](https://stripe.com/docs/payments/promptpay) for more details. +/// The [Single Euro Payments Area (SEPA)](https://en.wikipedia.org/wiki/Single_Euro_Payments_Area) is an initiative of the European Union to simplify payments within and across member countries. +/// SEPA established and enforced banking standards to allow for the direct debiting of every EUR-denominated bank account within the SEPA region, check this [page](https://stripe.com/docs/payments/sepa-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationPromptpay { +pub struct UpdatePaymentMethodConfigurationSepaDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationPromptpayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationSepaDebitDisplayPreference>, } -impl CreatePaymentMethodConfigurationPromptpay { +impl UpdatePaymentMethodConfigurationSepaDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationPromptpayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationSepaDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationPromptpayDisplayPreference { +impl UpdatePaymentMethodConfigurationSepaDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2468,10 +2414,10 @@ impl CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2480,18 +2426,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationPromptpayDisplayPrefe } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2499,41 +2445,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationPromptpayDisplayPrefer serializer.serialize_str(self.as_str()) } } -/// Revolut Pay, developed by Revolut, a global finance app, is a digital wallet payment method. -/// Revolut Pay uses the customer’s stored balance or cards to fund the payment, and offers the option for non-Revolut customers to save their details after their first purchase. +/// Stripe users in Europe and the United States can use the [Payment Intents API](https://stripe.com/docs/payments/payment-intents)—a single integration path for creating payments using any supported method—to accept [Sofort](https://www.sofort.com/) payments from customers. +/// Check this [page](https://stripe.com/docs/payments/sofort) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationRevolutPay { +pub struct UpdatePaymentMethodConfigurationSofort { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationRevolutPayDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationSofortDisplayPreference>, } -impl CreatePaymentMethodConfigurationRevolutPay { +impl UpdatePaymentMethodConfigurationSofort { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationRevolutPayDisplayPreference { +pub struct UpdatePaymentMethodConfigurationSofortDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationRevolutPayDisplayPreference { +impl UpdatePaymentMethodConfigurationSofortDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2542,10 +2488,10 @@ impl CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2554,18 +2500,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationRevolutPayDisplayPref } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2573,41 +2519,41 @@ impl serde::Serialize for CreatePaymentMethodConfigurationRevolutPayDisplayPrefe serializer.serialize_str(self.as_str()) } } -/// The [Single Euro Payments Area (SEPA)](https://en.wikipedia.org/wiki/Single_Euro_Payments_Area) is an initiative of the European Union to simplify payments within and across member countries. -/// SEPA established and enforced banking standards to allow for the direct debiting of every EUR-denominated bank account within the SEPA region, check this [page](https://stripe.com/docs/payments/sepa-debit) for more details. +/// Stripe users in the United States can accept ACH direct debit payments from customers with a US bank account using the Automated Clearing House (ACH) payments system operated by Nacha. +/// Check this [page](https://stripe.com/docs/payments/ach-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationSepaDebit { +pub struct UpdatePaymentMethodConfigurationUsBankAccount { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationSepaDebitDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationUsBankAccountDisplayPreference>, } -impl CreatePaymentMethodConfigurationSepaDebit { +impl UpdatePaymentMethodConfigurationUsBankAccount { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationSepaDebitDisplayPreference { +pub struct UpdatePaymentMethodConfigurationUsBankAccountDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationSepaDebitDisplayPreference { +impl UpdatePaymentMethodConfigurationUsBankAccountDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2616,10 +2562,10 @@ impl CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2628,18 +2574,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationSepaDebitDisplayPrefe } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2647,196 +2593,43 @@ impl serde::Serialize for CreatePaymentMethodConfigurationSepaDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } -/// Stripe users in Europe and the United States can use the [Payment Intents API](https://stripe.com/docs/payments/payment-intents)—a single integration path for creating payments using any supported method—to accept [Sofort](https://www.sofort.com/) payments from customers. -/// Check this [page](https://stripe.com/docs/payments/sofort) for more details. +/// WeChat, owned by Tencent, is China's leading mobile app with over 1 billion monthly active users. +/// Chinese consumers can use WeChat Pay to pay for goods and services inside of businesses' apps and websites. +/// WeChat Pay users buy most frequently in gaming, e-commerce, travel, online education, and food/nutrition. +/// Check this [page](https://stripe.com/docs/payments/wechat-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationSofort { +pub struct UpdatePaymentMethodConfigurationWechatPay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationSofortDisplayPreference>, + pub display_preference: Option<UpdatePaymentMethodConfigurationWechatPayDisplayPreference>, } -impl CreatePaymentMethodConfigurationSofort { +impl UpdatePaymentMethodConfigurationWechatPay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationSofortDisplayPreference { +pub struct UpdatePaymentMethodConfigurationWechatPayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationSofortDisplayPreferencePreference>, -} -impl CreatePaymentMethodConfigurationSofortDisplayPreference { - pub fn new() -> Self { - Self::default() - } -} -/// The account's preference for whether or not to display this payment method. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { - None, - Off, - On, -} -impl CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { - pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; - match self { - None => "none", - Off => "off", - On => "on", - } - } -} - -impl std::str::FromStr for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; - match s { - "none" => Ok(None), - "off" => Ok(Off), - "on" => Ok(On), - _ => Err(()), - } - } -} -impl std::fmt::Display for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// Stripe users in the United States can accept ACH direct debit payments from customers with a US bank account using the Automated Clearing House (ACH) payments system operated by Nacha. -/// Check this [page](https://stripe.com/docs/payments/ach-debit) for more details. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationUsBankAccount { - /// Whether or not the payment method should be displayed. - #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationUsBankAccountDisplayPreference>, -} -impl CreatePaymentMethodConfigurationUsBankAccount { - pub fn new() -> Self { - Self::default() - } -} -/// Whether or not the payment method should be displayed. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationUsBankAccountDisplayPreference { - /// The account's preference for whether or not to display this payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference>, -} -impl CreatePaymentMethodConfigurationUsBankAccountDisplayPreference { - pub fn new() -> Self { - Self::default() - } -} -/// The account's preference for whether or not to display this payment method. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { - None, - Off, - On, -} -impl CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { - pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; - match self { - None => "none", - Off => "off", - On => "on", - } - } -} - -impl std::str::FromStr - for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; - match s { - "none" => Ok(None), - "off" => Ok(Off), - "on" => Ok(On), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// WeChat, owned by Tencent, is China's leading mobile app with over 1 billion monthly active users. -/// Chinese consumers can use WeChat Pay to pay for goods and services inside of businesses' apps and websites. -/// WeChat Pay users buy most frequently in gaming, e-commerce, travel, online education, and food/nutrition. -/// Check this [page](https://stripe.com/docs/payments/wechat-pay) for more details. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationWechatPay { - /// Whether or not the payment method should be displayed. - #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<CreatePaymentMethodConfigurationWechatPayDisplayPreference>, -} -impl CreatePaymentMethodConfigurationWechatPay { - pub fn new() -> Self { - Self::default() - } -} -/// Whether or not the payment method should be displayed. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentMethodConfigurationWechatPayDisplayPreference { - /// The account's preference for whether or not to display this payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference>, + pub preference: Option<UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference>, } -impl CreatePaymentMethodConfigurationWechatPayDisplayPreference { +impl UpdatePaymentMethodConfigurationWechatPayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +pub enum UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { None, Off, On, } -impl CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -2845,10 +2638,10 @@ impl CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { } } -impl std::str::FromStr for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl std::str::FromStr for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; + use UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -2857,18 +2650,18 @@ impl std::str::FromStr for CreatePaymentMethodConfigurationWechatPayDisplayPrefe } } } -impl std::fmt::Display for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl std::fmt::Display for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl std::fmt::Debug for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl serde::Serialize for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -2876,90 +2669,79 @@ impl serde::Serialize for CreatePaymentMethodConfigurationWechatPayDisplayPrefer serializer.serialize_str(self.as_str()) } } -impl<'a> CreatePaymentMethodConfiguration<'a> { - /// Creates a payment method configuration - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_payment::PaymentMethodConfiguration> { - client.send_form("/payment_method_configurations", self, http_types::Method::Post) +impl<'a> UpdatePaymentMethodConfiguration<'a> { + /// Update payment method configuration + pub fn send(&self, client: &stripe::Client, configuration: &stripe_payment::PaymentMethodConfigurationId) -> stripe::Response<stripe_payment::PaymentMethodConfiguration> { + client.send_form(&format!("/payment_method_configurations/{configuration}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfiguration<'a> { +pub struct CreatePaymentMethodConfiguration<'a> { /// Canadian pre-authorized debit payments, check this [page](https://stripe.com/docs/payments/acss-debit) for more details like country availability. #[serde(skip_serializing_if = "Option::is_none")] - pub acss_debit: Option<UpdatePaymentMethodConfigurationAcssDebit>, - /// Whether the configuration can be used for new payments. - #[serde(skip_serializing_if = "Option::is_none")] - pub active: Option<bool>, + pub acss_debit: Option<CreatePaymentMethodConfigurationAcssDebit>, /// [Affirm](https://www.affirm.com/) gives your customers a way to split purchases over a series of payments. /// Depending on the purchase, they can pay with four interest-free payments (Split Pay) or pay over a longer term (Installments), which might include interest. /// Check this [page](https://stripe.com/docs/payments/affirm) for more details like country availability. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<UpdatePaymentMethodConfigurationAffirm>, + pub affirm: Option<CreatePaymentMethodConfigurationAffirm>, /// Afterpay gives your customers a way to pay for purchases in installments, check this [page](https://stripe.com/docs/payments/afterpay-clearpay) for more details like country availability. /// Afterpay is particularly popular among businesses selling fashion, beauty, and sports products. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<UpdatePaymentMethodConfigurationAfterpayClearpay>, + pub afterpay_clearpay: Option<CreatePaymentMethodConfigurationAfterpayClearpay>, /// Alipay is a digital wallet in China that has more than a billion active users worldwide. /// Alipay users can pay on the web or on a mobile device using login credentials or their Alipay app. /// Alipay has a low dispute rate and reduces fraud by authenticating payments using the customer's login credentials. /// Check this [page](https://stripe.com/docs/payments/alipay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<UpdatePaymentMethodConfigurationAlipay>, + pub alipay: Option<CreatePaymentMethodConfigurationAlipay>, /// Stripe users can accept [Apple Pay](/payments/apple-pay) in iOS applications in iOS 9 and later, and on the web in Safari starting with iOS 10 or macOS Sierra. /// There are no additional fees to process Apple Pay payments, and the [pricing](/pricing) is the same as other card transactions. /// Check this [page](https://stripe.com/docs/apple-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub apple_pay: Option<UpdatePaymentMethodConfigurationApplePay>, + pub apple_pay: Option<CreatePaymentMethodConfigurationApplePay>, /// Apple Pay Later, a payment method for customers to buy now and pay later, gives your customers a way to split purchases into four installments across six weeks. #[serde(skip_serializing_if = "Option::is_none")] - pub apple_pay_later: Option<UpdatePaymentMethodConfigurationApplePayLater>, + pub apple_pay_later: Option<CreatePaymentMethodConfigurationApplePayLater>, /// Stripe users in Australia can accept Bulk Electronic Clearing System (BECS) direct debit payments from customers with an Australian bank account. /// Check this [page](https://stripe.com/docs/payments/au-becs-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub au_becs_debit: Option<UpdatePaymentMethodConfigurationAuBecsDebit>, + pub au_becs_debit: Option<CreatePaymentMethodConfigurationAuBecsDebit>, /// Stripe users in the UK can accept Bacs Direct Debit payments from customers with a UK bank account, check this [page](https://stripe.com/docs/payments/payment-methods/bacs-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub bacs_debit: Option<UpdatePaymentMethodConfigurationBacsDebit>, + pub bacs_debit: Option<CreatePaymentMethodConfigurationBacsDebit>, /// Bancontact is the most popular online payment method in Belgium, with over 15 million cards in circulation. /// [Customers](https://stripe.com/docs/api/customers) use a Bancontact card or mobile app linked to a Belgian bank account to make online payments that are secure, guaranteed, and confirmed immediately. /// Check this [page](https://stripe.com/docs/payments/bancontact) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<UpdatePaymentMethodConfigurationBancontact>, + pub bancontact: Option<CreatePaymentMethodConfigurationBancontact>, /// BLIK is a [single use](https://stripe.com/docs/payments/payment-methods#usage) payment method that requires customers to authenticate their payments. /// When customers want to pay online using BLIK, they request a six-digit code from their banking application and enter it into the payment collection form. /// Check this [page](https://stripe.com/docs/payments/blik) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<UpdatePaymentMethodConfigurationBlik>, + pub blik: Option<CreatePaymentMethodConfigurationBlik>, /// Boleto is an official (regulated by the Central Bank of Brazil) payment method in Brazil. /// Check this [page](https://stripe.com/docs/payments/boleto) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub boleto: Option<UpdatePaymentMethodConfigurationBoleto>, + pub boleto: Option<CreatePaymentMethodConfigurationBoleto>, /// Cards are a popular way for consumers and businesses to pay online or in person. /// Stripe supports global and local card networks. #[serde(skip_serializing_if = "Option::is_none")] - pub card: Option<UpdatePaymentMethodConfigurationCard>, + pub card: Option<CreatePaymentMethodConfigurationCard>, /// Cartes Bancaires is France's local card network. /// More than 95% of these cards are co-branded with either Visa or Mastercard, meaning you can process these cards over either Cartes Bancaires or the Visa or Mastercard networks. /// Check this [page](https://stripe.com/docs/payments/cartes-bancaires) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: Option<UpdatePaymentMethodConfigurationCartesBancaires>, + pub cartes_bancaires: Option<CreatePaymentMethodConfigurationCartesBancaires>, /// Cash App is a popular consumer app in the US that allows customers to bank, invest, send, and receive money using their digital wallet. /// Check this [page](https://stripe.com/docs/payments/cash-app-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<UpdatePaymentMethodConfigurationCashapp>, - /// Uses a customer’s [cash balance](https://stripe.com/docs/payments/customer-balance) for the payment. - /// The cash balance can be funded via a bank transfer. - /// Check this [page](https://stripe.com/docs/payments/bank-transfers) for more details. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<UpdatePaymentMethodConfigurationCustomerBalance>, + pub cashapp: Option<CreatePaymentMethodConfigurationCashapp>, /// EPS is an Austria-based payment method that allows customers to complete transactions online using their bank credentials. /// EPS is supported by all Austrian banks and is accepted by over 80% of Austrian online retailers. /// Check this [page](https://stripe.com/docs/payments/eps) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub eps: Option<UpdatePaymentMethodConfigurationEps>, + pub eps: Option<CreatePaymentMethodConfigurationEps>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -2968,48 +2750,48 @@ pub struct UpdatePaymentMethodConfiguration<'a> { /// It is one of the most popular online payment methods in Malaysia, with nearly 90 million transactions in 2018 according to BNM. /// Check this [page](https://stripe.com/docs/payments/fpx) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub fpx: Option<UpdatePaymentMethodConfigurationFpx>, + pub fpx: Option<CreatePaymentMethodConfigurationFpx>, /// giropay is a German payment method based on online banking, introduced in 2006. /// It allows customers to complete transactions online using their online banking environment, with funds debited from their bank account. /// Depending on their bank, customers confirm payments on giropay using a second factor of authentication or a PIN. /// giropay accounts for 10% of online checkouts in Germany. /// Check this [page](https://stripe.com/docs/payments/giropay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<UpdatePaymentMethodConfigurationGiropay>, + pub giropay: Option<CreatePaymentMethodConfigurationGiropay>, /// Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. /// Use the Google Pay API to request any credit or debit card stored in your customer's Google account. /// Check this [page](https://stripe.com/docs/google-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub google_pay: Option<UpdatePaymentMethodConfigurationGooglePay>, + pub google_pay: Option<CreatePaymentMethodConfigurationGooglePay>, /// GrabPay is a payment method developed by [Grab](https://www.grab.com/sg/consumer/finance/pay/). /// GrabPay is a digital wallet - customers maintain a balance in their wallets that they pay out with. /// Check this [page](https://stripe.com/docs/payments/grabpay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<UpdatePaymentMethodConfigurationGrabpay>, + pub grabpay: Option<CreatePaymentMethodConfigurationGrabpay>, /// iDEAL is a Netherlands-based payment method that allows customers to complete transactions online using their bank credentials. /// All major Dutch banks are members of Currence, the scheme that operates iDEAL, making it the most popular online payment method in the Netherlands with a share of online transactions close to 55%. /// Check this [page](https://stripe.com/docs/payments/ideal) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub ideal: Option<UpdatePaymentMethodConfigurationIdeal>, + pub ideal: Option<CreatePaymentMethodConfigurationIdeal>, /// JCB is a credit card company based in Japan. /// JCB is currently available in Japan to businesses approved by JCB, and available to all businesses in Australia, Canada, Hong Kong, Japan, New Zealand, Singapore, Switzerland, United Kingdom, United States, and all countries in the European Economic Area except Iceland. /// Check this [page](https://support.stripe.com/questions/accepting-japan-credit-bureau-%28jcb%29-payments) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub jcb: Option<UpdatePaymentMethodConfigurationJcb>, + pub jcb: Option<CreatePaymentMethodConfigurationJcb>, /// Klarna gives customers a range of [payment options](https://stripe.com/docs/payments/klarna#payment-options) during checkout. /// Available payment options vary depending on the customer's billing address and the transaction amount. /// These payment options make it convenient for customers to purchase items in all price ranges. /// Check this [page](https://stripe.com/docs/payments/klarna) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub klarna: Option<UpdatePaymentMethodConfigurationKlarna>, + pub klarna: Option<CreatePaymentMethodConfigurationKlarna>, /// Konbini allows customers in Japan to pay for bills and online purchases at convenience stores with cash. /// Check this [page](https://stripe.com/docs/payments/konbini) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<UpdatePaymentMethodConfigurationKonbini>, + pub konbini: Option<CreatePaymentMethodConfigurationKonbini>, /// [Link](https://stripe.com/docs/payments/link) is a payment method network. /// With Link, users save their payment details once, then reuse that information to pay with one click for any business on the network. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<UpdatePaymentMethodConfigurationLink>, + pub link: Option<CreatePaymentMethodConfigurationLink>, /// Configuration name. #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<&'a str>, @@ -3017,237 +2799,85 @@ pub struct UpdatePaymentMethodConfiguration<'a> { /// OXXO allows customers to pay bills and online purchases in-store with cash. /// Check this [page](https://stripe.com/docs/payments/oxxo) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<UpdatePaymentMethodConfigurationOxxo>, + pub oxxo: Option<CreatePaymentMethodConfigurationOxxo>, /// Przelewy24 is a Poland-based payment method aggregator that allows customers to complete transactions online using bank transfers and other methods. /// Bank transfers account for 30% of online payments in Poland and Przelewy24 provides a way for customers to pay with over 165 banks. /// Check this [page](https://stripe.com/docs/payments/p24) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub p24: Option<UpdatePaymentMethodConfigurationP24>, + pub p24: Option<CreatePaymentMethodConfigurationP24>, + /// Configuration's parent configuration. Specify to create a child configuration. + #[serde(skip_serializing_if = "Option::is_none")] + pub parent: Option<&'a str>, /// PayNow is a Singapore-based payment method that allows customers to make a payment using their preferred app from participating banks and participating non-bank financial institutions. /// Check this [page](https://stripe.com/docs/payments/paynow) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<UpdatePaymentMethodConfigurationPaynow>, + pub paynow: Option<CreatePaymentMethodConfigurationPaynow>, /// PayPal, a digital wallet popular with customers in Europe, allows your customers worldwide to pay using their PayPal account. /// Check this [page](https://stripe.com/docs/payments/paypal) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<UpdatePaymentMethodConfigurationPaypal>, + pub paypal: Option<CreatePaymentMethodConfigurationPaypal>, /// PromptPay is a Thailand-based payment method that allows customers to make a payment using their preferred app from participating banks. /// Check this [page](https://stripe.com/docs/payments/promptpay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<UpdatePaymentMethodConfigurationPromptpay>, - /// Revolut Pay, developed by Revolut, a global finance app, is a digital wallet payment method. - /// Revolut Pay uses the customer’s stored balance or cards to fund the payment, and offers the option for non-Revolut customers to save their details after their first purchase. - #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<UpdatePaymentMethodConfigurationRevolutPay>, + pub promptpay: Option<CreatePaymentMethodConfigurationPromptpay>, /// The [Single Euro Payments Area (SEPA)](https://en.wikipedia.org/wiki/Single_Euro_Payments_Area) is an initiative of the European Union to simplify payments within and across member countries. /// SEPA established and enforced banking standards to allow for the direct debiting of every EUR-denominated bank account within the SEPA region, check this [page](https://stripe.com/docs/payments/sepa-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option<UpdatePaymentMethodConfigurationSepaDebit>, + pub sepa_debit: Option<CreatePaymentMethodConfigurationSepaDebit>, /// Stripe users in Europe and the United States can use the [Payment Intents API](https://stripe.com/docs/payments/payment-intents)—a single integration path for creating payments using any supported method—to accept [Sofort](https://www.sofort.com/) payments from customers. /// Check this [page](https://stripe.com/docs/payments/sofort) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub sofort: Option<UpdatePaymentMethodConfigurationSofort>, + pub sofort: Option<CreatePaymentMethodConfigurationSofort>, /// Stripe users in the United States can accept ACH direct debit payments from customers with a US bank account using the Automated Clearing House (ACH) payments system operated by Nacha. /// Check this [page](https://stripe.com/docs/payments/ach-debit) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: Option<UpdatePaymentMethodConfigurationUsBankAccount>, + pub us_bank_account: Option<CreatePaymentMethodConfigurationUsBankAccount>, /// WeChat, owned by Tencent, is China's leading mobile app with over 1 billion monthly active users. /// Chinese consumers can use WeChat Pay to pay for goods and services inside of businesses' apps and websites. /// WeChat Pay users buy most frequently in gaming, e-commerce, travel, online education, and food/nutrition. /// Check this [page](https://stripe.com/docs/payments/wechat-pay) for more details. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<UpdatePaymentMethodConfigurationWechatPay>, -} -impl<'a> UpdatePaymentMethodConfiguration<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Canadian pre-authorized debit payments, check this [page](https://stripe.com/docs/payments/acss-debit) for more details like country availability. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAcssDebit { - /// Whether or not the payment method should be displayed. - #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationAcssDebitDisplayPreference>, -} -impl UpdatePaymentMethodConfigurationAcssDebit { - pub fn new() -> Self { - Self::default() - } -} -/// Whether or not the payment method should be displayed. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAcssDebitDisplayPreference { - /// The account's preference for whether or not to display this payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference>, -} -impl UpdatePaymentMethodConfigurationAcssDebitDisplayPreference { - pub fn new() -> Self { - Self::default() - } -} -/// The account's preference for whether or not to display this payment method. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { - None, - Off, - On, -} -impl UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { - pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; - match self { - None => "none", - Off => "off", - On => "on", - } - } -} - -impl std::str::FromStr for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; - match s { - "none" => Ok(None), - "off" => Ok(Off), - "on" => Ok(On), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -/// [Affirm](https://www.affirm.com/) gives your customers a way to split purchases over a series of payments. -/// Depending on the purchase, they can pay with four interest-free payments (Split Pay) or pay over a longer term (Installments), which might include interest. -/// Check this [page](https://stripe.com/docs/payments/affirm) for more details like country availability. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAffirm { - /// Whether or not the payment method should be displayed. - #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationAffirmDisplayPreference>, -} -impl UpdatePaymentMethodConfigurationAffirm { - pub fn new() -> Self { - Self::default() - } -} -/// Whether or not the payment method should be displayed. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAffirmDisplayPreference { - /// The account's preference for whether or not to display this payment method. - #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference>, -} -impl UpdatePaymentMethodConfigurationAffirmDisplayPreference { - pub fn new() -> Self { - Self::default() - } -} -/// The account's preference for whether or not to display this payment method. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { - None, - Off, - On, -} -impl UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { - pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; - match self { - None => "none", - Off => "off", - On => "on", - } - } -} - -impl std::str::FromStr for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; - match s { - "none" => Ok(None), - "off" => Ok(Off), - "on" => Ok(On), - _ => Err(()), - } - } -} -impl std::fmt::Display for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } + pub wechat_pay: Option<CreatePaymentMethodConfigurationWechatPay>, } -impl serde::Serialize for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) +impl<'a> CreatePaymentMethodConfiguration<'a> { + pub fn new() -> Self { + Self::default() } } -/// Afterpay gives your customers a way to pay for purchases in installments, check this [page](https://stripe.com/docs/payments/afterpay-clearpay) for more details like country availability. -/// Afterpay is particularly popular among businesses selling fashion, beauty, and sports products. +/// Canadian pre-authorized debit payments, check this [page](https://stripe.com/docs/payments/acss-debit) for more details like country availability. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAfterpayClearpay { +pub struct CreatePaymentMethodConfigurationAcssDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: - Option<UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationAcssDebitDisplayPreference>, } -impl UpdatePaymentMethodConfigurationAfterpayClearpay { +impl CreatePaymentMethodConfigurationAcssDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { +pub struct CreatePaymentMethodConfigurationAcssDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { +impl CreatePaymentMethodConfigurationAcssDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3256,12 +2886,10 @@ impl UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference } } -impl std::str::FromStr - for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl std::str::FromStr for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3270,24 +2898,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl std::fmt::Display for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl std::fmt::Debug for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference -{ +impl serde::Serialize for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3295,43 +2917,42 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Alipay is a digital wallet in China that has more than a billion active users worldwide. -/// Alipay users can pay on the web or on a mobile device using login credentials or their Alipay app. -/// Alipay has a low dispute rate and reduces fraud by authenticating payments using the customer's login credentials. -/// Check this [page](https://stripe.com/docs/payments/alipay) for more details. +/// [Affirm](https://www.affirm.com/) gives your customers a way to split purchases over a series of payments. +/// Depending on the purchase, they can pay with four interest-free payments (Split Pay) or pay over a longer term (Installments), which might include interest. +/// Check this [page](https://stripe.com/docs/payments/affirm) for more details like country availability. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAlipay { +pub struct CreatePaymentMethodConfigurationAffirm { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationAlipayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationAffirmDisplayPreference>, } -impl UpdatePaymentMethodConfigurationAlipay { +impl CreatePaymentMethodConfigurationAffirm { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAlipayDisplayPreference { +pub struct CreatePaymentMethodConfigurationAffirmDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationAlipayDisplayPreference { +impl CreatePaymentMethodConfigurationAffirmDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3340,10 +2961,10 @@ impl UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3352,18 +2973,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationAlipayDisplayPreferen } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3371,42 +2992,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationAlipayDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// Stripe users can accept [Apple Pay](/payments/apple-pay) in iOS applications in iOS 9 and later, and on the web in Safari starting with iOS 10 or macOS Sierra. -/// There are no additional fees to process Apple Pay payments, and the [pricing](/pricing) is the same as other card transactions. -/// Check this [page](https://stripe.com/docs/apple-pay) for more details. +/// Afterpay gives your customers a way to pay for purchases in installments, check this [page](https://stripe.com/docs/payments/afterpay-clearpay) for more details like country availability. +/// Afterpay is particularly popular among businesses selling fashion, beauty, and sports products. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationApplePay { +pub struct CreatePaymentMethodConfigurationAfterpayClearpay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationApplePayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationApplePay { +impl CreatePaymentMethodConfigurationAfterpayClearpay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationApplePayDisplayPreference { +pub struct CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationApplePayDisplayPreference { +impl CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3415,10 +3035,10 @@ impl UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3427,18 +3047,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationApplePayDisplayPrefer } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3446,41 +3066,43 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayDisplayPrefere serializer.serialize_str(self.as_str()) } } -/// Apple Pay Later, a payment method for customers to buy now and pay later, gives your customers a way to split purchases into four installments across six weeks. +/// Alipay is a digital wallet in China that has more than a billion active users worldwide. +/// Alipay users can pay on the web or on a mobile device using login credentials or their Alipay app. +/// Alipay has a low dispute rate and reduces fraud by authenticating payments using the customer's login credentials. +/// Check this [page](https://stripe.com/docs/payments/alipay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationApplePayLater { +pub struct CreatePaymentMethodConfigurationAlipay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationApplePayLaterDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationAlipayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationApplePayLater { +impl CreatePaymentMethodConfigurationAlipay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationApplePayLaterDisplayPreference { +pub struct CreatePaymentMethodConfigurationAlipayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationApplePayLaterDisplayPreference { +impl CreatePaymentMethodConfigurationAlipayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3489,12 +3111,10 @@ impl UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { } } -impl std::str::FromStr - for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference -{ +impl std::str::FromStr for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3503,20 +3123,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference -{ +impl std::fmt::Display for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3524,41 +3142,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayLaterDisplayPr serializer.serialize_str(self.as_str()) } } -/// Stripe users in Australia can accept Bulk Electronic Clearing System (BECS) direct debit payments from customers with an Australian bank account. -/// Check this [page](https://stripe.com/docs/payments/au-becs-debit) for more details. +/// Stripe users can accept [Apple Pay](/payments/apple-pay) in iOS applications in iOS 9 and later, and on the web in Safari starting with iOS 10 or macOS Sierra. +/// There are no additional fees to process Apple Pay payments, and the [pricing](/pricing) is the same as other card transactions. +/// Check this [page](https://stripe.com/docs/apple-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAuBecsDebit { +pub struct CreatePaymentMethodConfigurationApplePay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationApplePayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationAuBecsDebit { +impl CreatePaymentMethodConfigurationApplePay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreference { +pub struct CreatePaymentMethodConfigurationApplePayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreference { +impl CreatePaymentMethodConfigurationApplePayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3567,10 +3186,10 @@ impl UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3579,18 +3198,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPre } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3598,40 +3217,40 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPref serializer.serialize_str(self.as_str()) } } -/// Stripe users in the UK can accept Bacs Direct Debit payments from customers with a UK bank account, check this [page](https://stripe.com/docs/payments/payment-methods/bacs-debit) for more details. +/// Apple Pay Later, a payment method for customers to buy now and pay later, gives your customers a way to split purchases into four installments across six weeks. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBacsDebit { +pub struct CreatePaymentMethodConfigurationApplePayLater { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationBacsDebitDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationApplePayLaterDisplayPreference>, } -impl UpdatePaymentMethodConfigurationBacsDebit { +impl CreatePaymentMethodConfigurationApplePayLater { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBacsDebitDisplayPreference { +pub struct CreatePaymentMethodConfigurationApplePayLaterDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationBacsDebitDisplayPreference { +impl CreatePaymentMethodConfigurationApplePayLaterDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3640,10 +3259,10 @@ impl UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3652,18 +3271,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationBacsDebitDisplayPrefe } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3671,42 +3290,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBacsDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } -/// Bancontact is the most popular online payment method in Belgium, with over 15 million cards in circulation. -/// [Customers](https://stripe.com/docs/api/customers) use a Bancontact card or mobile app linked to a Belgian bank account to make online payments that are secure, guaranteed, and confirmed immediately. -/// Check this [page](https://stripe.com/docs/payments/bancontact) for more details. +/// Stripe users in Australia can accept Bulk Electronic Clearing System (BECS) direct debit payments from customers with an Australian bank account. +/// Check this [page](https://stripe.com/docs/payments/au-becs-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBancontact { +pub struct CreatePaymentMethodConfigurationAuBecsDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationBancontactDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationAuBecsDebitDisplayPreference>, } -impl UpdatePaymentMethodConfigurationBancontact { +impl CreatePaymentMethodConfigurationAuBecsDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBancontactDisplayPreference { +pub struct CreatePaymentMethodConfigurationAuBecsDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationBancontactDisplayPreference { +impl CreatePaymentMethodConfigurationAuBecsDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3715,10 +3333,10 @@ impl UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3727,18 +3345,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationBancontactDisplayPref } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3746,42 +3364,40 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBancontactDisplayPrefe serializer.serialize_str(self.as_str()) } } -/// BLIK is a [single use](https://stripe.com/docs/payments/payment-methods#usage) payment method that requires customers to authenticate their payments. -/// When customers want to pay online using BLIK, they request a six-digit code from their banking application and enter it into the payment collection form. -/// Check this [page](https://stripe.com/docs/payments/blik) for more details. +/// Stripe users in the UK can accept Bacs Direct Debit payments from customers with a UK bank account, check this [page](https://stripe.com/docs/payments/payment-methods/bacs-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBlik { +pub struct CreatePaymentMethodConfigurationBacsDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationBlikDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationBacsDebitDisplayPreference>, } -impl UpdatePaymentMethodConfigurationBlik { +impl CreatePaymentMethodConfigurationBacsDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBlikDisplayPreference { +pub struct CreatePaymentMethodConfigurationBacsDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationBlikDisplayPreference { +impl CreatePaymentMethodConfigurationBacsDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3790,10 +3406,10 @@ impl UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3802,18 +3418,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationBlikDisplayPreference } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3821,41 +3437,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBlikDisplayPreferenceP serializer.serialize_str(self.as_str()) } } -/// Boleto is an official (regulated by the Central Bank of Brazil) payment method in Brazil. -/// Check this [page](https://stripe.com/docs/payments/boleto) for more details. +/// Bancontact is the most popular online payment method in Belgium, with over 15 million cards in circulation. +/// [Customers](https://stripe.com/docs/api/customers) use a Bancontact card or mobile app linked to a Belgian bank account to make online payments that are secure, guaranteed, and confirmed immediately. +/// Check this [page](https://stripe.com/docs/payments/bancontact) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBoleto { +pub struct CreatePaymentMethodConfigurationBancontact { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationBoletoDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationBancontactDisplayPreference>, } -impl UpdatePaymentMethodConfigurationBoleto { +impl CreatePaymentMethodConfigurationBancontact { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationBoletoDisplayPreference { +pub struct CreatePaymentMethodConfigurationBancontactDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationBoletoDisplayPreference { +impl CreatePaymentMethodConfigurationBancontactDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3864,10 +3481,10 @@ impl UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3876,18 +3493,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationBoletoDisplayPreferen } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3895,41 +3512,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBoletoDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// Cards are a popular way for consumers and businesses to pay online or in person. -/// Stripe supports global and local card networks. +/// BLIK is a [single use](https://stripe.com/docs/payments/payment-methods#usage) payment method that requires customers to authenticate their payments. +/// When customers want to pay online using BLIK, they request a six-digit code from their banking application and enter it into the payment collection form. +/// Check this [page](https://stripe.com/docs/payments/blik) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCard { +pub struct CreatePaymentMethodConfigurationBlik { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationCardDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationBlikDisplayPreference>, } -impl UpdatePaymentMethodConfigurationCard { +impl CreatePaymentMethodConfigurationBlik { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCardDisplayPreference { +pub struct CreatePaymentMethodConfigurationBlikDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationCardDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationBlikDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationCardDisplayPreference { +impl CreatePaymentMethodConfigurationBlikDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationCardDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -3938,10 +3556,10 @@ impl UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationCardDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBlikDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -3950,18 +3568,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationCardDisplayPreference } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -3969,44 +3587,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationCardDisplayPreferenceP serializer.serialize_str(self.as_str()) } } -/// Cartes Bancaires is France's local card network. -/// More than 95% of these cards are co-branded with either Visa or Mastercard, meaning you can process these cards over either Cartes Bancaires or the Visa or Mastercard networks. -/// Check this [page](https://stripe.com/docs/payments/cartes-bancaires) for more details. +/// Boleto is an official (regulated by the Central Bank of Brazil) payment method in Brazil. +/// Check this [page](https://stripe.com/docs/payments/boleto) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCartesBancaires { +pub struct CreatePaymentMethodConfigurationBoleto { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: - Option<UpdatePaymentMethodConfigurationCartesBancairesDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationBoletoDisplayPreference>, } -impl UpdatePaymentMethodConfigurationCartesBancaires { +impl CreatePaymentMethodConfigurationBoleto { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCartesBancairesDisplayPreference { +pub struct CreatePaymentMethodConfigurationBoletoDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationCartesBancairesDisplayPreference { +impl CreatePaymentMethodConfigurationBoletoDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4015,12 +3630,10 @@ impl UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference } } -impl std::str::FromStr - for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl std::str::FromStr for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4029,24 +3642,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl std::fmt::Display for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl std::fmt::Debug for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference -{ +impl serde::Serialize for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4054,41 +3661,41 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// Cash App is a popular consumer app in the US that allows customers to bank, invest, send, and receive money using their digital wallet. -/// Check this [page](https://stripe.com/docs/payments/cash-app-pay) for more details. +/// Cards are a popular way for consumers and businesses to pay online or in person. +/// Stripe supports global and local card networks. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCashapp { +pub struct CreatePaymentMethodConfigurationCard { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationCashappDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationCardDisplayPreference>, } -impl UpdatePaymentMethodConfigurationCashapp { +impl CreatePaymentMethodConfigurationCard { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCashappDisplayPreference { +pub struct CreatePaymentMethodConfigurationCardDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationCardDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationCashappDisplayPreference { +impl CreatePaymentMethodConfigurationCardDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationCardDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationCardDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationCardDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4097,10 +3704,10 @@ impl UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationCardDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4109,18 +3716,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationCashappDisplayPrefere } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationCardDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4128,44 +3735,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationCashappDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// Uses a customer’s [cash balance](https://stripe.com/docs/payments/customer-balance) for the payment. -/// The cash balance can be funded via a bank transfer. -/// Check this [page](https://stripe.com/docs/payments/bank-transfers) for more details. +/// Cartes Bancaires is France's local card network. +/// More than 95% of these cards are co-branded with either Visa or Mastercard, meaning you can process these cards over either Cartes Bancaires or the Visa or Mastercard networks. +/// Check this [page](https://stripe.com/docs/payments/cartes-bancaires) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCustomerBalance { +pub struct CreatePaymentMethodConfigurationCartesBancaires { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: - Option<UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationCartesBancairesDisplayPreference>, } -impl UpdatePaymentMethodConfigurationCustomerBalance { +impl CreatePaymentMethodConfigurationCartesBancaires { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreference { +pub struct CreatePaymentMethodConfigurationCartesBancairesDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreference { +impl CreatePaymentMethodConfigurationCartesBancairesDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4174,12 +3779,10 @@ impl UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference } } -impl std::str::FromStr - for UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl std::str::FromStr for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4188,24 +3791,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl std::fmt::Display for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl std::fmt::Debug for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference -{ +impl serde::Serialize for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4213,42 +3810,41 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -/// EPS is an Austria-based payment method that allows customers to complete transactions online using their bank credentials. -/// EPS is supported by all Austrian banks and is accepted by over 80% of Austrian online retailers. -/// Check this [page](https://stripe.com/docs/payments/eps) for more details. +/// Cash App is a popular consumer app in the US that allows customers to bank, invest, send, and receive money using their digital wallet. +/// Check this [page](https://stripe.com/docs/payments/cash-app-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationEps { +pub struct CreatePaymentMethodConfigurationCashapp { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationEpsDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationCashappDisplayPreference>, } -impl UpdatePaymentMethodConfigurationEps { +impl CreatePaymentMethodConfigurationCashapp { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationEpsDisplayPreference { +pub struct CreatePaymentMethodConfigurationCashappDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationCashappDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationEpsDisplayPreference { +impl CreatePaymentMethodConfigurationCashappDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4257,10 +3853,10 @@ impl UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationCashappDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4269,18 +3865,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationEpsDisplayPreferenceP } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4288,43 +3884,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationEpsDisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// Financial Process Exchange (FPX) is a Malaysia-based payment method that allows customers to complete transactions online using their bank credentials. -/// Bank Negara Malaysia (BNM), the Central Bank of Malaysia, and eleven other major Malaysian financial institutions are members of the PayNet Group, which owns and operates FPX. -/// It is one of the most popular online payment methods in Malaysia, with nearly 90 million transactions in 2018 according to BNM. -/// Check this [page](https://stripe.com/docs/payments/fpx) for more details. +/// EPS is an Austria-based payment method that allows customers to complete transactions online using their bank credentials. +/// EPS is supported by all Austrian banks and is accepted by over 80% of Austrian online retailers. +/// Check this [page](https://stripe.com/docs/payments/eps) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationFpx { +pub struct CreatePaymentMethodConfigurationEps { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationFpxDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationEpsDisplayPreference>, } -impl UpdatePaymentMethodConfigurationFpx { +impl CreatePaymentMethodConfigurationEps { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationFpxDisplayPreference { +pub struct CreatePaymentMethodConfigurationEpsDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationEpsDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationFpxDisplayPreference { +impl CreatePaymentMethodConfigurationEpsDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4333,10 +3928,10 @@ impl UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationEpsDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4345,18 +3940,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationFpxDisplayPreferenceP } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4364,44 +3959,43 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationFpxDisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// giropay is a German payment method based on online banking, introduced in 2006. -/// It allows customers to complete transactions online using their online banking environment, with funds debited from their bank account. -/// Depending on their bank, customers confirm payments on giropay using a second factor of authentication or a PIN. -/// giropay accounts for 10% of online checkouts in Germany. -/// Check this [page](https://stripe.com/docs/payments/giropay) for more details. +/// Financial Process Exchange (FPX) is a Malaysia-based payment method that allows customers to complete transactions online using their bank credentials. +/// Bank Negara Malaysia (BNM), the Central Bank of Malaysia, and eleven other major Malaysian financial institutions are members of the PayNet Group, which owns and operates FPX. +/// It is one of the most popular online payment methods in Malaysia, with nearly 90 million transactions in 2018 according to BNM. +/// Check this [page](https://stripe.com/docs/payments/fpx) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationGiropay { +pub struct CreatePaymentMethodConfigurationFpx { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationGiropayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationFpxDisplayPreference>, } -impl UpdatePaymentMethodConfigurationGiropay { +impl CreatePaymentMethodConfigurationFpx { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationGiropayDisplayPreference { +pub struct CreatePaymentMethodConfigurationFpxDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationFpxDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationGiropayDisplayPreference { +impl CreatePaymentMethodConfigurationFpxDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4410,10 +4004,10 @@ impl UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationFpxDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4422,18 +4016,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationGiropayDisplayPrefere } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4441,42 +4035,44 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationGiropayDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. -/// Use the Google Pay API to request any credit or debit card stored in your customer's Google account. -/// Check this [page](https://stripe.com/docs/google-pay) for more details. +/// giropay is a German payment method based on online banking, introduced in 2006. +/// It allows customers to complete transactions online using their online banking environment, with funds debited from their bank account. +/// Depending on their bank, customers confirm payments on giropay using a second factor of authentication or a PIN. +/// giropay accounts for 10% of online checkouts in Germany. +/// Check this [page](https://stripe.com/docs/payments/giropay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationGooglePay { +pub struct CreatePaymentMethodConfigurationGiropay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationGooglePayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationGiropayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationGooglePay { +impl CreatePaymentMethodConfigurationGiropay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationGooglePayDisplayPreference { +pub struct CreatePaymentMethodConfigurationGiropayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationGooglePayDisplayPreference { +impl CreatePaymentMethodConfigurationGiropayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4485,10 +4081,10 @@ impl UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4497,18 +4093,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationGooglePayDisplayPrefe } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4516,42 +4112,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationGooglePayDisplayPrefer serializer.serialize_str(self.as_str()) } } -/// GrabPay is a payment method developed by [Grab](https://www.grab.com/sg/consumer/finance/pay/). -/// GrabPay is a digital wallet - customers maintain a balance in their wallets that they pay out with. -/// Check this [page](https://stripe.com/docs/payments/grabpay) for more details. +/// Google Pay allows customers to make payments in your app or website using any credit or debit card saved to their Google Account, including those from Google Play, YouTube, Chrome, or an Android device. +/// Use the Google Pay API to request any credit or debit card stored in your customer's Google account. +/// Check this [page](https://stripe.com/docs/google-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationGrabpay { +pub struct CreatePaymentMethodConfigurationGooglePay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationGrabpayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationGooglePayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationGrabpay { +impl CreatePaymentMethodConfigurationGooglePay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationGrabpayDisplayPreference { +pub struct CreatePaymentMethodConfigurationGooglePayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationGrabpayDisplayPreference { +impl CreatePaymentMethodConfigurationGooglePayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4560,10 +4156,10 @@ impl UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4572,18 +4168,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationGrabpayDisplayPrefere } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4591,42 +4187,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationGrabpayDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// iDEAL is a Netherlands-based payment method that allows customers to complete transactions online using their bank credentials. -/// All major Dutch banks are members of Currence, the scheme that operates iDEAL, making it the most popular online payment method in the Netherlands with a share of online transactions close to 55%. -/// Check this [page](https://stripe.com/docs/payments/ideal) for more details. +/// GrabPay is a payment method developed by [Grab](https://www.grab.com/sg/consumer/finance/pay/). +/// GrabPay is a digital wallet - customers maintain a balance in their wallets that they pay out with. +/// Check this [page](https://stripe.com/docs/payments/grabpay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationIdeal { +pub struct CreatePaymentMethodConfigurationGrabpay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationIdealDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationGrabpayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationIdeal { +impl CreatePaymentMethodConfigurationGrabpay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationIdealDisplayPreference { +pub struct CreatePaymentMethodConfigurationGrabpayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationIdealDisplayPreference { +impl CreatePaymentMethodConfigurationGrabpayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4635,10 +4231,10 @@ impl UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4647,18 +4243,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationIdealDisplayPreferenc } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4666,42 +4262,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationIdealDisplayPreference serializer.serialize_str(self.as_str()) } } -/// JCB is a credit card company based in Japan. -/// JCB is currently available in Japan to businesses approved by JCB, and available to all businesses in Australia, Canada, Hong Kong, Japan, New Zealand, Singapore, Switzerland, United Kingdom, United States, and all countries in the European Economic Area except Iceland. -/// Check this [page](https://support.stripe.com/questions/accepting-japan-credit-bureau-%28jcb%29-payments) for more details. +/// iDEAL is a Netherlands-based payment method that allows customers to complete transactions online using their bank credentials. +/// All major Dutch banks are members of Currence, the scheme that operates iDEAL, making it the most popular online payment method in the Netherlands with a share of online transactions close to 55%. +/// Check this [page](https://stripe.com/docs/payments/ideal) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationJcb { +pub struct CreatePaymentMethodConfigurationIdeal { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationJcbDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationIdealDisplayPreference>, } -impl UpdatePaymentMethodConfigurationJcb { +impl CreatePaymentMethodConfigurationIdeal { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationJcbDisplayPreference { +pub struct CreatePaymentMethodConfigurationIdealDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationIdealDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationJcbDisplayPreference { +impl CreatePaymentMethodConfigurationIdealDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4710,10 +4306,10 @@ impl UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationIdealDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4722,18 +4318,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationJcbDisplayPreferenceP } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4741,43 +4337,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationJcbDisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// Klarna gives customers a range of [payment options](https://stripe.com/docs/payments/klarna#payment-options) during checkout. -/// Available payment options vary depending on the customer's billing address and the transaction amount. -/// These payment options make it convenient for customers to purchase items in all price ranges. -/// Check this [page](https://stripe.com/docs/payments/klarna) for more details. +/// JCB is a credit card company based in Japan. +/// JCB is currently available in Japan to businesses approved by JCB, and available to all businesses in Australia, Canada, Hong Kong, Japan, New Zealand, Singapore, Switzerland, United Kingdom, United States, and all countries in the European Economic Area except Iceland. +/// Check this [page](https://support.stripe.com/questions/accepting-japan-credit-bureau-%28jcb%29-payments) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationKlarna { +pub struct CreatePaymentMethodConfigurationJcb { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationKlarnaDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationJcbDisplayPreference>, } -impl UpdatePaymentMethodConfigurationKlarna { +impl CreatePaymentMethodConfigurationJcb { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationKlarnaDisplayPreference { +pub struct CreatePaymentMethodConfigurationJcbDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationJcbDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationKlarnaDisplayPreference { +impl CreatePaymentMethodConfigurationJcbDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4786,10 +4381,10 @@ impl UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationJcbDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4798,18 +4393,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationKlarnaDisplayPreferen } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4817,41 +4412,43 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationKlarnaDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// Konbini allows customers in Japan to pay for bills and online purchases at convenience stores with cash. -/// Check this [page](https://stripe.com/docs/payments/konbini) for more details. +/// Klarna gives customers a range of [payment options](https://stripe.com/docs/payments/klarna#payment-options) during checkout. +/// Available payment options vary depending on the customer's billing address and the transaction amount. +/// These payment options make it convenient for customers to purchase items in all price ranges. +/// Check this [page](https://stripe.com/docs/payments/klarna) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationKonbini { +pub struct CreatePaymentMethodConfigurationKlarna { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationKonbiniDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationKlarnaDisplayPreference>, } -impl UpdatePaymentMethodConfigurationKonbini { +impl CreatePaymentMethodConfigurationKlarna { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationKonbiniDisplayPreference { +pub struct CreatePaymentMethodConfigurationKlarnaDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationKonbiniDisplayPreference { +impl CreatePaymentMethodConfigurationKlarnaDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4860,10 +4457,10 @@ impl UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4872,18 +4469,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationKonbiniDisplayPrefere } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4891,41 +4488,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationKonbiniDisplayPreferen serializer.serialize_str(self.as_str()) } } -/// [Link](https://stripe.com/docs/payments/link) is a payment method network. -/// With Link, users save their payment details once, then reuse that information to pay with one click for any business on the network. +/// Konbini allows customers in Japan to pay for bills and online purchases at convenience stores with cash. +/// Check this [page](https://stripe.com/docs/payments/konbini) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationLink { +pub struct CreatePaymentMethodConfigurationKonbini { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationLinkDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationKonbiniDisplayPreference>, } -impl UpdatePaymentMethodConfigurationLink { +impl CreatePaymentMethodConfigurationKonbini { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationLinkDisplayPreference { +pub struct CreatePaymentMethodConfigurationKonbiniDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationLinkDisplayPreference { +impl CreatePaymentMethodConfigurationKonbiniDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -4934,10 +4531,10 @@ impl UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -4946,18 +4543,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationLinkDisplayPreference } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -4965,42 +4562,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationLinkDisplayPreferenceP serializer.serialize_str(self.as_str()) } } -/// OXXO is a Mexican chain of convenience stores with thousands of locations across Latin America and represents nearly 20% of online transactions in Mexico. -/// OXXO allows customers to pay bills and online purchases in-store with cash. -/// Check this [page](https://stripe.com/docs/payments/oxxo) for more details. +/// [Link](https://stripe.com/docs/payments/link) is a payment method network. +/// With Link, users save their payment details once, then reuse that information to pay with one click for any business on the network. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationOxxo { +pub struct CreatePaymentMethodConfigurationLink { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationOxxoDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationLinkDisplayPreference>, } -impl UpdatePaymentMethodConfigurationOxxo { +impl CreatePaymentMethodConfigurationLink { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationOxxoDisplayPreference { +pub struct CreatePaymentMethodConfigurationLinkDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationLinkDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationOxxoDisplayPreference { +impl CreatePaymentMethodConfigurationLinkDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5009,10 +4605,10 @@ impl UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationLinkDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5021,61 +4617,61 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationOxxoDisplayPreference } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { serializer.serialize_str(self.as_str()) } -} -/// Przelewy24 is a Poland-based payment method aggregator that allows customers to complete transactions online using bank transfers and other methods. -/// Bank transfers account for 30% of online payments in Poland and Przelewy24 provides a way for customers to pay with over 165 banks. -/// Check this [page](https://stripe.com/docs/payments/p24) for more details. +} +/// OXXO is a Mexican chain of convenience stores with thousands of locations across Latin America and represents nearly 20% of online transactions in Mexico. +/// OXXO allows customers to pay bills and online purchases in-store with cash. +/// Check this [page](https://stripe.com/docs/payments/oxxo) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationP24 { +pub struct CreatePaymentMethodConfigurationOxxo { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationP24DisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationOxxoDisplayPreference>, } -impl UpdatePaymentMethodConfigurationP24 { +impl CreatePaymentMethodConfigurationOxxo { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationP24DisplayPreference { +pub struct CreatePaymentMethodConfigurationOxxoDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationP24DisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationP24DisplayPreference { +impl CreatePaymentMethodConfigurationOxxoDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationP24DisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5084,10 +4680,10 @@ impl UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationP24DisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5096,18 +4692,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationP24DisplayPreferenceP } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5115,41 +4711,42 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationP24DisplayPreferencePr serializer.serialize_str(self.as_str()) } } -/// PayNow is a Singapore-based payment method that allows customers to make a payment using their preferred app from participating banks and participating non-bank financial institutions. -/// Check this [page](https://stripe.com/docs/payments/paynow) for more details. +/// Przelewy24 is a Poland-based payment method aggregator that allows customers to complete transactions online using bank transfers and other methods. +/// Bank transfers account for 30% of online payments in Poland and Przelewy24 provides a way for customers to pay with over 165 banks. +/// Check this [page](https://stripe.com/docs/payments/p24) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationPaynow { +pub struct CreatePaymentMethodConfigurationP24 { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationPaynowDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationP24DisplayPreference>, } -impl UpdatePaymentMethodConfigurationPaynow { +impl CreatePaymentMethodConfigurationP24 { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationPaynowDisplayPreference { +pub struct CreatePaymentMethodConfigurationP24DisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationP24DisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationPaynowDisplayPreference { +impl CreatePaymentMethodConfigurationP24DisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationP24DisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationP24DisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationP24DisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5158,10 +4755,10 @@ impl UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationP24DisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5170,18 +4767,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationPaynowDisplayPreferen } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationP24DisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5189,41 +4786,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationPaynowDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// PayPal, a digital wallet popular with customers in Europe, allows your customers worldwide to pay using their PayPal account. -/// Check this [page](https://stripe.com/docs/payments/paypal) for more details. +/// PayNow is a Singapore-based payment method that allows customers to make a payment using their preferred app from participating banks and participating non-bank financial institutions. +/// Check this [page](https://stripe.com/docs/payments/paynow) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationPaypal { +pub struct CreatePaymentMethodConfigurationPaynow { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationPaypalDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationPaynowDisplayPreference>, } -impl UpdatePaymentMethodConfigurationPaypal { +impl CreatePaymentMethodConfigurationPaynow { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationPaypalDisplayPreference { +pub struct CreatePaymentMethodConfigurationPaynowDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationPaypalDisplayPreference { +impl CreatePaymentMethodConfigurationPaynowDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5232,10 +4829,10 @@ impl UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5244,18 +4841,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationPaypalDisplayPreferen } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5263,41 +4860,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationPaypalDisplayPreferenc serializer.serialize_str(self.as_str()) } } -/// PromptPay is a Thailand-based payment method that allows customers to make a payment using their preferred app from participating banks. -/// Check this [page](https://stripe.com/docs/payments/promptpay) for more details. +/// PayPal, a digital wallet popular with customers in Europe, allows your customers worldwide to pay using their PayPal account. +/// Check this [page](https://stripe.com/docs/payments/paypal) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationPromptpay { +pub struct CreatePaymentMethodConfigurationPaypal { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationPromptpayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationPaypalDisplayPreference>, } -impl UpdatePaymentMethodConfigurationPromptpay { +impl CreatePaymentMethodConfigurationPaypal { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationPromptpayDisplayPreference { +pub struct CreatePaymentMethodConfigurationPaypalDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationPromptpayDisplayPreference { +impl CreatePaymentMethodConfigurationPaypalDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5306,10 +4903,10 @@ impl UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5318,18 +4915,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationPromptpayDisplayPrefe } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5337,41 +4934,41 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationPromptpayDisplayPrefer serializer.serialize_str(self.as_str()) } } -/// Revolut Pay, developed by Revolut, a global finance app, is a digital wallet payment method. -/// Revolut Pay uses the customer’s stored balance or cards to fund the payment, and offers the option for non-Revolut customers to save their details after their first purchase. +/// PromptPay is a Thailand-based payment method that allows customers to make a payment using their preferred app from participating banks. +/// Check this [page](https://stripe.com/docs/payments/promptpay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationRevolutPay { +pub struct CreatePaymentMethodConfigurationPromptpay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationRevolutPayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationPromptpayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationRevolutPay { +impl CreatePaymentMethodConfigurationPromptpay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationRevolutPayDisplayPreference { +pub struct CreatePaymentMethodConfigurationPromptpayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationRevolutPayDisplayPreference { +impl CreatePaymentMethodConfigurationPromptpayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5380,10 +4977,10 @@ impl UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5392,18 +4989,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationRevolutPayDisplayPref } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5414,38 +5011,38 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationRevolutPayDisplayPrefe /// The [Single Euro Payments Area (SEPA)](https://en.wikipedia.org/wiki/Single_Euro_Payments_Area) is an initiative of the European Union to simplify payments within and across member countries. /// SEPA established and enforced banking standards to allow for the direct debiting of every EUR-denominated bank account within the SEPA region, check this [page](https://stripe.com/docs/payments/sepa-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationSepaDebit { +pub struct CreatePaymentMethodConfigurationSepaDebit { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationSepaDebitDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationSepaDebitDisplayPreference>, } -impl UpdatePaymentMethodConfigurationSepaDebit { +impl CreatePaymentMethodConfigurationSepaDebit { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationSepaDebitDisplayPreference { +pub struct CreatePaymentMethodConfigurationSepaDebitDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationSepaDebitDisplayPreference { +impl CreatePaymentMethodConfigurationSepaDebitDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5454,10 +5051,10 @@ impl UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5466,18 +5063,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationSepaDebitDisplayPrefe } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5488,38 +5085,38 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationSepaDebitDisplayPrefer /// Stripe users in Europe and the United States can use the [Payment Intents API](https://stripe.com/docs/payments/payment-intents)—a single integration path for creating payments using any supported method—to accept [Sofort](https://www.sofort.com/) payments from customers. /// Check this [page](https://stripe.com/docs/payments/sofort) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationSofort { +pub struct CreatePaymentMethodConfigurationSofort { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationSofortDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationSofortDisplayPreference>, } -impl UpdatePaymentMethodConfigurationSofort { +impl CreatePaymentMethodConfigurationSofort { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationSofortDisplayPreference { +pub struct CreatePaymentMethodConfigurationSofortDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationSofortDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationSofortDisplayPreference { +impl CreatePaymentMethodConfigurationSofortDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5528,10 +5125,10 @@ impl UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationSofortDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5540,18 +5137,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationSofortDisplayPreferen } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5562,39 +5159,38 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationSofortDisplayPreferenc /// Stripe users in the United States can accept ACH direct debit payments from customers with a US bank account using the Automated Clearing House (ACH) payments system operated by Nacha. /// Check this [page](https://stripe.com/docs/payments/ach-debit) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationUsBankAccount { +pub struct CreatePaymentMethodConfigurationUsBankAccount { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationUsBankAccountDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationUsBankAccountDisplayPreference>, } -impl UpdatePaymentMethodConfigurationUsBankAccount { +impl CreatePaymentMethodConfigurationUsBankAccount { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationUsBankAccountDisplayPreference { +pub struct CreatePaymentMethodConfigurationUsBankAccountDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: - Option<UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationUsBankAccountDisplayPreference { +impl CreatePaymentMethodConfigurationUsBankAccountDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5603,12 +5199,10 @@ impl UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { } } -impl std::str::FromStr - for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference -{ +impl std::str::FromStr for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5617,20 +5211,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference -{ +impl std::fmt::Display for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5643,38 +5235,38 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationUsBankAccountDisplayPr /// WeChat Pay users buy most frequently in gaming, e-commerce, travel, online education, and food/nutrition. /// Check this [page](https://stripe.com/docs/payments/wechat-pay) for more details. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationWechatPay { +pub struct CreatePaymentMethodConfigurationWechatPay { /// Whether or not the payment method should be displayed. #[serde(skip_serializing_if = "Option::is_none")] - pub display_preference: Option<UpdatePaymentMethodConfigurationWechatPayDisplayPreference>, + pub display_preference: Option<CreatePaymentMethodConfigurationWechatPayDisplayPreference>, } -impl UpdatePaymentMethodConfigurationWechatPay { +impl CreatePaymentMethodConfigurationWechatPay { pub fn new() -> Self { Self::default() } } /// Whether or not the payment method should be displayed. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentMethodConfigurationWechatPayDisplayPreference { +pub struct CreatePaymentMethodConfigurationWechatPayDisplayPreference { /// The account's preference for whether or not to display this payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub preference: Option<UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference>, + pub preference: Option<CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference>, } -impl UpdatePaymentMethodConfigurationWechatPayDisplayPreference { +impl CreatePaymentMethodConfigurationWechatPayDisplayPreference { pub fn new() -> Self { Self::default() } } /// The account's preference for whether or not to display this payment method. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +pub enum CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { None, Off, On, } -impl UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { pub fn as_str(self) -> &'static str { - use UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; match self { None => "none", Off => "off", @@ -5683,10 +5275,10 @@ impl UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { } } -impl std::str::FromStr for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl std::str::FromStr for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { - use UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; + use CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference::*; match s { "none" => Ok(None), "off" => Ok(Off), @@ -5695,18 +5287,18 @@ impl std::str::FromStr for UpdatePaymentMethodConfigurationWechatPayDisplayPrefe } } } -impl std::fmt::Display for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl std::fmt::Display for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl std::fmt::Debug for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { +impl serde::Serialize for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -5714,17 +5306,9 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationWechatPayDisplayPrefer serializer.serialize_str(self.as_str()) } } -impl<'a> UpdatePaymentMethodConfiguration<'a> { - /// Update payment method configuration - pub fn send( - &self, - client: &stripe::Client, - configuration: &stripe_payment::PaymentMethodConfigurationId, - ) -> stripe::Response<stripe_payment::PaymentMethodConfiguration> { - client.send_form( - &format!("/payment_method_configurations/{configuration}"), - self, - http_types::Method::Post, - ) +impl<'a> CreatePaymentMethodConfiguration<'a> { + /// Creates a payment method configuration + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_payment::PaymentMethodConfiguration> { + client.send_form("/payment_method_configurations", self, http_types::Method::Post) } } diff --git a/generated/stripe_payment/src/payment_method_configuration/types.rs b/generated/stripe_payment/src/payment_method_configuration/types.rs index 2dd733767..289e78096 100644 --- a/generated/stripe_payment/src/payment_method_configuration/types.rs +++ b/generated/stripe_payment/src/payment_method_configuration/types.rs @@ -18,94 +18,410 @@ /// - [Multiple configurations for your Connect accounts](https://stripe.com/docs/connect/multiple-payment-method-configurations). /// /// For more details see <<https://stripe.com/docs/api/payment_method_configurations/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodConfiguration { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, /// Whether the configuration can be used for new payments. pub active: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: - Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] + pub afterpay_clearpay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, pub alipay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub apple_pay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, /// For child configs, the Connect application associated with the configuration. pub application: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] - pub cartes_bancaires: - Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] + pub cartes_bancaires: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, pub cashapp: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: - Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, /// Unique identifier for the object. pub id: stripe_payment::PaymentMethodConfigurationId, - #[serde(skip_serializing_if = "Option::is_none")] + pub id_bank_transfer: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, pub ideal: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, /// The default configuration is used whenever a payment method configuration is not specified. pub is_default: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub jcb: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, + pub multibanco: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, /// The configuration's name. pub name: String, - #[serde(skip_serializing_if = "Option::is_none")] + pub netbanking: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, pub oxxo: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, /// For child configs, the configuration's parent configuration. pub parent: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] + pub pay_by_bank: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, pub paynow: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] + pub upi: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, pub us_bank_account: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodConfigurationBuilder { + acss_debit: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + active: Option<bool>, + affirm: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + afterpay_clearpay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + alipay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + apple_pay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + application: Option<Option<String>>, + au_becs_debit: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + bacs_debit: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + bancontact: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + blik: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + boleto: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + card: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + cartes_bancaires: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + cashapp: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + eps: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + fpx: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + giropay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + google_pay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + grabpay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + id: Option<stripe_payment::PaymentMethodConfigurationId>, + id_bank_transfer: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + ideal: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + is_default: Option<bool>, + jcb: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + klarna: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + konbini: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + link: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + livemode: Option<bool>, + multibanco: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + name: Option<String>, + netbanking: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + oxxo: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + p24: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + parent: Option<Option<String>>, + pay_by_bank: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + paynow: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + paypal: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + promptpay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + sepa_debit: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + sofort: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + upi: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + us_bank_account: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, + wechat_pay: Option<Option<stripe_payment::PaymentMethodConfigResourcePaymentMethodProperties>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodConfiguration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodConfiguration>, + builder: PaymentMethodConfigurationBuilder, + } + + impl Visitor for Place<PaymentMethodConfiguration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodConfigurationBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodConfigurationBuilder { + type Out = PaymentMethodConfiguration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "active" => Deserialize::begin(&mut self.active), + "affirm" => Deserialize::begin(&mut self.affirm), + "afterpay_clearpay" => Deserialize::begin(&mut self.afterpay_clearpay), + "alipay" => Deserialize::begin(&mut self.alipay), + "apple_pay" => Deserialize::begin(&mut self.apple_pay), + "application" => Deserialize::begin(&mut self.application), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "blik" => Deserialize::begin(&mut self.blik), + "boleto" => Deserialize::begin(&mut self.boleto), + "card" => Deserialize::begin(&mut self.card), + "cartes_bancaires" => Deserialize::begin(&mut self.cartes_bancaires), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "eps" => Deserialize::begin(&mut self.eps), + "fpx" => Deserialize::begin(&mut self.fpx), + "giropay" => Deserialize::begin(&mut self.giropay), + "google_pay" => Deserialize::begin(&mut self.google_pay), + "grabpay" => Deserialize::begin(&mut self.grabpay), + "id" => Deserialize::begin(&mut self.id), + "id_bank_transfer" => Deserialize::begin(&mut self.id_bank_transfer), + "ideal" => Deserialize::begin(&mut self.ideal), + "is_default" => Deserialize::begin(&mut self.is_default), + "jcb" => Deserialize::begin(&mut self.jcb), + "klarna" => Deserialize::begin(&mut self.klarna), + "konbini" => Deserialize::begin(&mut self.konbini), + "link" => Deserialize::begin(&mut self.link), + "livemode" => Deserialize::begin(&mut self.livemode), + "multibanco" => Deserialize::begin(&mut self.multibanco), + "name" => Deserialize::begin(&mut self.name), + "netbanking" => Deserialize::begin(&mut self.netbanking), + "oxxo" => Deserialize::begin(&mut self.oxxo), + "p24" => Deserialize::begin(&mut self.p24), + "parent" => Deserialize::begin(&mut self.parent), + "pay_by_bank" => Deserialize::begin(&mut self.pay_by_bank), + "paynow" => Deserialize::begin(&mut self.paynow), + "paypal" => Deserialize::begin(&mut self.paypal), + "promptpay" => Deserialize::begin(&mut self.promptpay), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "sofort" => Deserialize::begin(&mut self.sofort), + "upi" => Deserialize::begin(&mut self.upi), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + "wechat_pay" => Deserialize::begin(&mut self.wechat_pay), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + active: Deserialize::default(), + affirm: Deserialize::default(), + afterpay_clearpay: Deserialize::default(), + alipay: Deserialize::default(), + apple_pay: Deserialize::default(), + application: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bacs_debit: Deserialize::default(), + bancontact: Deserialize::default(), + blik: Deserialize::default(), + boleto: Deserialize::default(), + card: Deserialize::default(), + cartes_bancaires: Deserialize::default(), + cashapp: Deserialize::default(), + eps: Deserialize::default(), + fpx: Deserialize::default(), + giropay: Deserialize::default(), + google_pay: Deserialize::default(), + grabpay: Deserialize::default(), + id: Deserialize::default(), + id_bank_transfer: Deserialize::default(), + ideal: Deserialize::default(), + is_default: Deserialize::default(), + jcb: Deserialize::default(), + klarna: Deserialize::default(), + konbini: Deserialize::default(), + link: Deserialize::default(), + livemode: Deserialize::default(), + multibanco: Deserialize::default(), + name: Deserialize::default(), + netbanking: Deserialize::default(), + oxxo: Deserialize::default(), + p24: Deserialize::default(), + parent: Deserialize::default(), + pay_by_bank: Deserialize::default(), + paynow: Deserialize::default(), + paypal: Deserialize::default(), + promptpay: Deserialize::default(), + sepa_debit: Deserialize::default(), + sofort: Deserialize::default(), + upi: Deserialize::default(), + us_bank_account: Deserialize::default(), + wechat_pay: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let active = self.active.take()?; + let affirm = self.affirm.take()?; + let afterpay_clearpay = self.afterpay_clearpay.take()?; + let alipay = self.alipay.take()?; + let apple_pay = self.apple_pay.take()?; + let application = self.application.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bacs_debit = self.bacs_debit.take()?; + let bancontact = self.bancontact.take()?; + let blik = self.blik.take()?; + let boleto = self.boleto.take()?; + let card = self.card.take()?; + let cartes_bancaires = self.cartes_bancaires.take()?; + let cashapp = self.cashapp.take()?; + let eps = self.eps.take()?; + let fpx = self.fpx.take()?; + let giropay = self.giropay.take()?; + let google_pay = self.google_pay.take()?; + let grabpay = self.grabpay.take()?; + let id = self.id.take()?; + let id_bank_transfer = self.id_bank_transfer.take()?; + let ideal = self.ideal.take()?; + let is_default = self.is_default.take()?; + let jcb = self.jcb.take()?; + let klarna = self.klarna.take()?; + let konbini = self.konbini.take()?; + let link = self.link.take()?; + let livemode = self.livemode.take()?; + let multibanco = self.multibanco.take()?; + let name = self.name.take()?; + let netbanking = self.netbanking.take()?; + let oxxo = self.oxxo.take()?; + let p24 = self.p24.take()?; + let parent = self.parent.take()?; + let pay_by_bank = self.pay_by_bank.take()?; + let paynow = self.paynow.take()?; + let paypal = self.paypal.take()?; + let promptpay = self.promptpay.take()?; + let sepa_debit = self.sepa_debit.take()?; + let sofort = self.sofort.take()?; + let upi = self.upi.take()?; + let us_bank_account = self.us_bank_account.take()?; + let wechat_pay = self.wechat_pay.take()?; + + Some(Self::Out { + acss_debit, + active, + affirm, + afterpay_clearpay, + alipay, + apple_pay, + application, + au_becs_debit, + bacs_debit, + bancontact, + blik, + boleto, + card, + cartes_bancaires, + cashapp, + eps, + fpx, + giropay, + google_pay, + grabpay, + id, + id_bank_transfer, + ideal, + is_default, + jcb, + klarna, + konbini, + link, + livemode, + multibanco, + name, + netbanking, + oxxo, + p24, + parent, + pay_by_bank, + paynow, + paypal, + promptpay, + sepa_debit, + sofort, + upi, + us_bank_account, + wechat_pay, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodConfiguration { + type Builder = PaymentMethodConfigurationBuilder; + } + + impl FromValueOpt for PaymentMethodConfiguration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodConfigurationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "affirm" => b.affirm = Some(FromValueOpt::from_value(v)?), + "afterpay_clearpay" => b.afterpay_clearpay = Some(FromValueOpt::from_value(v)?), + "alipay" => b.alipay = Some(FromValueOpt::from_value(v)?), + "apple_pay" => b.apple_pay = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "blik" => b.blik = Some(FromValueOpt::from_value(v)?), + "boleto" => b.boleto = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "cartes_bancaires" => b.cartes_bancaires = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "eps" => b.eps = Some(FromValueOpt::from_value(v)?), + "fpx" => b.fpx = Some(FromValueOpt::from_value(v)?), + "giropay" => b.giropay = Some(FromValueOpt::from_value(v)?), + "google_pay" => b.google_pay = Some(FromValueOpt::from_value(v)?), + "grabpay" => b.grabpay = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "id_bank_transfer" => b.id_bank_transfer = Some(FromValueOpt::from_value(v)?), + "ideal" => b.ideal = Some(FromValueOpt::from_value(v)?), + "is_default" => b.is_default = Some(FromValueOpt::from_value(v)?), + "jcb" => b.jcb = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "konbini" => b.konbini = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "multibanco" => b.multibanco = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "netbanking" => b.netbanking = Some(FromValueOpt::from_value(v)?), + "oxxo" => b.oxxo = Some(FromValueOpt::from_value(v)?), + "p24" => b.p24 = Some(FromValueOpt::from_value(v)?), + "parent" => b.parent = Some(FromValueOpt::from_value(v)?), + "pay_by_bank" => b.pay_by_bank = Some(FromValueOpt::from_value(v)?), + "paynow" => b.paynow = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "promptpay" => b.promptpay = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "upi" => b.upi = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + "wechat_pay" => b.wechat_pay = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for PaymentMethodConfiguration { type Id = stripe_payment::PaymentMethodConfigurationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_payment/src/payment_method_domain/requests.rs b/generated/stripe_payment/src/payment_method_domain/requests.rs index 15a45c4a2..61f357808 100644 --- a/generated/stripe_payment/src/payment_method_domain/requests.rs +++ b/generated/stripe_payment/src/payment_method_domain/requests.rs @@ -1,4 +1,21 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrievePaymentMethodDomain<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrievePaymentMethodDomain<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrievePaymentMethodDomain<'a> { + /// Retrieves the details of an existing payment method domain. + pub fn send(&self, client: &stripe::Client, payment_method_domain: &stripe_payment::PaymentMethodDomainId) -> stripe::Response<stripe_payment::PaymentMethodDomain> { + client.get_query(&format!("/payment_method_domains/{payment_method_domain}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListPaymentMethodDomain<'a> { /// The domain name that this payment method domain object represents. #[serde(skip_serializing_if = "Option::is_none")] @@ -32,39 +49,13 @@ impl<'a> ListPaymentMethodDomain<'a> { } impl<'a> ListPaymentMethodDomain<'a> { /// Lists the details of existing payment method domains. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_payment::PaymentMethodDomain>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_payment::PaymentMethodDomain>> { client.get_query("/payment_method_domains", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_payment::PaymentMethodDomain>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_payment::PaymentMethodDomain>> { stripe::ListPaginator::from_list_params("/payment_method_domains", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrievePaymentMethodDomain<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrievePaymentMethodDomain<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrievePaymentMethodDomain<'a> { - /// Retrieves the details of an existing payment method domain. - pub fn send( - &self, - client: &stripe::Client, - payment_method_domain: &stripe_payment::PaymentMethodDomainId, - ) -> stripe::Response<stripe_payment::PaymentMethodDomain> { - client.get_query(&format!("/payment_method_domains/{payment_method_domain}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentMethodDomain<'a> { /// The domain name that this payment method domain object represents. @@ -84,10 +75,7 @@ impl<'a> CreatePaymentMethodDomain<'a> { } impl<'a> CreatePaymentMethodDomain<'a> { /// Creates a payment method domain. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_payment::PaymentMethodDomain> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_payment::PaymentMethodDomain> { client.send_form("/payment_method_domains", self, http_types::Method::Post) } } @@ -108,16 +96,8 @@ impl<'a> UpdatePaymentMethodDomain<'a> { } impl<'a> UpdatePaymentMethodDomain<'a> { /// Updates an existing payment method domain. - pub fn send( - &self, - client: &stripe::Client, - payment_method_domain: &stripe_payment::PaymentMethodDomainId, - ) -> stripe::Response<stripe_payment::PaymentMethodDomain> { - client.send_form( - &format!("/payment_method_domains/{payment_method_domain}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, payment_method_domain: &stripe_payment::PaymentMethodDomainId) -> stripe::Response<stripe_payment::PaymentMethodDomain> { + client.send_form(&format!("/payment_method_domains/{payment_method_domain}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -139,15 +119,7 @@ impl<'a> ValidatePaymentMethodDomain<'a> { /// To activate a payment method on an existing payment method domain, complete the required validation steps specific to the payment method, and then validate the payment method domain with this endpoint. /// /// Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). - pub fn send( - &self, - client: &stripe::Client, - payment_method_domain: &stripe_payment::PaymentMethodDomainId, - ) -> stripe::Response<stripe_payment::PaymentMethodDomain> { - client.send_form( - &format!("/payment_method_domains/{payment_method_domain}/validate"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, payment_method_domain: &stripe_payment::PaymentMethodDomainId) -> stripe::Response<stripe_payment::PaymentMethodDomain> { + client.send_form(&format!("/payment_method_domains/{payment_method_domain}/validate"), self, http_types::Method::Post) } } diff --git a/generated/stripe_payment/src/payment_method_domain/types.rs b/generated/stripe_payment/src/payment_method_domain/types.rs index 432a94292..c5c28d0be 100644 --- a/generated/stripe_payment/src/payment_method_domain/types.rs +++ b/generated/stripe_payment/src/payment_method_domain/types.rs @@ -4,7 +4,9 @@ /// Related guides: [Payment method domains](https://stripe.com/docs/payments/payment-methods/pmd-registration). /// /// For more details see <<https://stripe.com/docs/api/payment_method_domains/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDomain { pub apple_pay: stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus, /// Time at which the object was created. Measured in seconds since the Unix epoch. @@ -22,6 +24,134 @@ pub struct PaymentMethodDomain { pub livemode: bool, pub paypal: stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDomainBuilder { + apple_pay: Option<stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus>, + created: Option<stripe_types::Timestamp>, + domain_name: Option<String>, + enabled: Option<bool>, + google_pay: Option<stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus>, + id: Option<stripe_payment::PaymentMethodDomainId>, + link: Option<stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus>, + livemode: Option<bool>, + paypal: Option<stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDomain { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDomain>, + builder: PaymentMethodDomainBuilder, + } + + impl Visitor for Place<PaymentMethodDomain> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDomainBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDomainBuilder { + type Out = PaymentMethodDomain; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "apple_pay" => Deserialize::begin(&mut self.apple_pay), + "created" => Deserialize::begin(&mut self.created), + "domain_name" => Deserialize::begin(&mut self.domain_name), + "enabled" => Deserialize::begin(&mut self.enabled), + "google_pay" => Deserialize::begin(&mut self.google_pay), + "id" => Deserialize::begin(&mut self.id), + "link" => Deserialize::begin(&mut self.link), + "livemode" => Deserialize::begin(&mut self.livemode), + "paypal" => Deserialize::begin(&mut self.paypal), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + apple_pay: Deserialize::default(), + created: Deserialize::default(), + domain_name: Deserialize::default(), + enabled: Deserialize::default(), + google_pay: Deserialize::default(), + id: Deserialize::default(), + link: Deserialize::default(), + livemode: Deserialize::default(), + paypal: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let apple_pay = self.apple_pay.take()?; + let created = self.created.take()?; + let domain_name = self.domain_name.take()?; + let enabled = self.enabled.take()?; + let google_pay = self.google_pay.take()?; + let id = self.id.take()?; + let link = self.link.take()?; + let livemode = self.livemode.take()?; + let paypal = self.paypal.take()?; + + Some(Self::Out { apple_pay, created, domain_name, enabled, google_pay, id, link, livemode, paypal }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDomain { + type Builder = PaymentMethodDomainBuilder; + } + + impl FromValueOpt for PaymentMethodDomain { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDomainBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "apple_pay" => b.apple_pay = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "domain_name" => b.domain_name = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "google_pay" => b.google_pay = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for PaymentMethodDomain { type Id = stripe_payment::PaymentMethodDomainId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status.rs b/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status.rs index 1b8e2d061..380957fbb 100644 --- a/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status.rs +++ b/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status.rs @@ -1,12 +1,102 @@ /// Indicates the status of a specific payment method on a payment method domain. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDomainResourcePaymentMethodStatus { /// The status of the payment method on the domain. pub status: PaymentMethodDomainResourcePaymentMethodStatusStatus, - #[serde(skip_serializing_if = "Option::is_none")] - pub status_details: - Option<stripe_payment::PaymentMethodDomainResourcePaymentMethodStatusDetails>, + pub status_details: Option<stripe_payment::PaymentMethodDomainResourcePaymentMethodStatusDetails>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDomainResourcePaymentMethodStatusBuilder { + status: Option<PaymentMethodDomainResourcePaymentMethodStatusStatus>, + status_details: Option<Option<stripe_payment::PaymentMethodDomainResourcePaymentMethodStatusDetails>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDomainResourcePaymentMethodStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDomainResourcePaymentMethodStatus>, + builder: PaymentMethodDomainResourcePaymentMethodStatusBuilder, + } + + impl Visitor for Place<PaymentMethodDomainResourcePaymentMethodStatus> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDomainResourcePaymentMethodStatusBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDomainResourcePaymentMethodStatusBuilder { + type Out = PaymentMethodDomainResourcePaymentMethodStatus; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "status" => Deserialize::begin(&mut self.status), + "status_details" => Deserialize::begin(&mut self.status_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default(), status_details: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let status = self.status.take()?; + let status_details = self.status_details.take()?; + + Some(Self::Out { status, status_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDomainResourcePaymentMethodStatus { + type Builder = PaymentMethodDomainResourcePaymentMethodStatusBuilder; + } + + impl FromValueOpt for PaymentMethodDomainResourcePaymentMethodStatus { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDomainResourcePaymentMethodStatusBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_details" => b.status_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the payment method on the domain. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDomainResourcePaymentMethodStatusStatus { @@ -57,10 +147,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDomainResourcePaymentMethodSt fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDomainResourcePaymentMethodStatusStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDomainResourcePaymentMethodStatusStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDomainResourcePaymentMethodStatusStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDomainResourcePaymentMethodStatusStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDomainResourcePaymentMethodStatusStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDomainResourcePaymentMethodStatusStatus); diff --git a/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status_details.rs b/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status_details.rs index 07dcdc569..7da6cb216 100644 --- a/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status_details.rs +++ b/generated/stripe_payment/src/payment_method_domain_resource_payment_method_status_details.rs @@ -1,6 +1,94 @@ /// Contains additional details about the status of a payment method for a specific payment method domain. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDomainResourcePaymentMethodStatusDetails { /// The error message associated with the status of the payment method on the domain. pub error_message: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder { + error_message: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDomainResourcePaymentMethodStatusDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDomainResourcePaymentMethodStatusDetails>, + builder: PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder, + } + + impl Visitor for Place<PaymentMethodDomainResourcePaymentMethodStatusDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder { + type Out = PaymentMethodDomainResourcePaymentMethodStatusDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "error_message" => Deserialize::begin(&mut self.error_message), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { error_message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let error_message = self.error_message.take()?; + + Some(Self::Out { error_message }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDomainResourcePaymentMethodStatusDetails { + type Builder = PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder; + } + + impl FromValueOpt for PaymentMethodDomainResourcePaymentMethodStatusDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "error_message" => b.error_message = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_payment/src/source/requests.rs b/generated/stripe_payment/src/source/requests.rs index e8595713f..0fe4f718c 100644 --- a/generated/stripe_payment/src/source/requests.rs +++ b/generated/stripe_payment/src/source/requests.rs @@ -11,25 +11,90 @@ impl<'a> DetachSource<'a> { } impl<'a> DetachSource<'a> { /// Delete a specified source for a given customer. - pub fn send( - &self, - client: &stripe::Client, - customer: &stripe_shared::CustomerId, - id: &str, - ) -> stripe::Response<DetachSourceReturned> { - client.send_form( - &format!("/customers/{customer}/sources/{id}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] + pub fn send(&self, client: &stripe::Client, customer: &stripe_shared::CustomerId, id: &str) -> stripe::Response<DetachSourceReturned> { + client.send_form(&format!("/customers/{customer}/sources/{id}"), self, http_types::Method::Delete) + } +} +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum DetachSourceReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct DetachSourceReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<DetachSourceReturned>, + builder: DetachSourceReturnedBuilder, + } + + impl Deserialize for DetachSourceReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<DetachSourceReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for DetachSourceReturnedBuilder { + type Out = DetachSourceReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + DetachSourceReturned::DeletedPaymentSource(FromValueOpt::from_value(Value::Object(o))?) + } else { + DetachSourceReturned::PaymentSource(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for DetachSourceReturned { + type Builder = DetachSourceReturnedBuilder; + } +}; + #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveSource<'a> { /// The client secret of the source. Required if a publishable key is used to retrieve the source. @@ -47,59 +112,11 @@ impl<'a> RetrieveSource<'a> { impl<'a> RetrieveSource<'a> { /// Retrieves an existing source object. /// Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information. - pub fn send( - &self, - client: &stripe::Client, - source: &stripe_shared::SourceId, - ) -> stripe::Response<stripe_shared::Source> { + pub fn send(&self, client: &stripe::Client, source: &stripe_shared::SourceId) -> stripe::Response<stripe_shared::Source> { client.get_query(&format!("/sources/{source}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct SourceTransactionsSource<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> SourceTransactionsSource<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> SourceTransactionsSource<'a> { - /// List source transactions for a given source. - pub fn send( - &self, - client: &stripe::Client, - source: &stripe_shared::SourceId, - ) -> stripe::Response<stripe_types::List<stripe_shared::SourceTransaction>> { - client.get_query(&format!("/sources/{source}/source_transactions"), self) - } - pub fn paginate( - self, - source: &stripe_shared::SourceId, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SourceTransaction>> { - stripe::ListPaginator::from_list_params( - &format!("/sources/{source}/source_transactions"), - self, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSource<'a> { /// Amount associated with the source. /// This is the amount for which the source will be chargeable once ready. @@ -156,7 +173,7 @@ pub struct CreateSource<'a> { pub token: Option<&'a str>, /// The `type` of the source to create. /// Required unless `customer` and `original_source` are specified (see the [Cloning card Sources](https://stripe.com/docs/sources/connect#cloning-card-sources) guide). - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<&'a str>, #[serde(skip_serializing_if = "Option::is_none")] @@ -268,7 +285,7 @@ pub struct CreateSourceMandateAcceptance<'a> { /// Either `accepted` (the mandate was accepted) or `refused` (the mandate was refused). pub status: CreateSourceMandateAcceptanceStatus, /// The type of acceptance information included with the mandate. Either `online` or `offline` - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CreateSourceMandateAcceptanceType>, /// The user agent of the browser from which the mandate was accepted or refused by the customer. @@ -277,15 +294,7 @@ pub struct CreateSourceMandateAcceptance<'a> { } impl<'a> CreateSourceMandateAcceptance<'a> { pub fn new(status: CreateSourceMandateAcceptanceStatus) -> Self { - Self { - date: None, - ip: None, - offline: None, - online: None, - status, - type_: None, - user_agent: None, - } + Self { date: None, ip: None, offline: None, online: None, status, type_: None, user_agent: None } } } /// The status of the mandate acceptance. @@ -605,7 +614,7 @@ pub struct CreateSourceSourceOrderItems<'a> { /// When type is `sku`, this is the number of instances of the SKU to be ordered. #[serde(skip_serializing_if = "Option::is_none")] pub quantity: Option<u64>, - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<CreateSourceSourceOrderItemsType>, } @@ -793,7 +802,7 @@ pub struct UpdateSourceMandateAcceptance<'a> { /// Either `accepted` (the mandate was accepted) or `refused` (the mandate was refused). pub status: UpdateSourceMandateAcceptanceStatus, /// The type of acceptance information included with the mandate. Either `online` or `offline` - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<UpdateSourceMandateAcceptanceType>, /// The user agent of the browser from which the mandate was accepted or refused by the customer. @@ -802,15 +811,7 @@ pub struct UpdateSourceMandateAcceptance<'a> { } impl<'a> UpdateSourceMandateAcceptance<'a> { pub fn new(status: UpdateSourceMandateAcceptanceStatus) -> Self { - Self { - date: None, - ip: None, - offline: None, - online: None, - status, - type_: None, - user_agent: None, - } + Self { date: None, ip: None, offline: None, online: None, status, type_: None, user_agent: None } } } /// The status of the mandate acceptance. @@ -1051,7 +1052,7 @@ pub struct UpdateSourceSourceOrderItems<'a> { /// When type is `sku`, this is the number of instances of the SKU to be ordered. #[serde(skip_serializing_if = "Option::is_none")] pub quantity: Option<u64>, - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<UpdateSourceSourceOrderItemsType>, } @@ -1118,11 +1119,7 @@ impl<'a> UpdateSource<'a> { /// This request accepts the `metadata` and `owner` as arguments. /// It is also possible to update type specific information for selected payment methods. /// Please refer to our [payment method guides](https://stripe.com/docs/sources) for more detail. - pub fn send( - &self, - client: &stripe::Client, - source: &stripe_shared::SourceId, - ) -> stripe::Response<stripe_shared::Source> { + pub fn send(&self, client: &stripe::Client, source: &stripe_shared::SourceId) -> stripe::Response<stripe_shared::Source> { client.send_form(&format!("/sources/{source}"), self, http_types::Method::Post) } } @@ -1141,14 +1138,44 @@ impl<'a> VerifySource<'a> { } impl<'a> VerifySource<'a> { /// Verify a given source. - pub fn send( - &self, - client: &stripe::Client, - source: &stripe_shared::SourceId, - ) -> stripe::Response<stripe_shared::Source> { + pub fn send(&self, client: &stripe::Client, source: &stripe_shared::SourceId) -> stripe::Response<stripe_shared::Source> { client.send_form(&format!("/sources/{source}/verify"), self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct SourceTransactionsSource<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> SourceTransactionsSource<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> SourceTransactionsSource<'a> { + /// List source transactions for a given source. + pub fn send(&self, client: &stripe::Client, source: &stripe_shared::SourceId) -> stripe::Response<stripe_types::List<stripe_shared::SourceTransaction>> { + client.get_query(&format!("/sources/{source}/source_transactions"), self) + } + pub fn paginate(self, source: &stripe_shared::SourceId) -> stripe::ListPaginator<stripe_types::List<stripe_shared::SourceTransaction>> { + stripe::ListPaginator::from_list_params(&format!("/sources/{source}/source_transactions"), self) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct MandateOfflineAcceptanceParams<'a> { /// An email to contact you with if a copy of the mandate is requested, required if `type` is `offline`. diff --git a/generated/stripe_payment/src/source_mandate_notification.rs b/generated/stripe_payment/src/source_mandate_notification.rs index 66ecbc19c..8c8b573ee 100644 --- a/generated/stripe_payment/src/source_mandate_notification.rs +++ b/generated/stripe_payment/src/source_mandate_notification.rs @@ -1,15 +1,15 @@ /// Source mandate notifications should be created when a notification related to /// a source mandate must be sent to the payer. They will trigger a webhook or /// deliver an email to the customer. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceMandateNotification { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_payment::SourceMandateNotificationAcssDebitData>, /// A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the amount associated with the mandate notification. /// The amount is expressed in the currency of the underlying source. /// Required if the notification type is `debit_initiated`. pub amount: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_payment::SourceMandateNotificationBacsDebitData>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -19,16 +19,153 @@ pub struct SourceMandateNotification { pub livemode: bool, /// The reason of the mandate notification. Valid reasons are `mandate_confirmed` or `debit_initiated`. pub reason: String, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_payment::SourceMandateNotificationSepaDebitData>, pub source: stripe_shared::Source, /// The status of the mandate notification. Valid statuses are `pending` or `submitted`. pub status: String, /// The type of source this mandate notification is attached to. /// Should be the source type identifier code for the payment method, such as `three_d_secure`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, } +#[cfg(feature = "min-ser")] +pub struct SourceMandateNotificationBuilder { + acss_debit: Option<Option<stripe_payment::SourceMandateNotificationAcssDebitData>>, + amount: Option<Option<i64>>, + bacs_debit: Option<Option<stripe_payment::SourceMandateNotificationBacsDebitData>>, + created: Option<stripe_types::Timestamp>, + id: Option<stripe_payment::SourceMandateNotificationId>, + livemode: Option<bool>, + reason: Option<String>, + sepa_debit: Option<Option<stripe_payment::SourceMandateNotificationSepaDebitData>>, + source: Option<stripe_shared::Source>, + status: Option<String>, + type_: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceMandateNotification { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceMandateNotification>, + builder: SourceMandateNotificationBuilder, + } + + impl Visitor for Place<SourceMandateNotification> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceMandateNotificationBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceMandateNotificationBuilder { + type Out = SourceMandateNotification; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "amount" => Deserialize::begin(&mut self.amount), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "created" => Deserialize::begin(&mut self.created), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "reason" => Deserialize::begin(&mut self.reason), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "source" => Deserialize::begin(&mut self.source), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + amount: Deserialize::default(), + bacs_debit: Deserialize::default(), + created: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + reason: Deserialize::default(), + sepa_debit: Deserialize::default(), + source: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let amount = self.amount.take()?; + let bacs_debit = self.bacs_debit.take()?; + let created = self.created.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let reason = self.reason.take()?; + let sepa_debit = self.sepa_debit.take()?; + let source = self.source.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { acss_debit, amount, bacs_debit, created, id, livemode, reason, sepa_debit, source, status, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceMandateNotification { + type Builder = SourceMandateNotificationBuilder; + } + + impl FromValueOpt for SourceMandateNotification { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceMandateNotificationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for SourceMandateNotification { type Id = stripe_payment::SourceMandateNotificationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_payment/src/source_mandate_notification_acss_debit_data.rs b/generated/stripe_payment/src/source_mandate_notification_acss_debit_data.rs index 6e8b5c44e..c7fd35812 100644 --- a/generated/stripe_payment/src/source_mandate_notification_acss_debit_data.rs +++ b/generated/stripe_payment/src/source_mandate_notification_acss_debit_data.rs @@ -1,6 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceMandateNotificationAcssDebitData { /// The statement descriptor associate with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceMandateNotificationAcssDebitDataBuilder { + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceMandateNotificationAcssDebitData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceMandateNotificationAcssDebitData>, + builder: SourceMandateNotificationAcssDebitDataBuilder, + } + + impl Visitor for Place<SourceMandateNotificationAcssDebitData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceMandateNotificationAcssDebitDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceMandateNotificationAcssDebitDataBuilder { + type Out = SourceMandateNotificationAcssDebitData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceMandateNotificationAcssDebitData { + type Builder = SourceMandateNotificationAcssDebitDataBuilder; + } + + impl FromValueOpt for SourceMandateNotificationAcssDebitData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceMandateNotificationAcssDebitDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_payment/src/source_mandate_notification_bacs_debit_data.rs b/generated/stripe_payment/src/source_mandate_notification_bacs_debit_data.rs index 214203f0b..6cec4f146 100644 --- a/generated/stripe_payment/src/source_mandate_notification_bacs_debit_data.rs +++ b/generated/stripe_payment/src/source_mandate_notification_bacs_debit_data.rs @@ -1,6 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceMandateNotificationBacsDebitData { /// Last 4 digits of the account number associated with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceMandateNotificationBacsDebitDataBuilder { + last4: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceMandateNotificationBacsDebitData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceMandateNotificationBacsDebitData>, + builder: SourceMandateNotificationBacsDebitDataBuilder, + } + + impl Visitor for Place<SourceMandateNotificationBacsDebitData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceMandateNotificationBacsDebitDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceMandateNotificationBacsDebitDataBuilder { + type Out = SourceMandateNotificationBacsDebitData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "last4" => Deserialize::begin(&mut self.last4), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { last4: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let last4 = self.last4.take()?; + + Some(Self::Out { last4 }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceMandateNotificationBacsDebitData { + type Builder = SourceMandateNotificationBacsDebitDataBuilder; + } + + impl FromValueOpt for SourceMandateNotificationBacsDebitData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceMandateNotificationBacsDebitDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_payment/src/source_mandate_notification_sepa_debit_data.rs b/generated/stripe_payment/src/source_mandate_notification_sepa_debit_data.rs index 1ac22700e..904ca6c27 100644 --- a/generated/stripe_payment/src/source_mandate_notification_sepa_debit_data.rs +++ b/generated/stripe_payment/src/source_mandate_notification_sepa_debit_data.rs @@ -1,12 +1,105 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceMandateNotificationSepaDebitData { /// SEPA creditor ID. - #[serde(skip_serializing_if = "Option::is_none")] pub creditor_identifier: Option<String>, /// Last 4 digits of the account number associated with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, /// Mandate reference associated with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_reference: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceMandateNotificationSepaDebitDataBuilder { + creditor_identifier: Option<Option<String>>, + last4: Option<Option<String>>, + mandate_reference: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceMandateNotificationSepaDebitData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceMandateNotificationSepaDebitData>, + builder: SourceMandateNotificationSepaDebitDataBuilder, + } + + impl Visitor for Place<SourceMandateNotificationSepaDebitData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceMandateNotificationSepaDebitDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceMandateNotificationSepaDebitDataBuilder { + type Out = SourceMandateNotificationSepaDebitData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "creditor_identifier" => Deserialize::begin(&mut self.creditor_identifier), + "last4" => Deserialize::begin(&mut self.last4), + "mandate_reference" => Deserialize::begin(&mut self.mandate_reference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { creditor_identifier: Deserialize::default(), last4: Deserialize::default(), mandate_reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let creditor_identifier = self.creditor_identifier.take()?; + let last4 = self.last4.take()?; + let mandate_reference = self.mandate_reference.take()?; + + Some(Self::Out { creditor_identifier, last4, mandate_reference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceMandateNotificationSepaDebitData { + type Builder = SourceMandateNotificationSepaDebitDataBuilder; + } + + impl FromValueOpt for SourceMandateNotificationSepaDebitData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceMandateNotificationSepaDebitDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "creditor_identifier" => b.creditor_identifier = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "mandate_reference" => b.mandate_reference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_product/.rustfmt.toml b/generated/stripe_product/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_product/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_product/Cargo.toml b/generated/stripe_product/Cargo.toml index 8dd73d620..51966ab8c 100644 --- a/generated/stripe_product/Cargo.toml +++ b/generated/stripe_product/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_product/src/coupon/requests.rs b/generated/stripe_product/src/coupon/requests.rs index 5be70a4da..ababba0f5 100644 --- a/generated/stripe_product/src/coupon/requests.rs +++ b/generated/stripe_product/src/coupon/requests.rs @@ -1,23 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteCoupon {} -impl DeleteCoupon { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteCoupon { - /// You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. - /// However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can’t redeem the coupon. - /// You can also delete coupons via the API. - pub fn send( - &self, - client: &stripe::Client, - coupon: &stripe_shared::CouponId, - ) -> stripe::Response<stripe_shared::DeletedCoupon> { - client.send_form(&format!("/coupons/{coupon}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListCoupon<'a> { /// A filter on the list, based on the object `created` field. /// The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options. @@ -48,10 +29,7 @@ impl<'a> ListCoupon<'a> { } impl<'a> ListCoupon<'a> { /// Returns a list of your coupons. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Coupon>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Coupon>> { client.get_query("/coupons", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Coupon>> { @@ -59,27 +37,6 @@ impl<'a> ListCoupon<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveCoupon<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveCoupon<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveCoupon<'a> { - /// Retrieves the coupon with the given ID. - pub fn send( - &self, - client: &stripe::Client, - coupon: &stripe_shared::CouponId, - ) -> stripe::Response<stripe_shared::Coupon> { - client.get_query(&format!("/coupons/{coupon}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCoupon<'a> { /// A positive integer representing the amount to subtract from an invoice total (required if `percent_off` is not passed). #[serde(skip_serializing_if = "Option::is_none")] @@ -93,8 +50,7 @@ pub struct CreateCoupon<'a> { /// Coupons defined in each available currency option (only supported if `amount_off` is passed). /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: - Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, /// Specifies how long the discount will be in effect if used on a subscription. Defaults to `once`. #[serde(skip_serializing_if = "Option::is_none")] pub duration: Option<stripe_shared::CouponDuration>, @@ -159,12 +115,28 @@ impl<'a> CreateCoupon<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveCoupon<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveCoupon<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveCoupon<'a> { + /// Retrieves the coupon with the given ID. + pub fn send(&self, client: &stripe::Client, coupon: &stripe_shared::CouponId) -> stripe::Response<stripe_shared::Coupon> { + client.get_query(&format!("/coupons/{coupon}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateCoupon<'a> { /// Coupons defined in each available currency option (only supported if the coupon is amount-based). /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: - Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -187,14 +159,25 @@ impl<'a> UpdateCoupon<'a> { impl<'a> UpdateCoupon<'a> { /// Updates the metadata of a coupon. /// Other coupon details (currency, duration, amount_off) are, by design, not editable. - pub fn send( - &self, - client: &stripe::Client, - coupon: &stripe_shared::CouponId, - ) -> stripe::Response<stripe_shared::Coupon> { + pub fn send(&self, client: &stripe::Client, coupon: &stripe_shared::CouponId) -> stripe::Response<stripe_shared::Coupon> { client.send_form(&format!("/coupons/{coupon}"), self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteCoupon {} +impl DeleteCoupon { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteCoupon { + /// You can delete coupons via the [coupon management](https://dashboard.stripe.com/coupons) page of the Stripe dashboard. + /// However, deleting a coupon does not affect any customers who have already applied the coupon; it means that new customers can’t redeem the coupon. + /// You can also delete coupons via the API. + pub fn send(&self, client: &stripe::Client, coupon: &stripe_shared::CouponId) -> stripe::Response<stripe_shared::DeletedCoupon> { + client.send_form(&format!("/coupons/{coupon}"), self, http_types::Method::Delete) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CurrencyOption { /// A positive integer representing the amount to subtract from an invoice total. diff --git a/generated/stripe_product/src/mod.rs b/generated/stripe_product/src/mod.rs index 544a4bd74..5e215c58b 100644 --- a/generated/stripe_product/src/mod.rs +++ b/generated/stripe_product/src/mod.rs @@ -7,6 +7,9 @@ //! for requests mentioned in the `Products` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_product; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); pub mod coupon; pub use stripe_shared::coupon::*; pub use stripe_shared::coupon_applies_to::*; diff --git a/generated/stripe_product/src/price/requests.rs b/generated/stripe_product/src/price/requests.rs index 36800ef73..75a02e8bf 100644 --- a/generated/stripe_product/src/price/requests.rs +++ b/generated/stripe_product/src/price/requests.rs @@ -1,3 +1,40 @@ +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct SearchPrice<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for pagination across multiple pages of results. + /// Don't include this parameter on the first call. + /// Use the next_page value returned in a previous response to request subsequent results. + #[serde(skip_serializing_if = "Option::is_none")] + pub page: Option<&'a str>, + /// The search query string. + /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for prices](https://stripe.com/docs/search#query-fields-for-prices). + pub query: &'a str, +} +impl<'a> SearchPrice<'a> { + pub fn new(query: &'a str) -> Self { + Self { expand: None, limit: None, page: None, query } + } +} +impl<'a> SearchPrice<'a> { + /// Search for prices you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). + /// Don’t use search in read-after-write flows where strict consistency is necessary. + /// Under normal operating. + /// conditions, data is searchable in less than a minute. + /// Occasionally, propagation of new or updated data can be up. + /// to an hour behind during outages. Search functionality is not available to merchants in India. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::SearchList<stripe_shared::Price>> { + client.get_query("/prices/search", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Price>> { + stripe::ListPaginator::from_search_params("/prices/search", self) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ListPrice<'a> { /// Only return prices that are active or inactive (e.g., pass `false` to list all inactive prices). @@ -37,7 +74,7 @@ pub struct ListPrice<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, /// Only return prices of type `recurring` or `one_time`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_shared::PriceType>, } @@ -162,77 +199,13 @@ impl serde::Serialize for ListPriceRecurringUsageType { impl<'a> ListPrice<'a> { /// Returns a list of your active prices, excluding [inline prices](https://stripe.com/docs/products-prices/pricing-models#inline-pricing). /// For the list of inactive prices, set `active` to false. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Price>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Price>> { client.get_query("/prices", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Price>> { stripe::ListPaginator::from_list_params("/prices", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrievePrice<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrievePrice<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrievePrice<'a> { - /// Retrieves the price with the given ID. - pub fn send( - &self, - client: &stripe::Client, - price: &stripe_shared::PriceId, - ) -> stripe::Response<stripe_shared::Price> { - client.get_query(&format!("/prices/{price}"), self) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct SearchPrice<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for pagination across multiple pages of results. - /// Don't include this parameter on the first call. - /// Use the next_page value returned in a previous response to request subsequent results. - #[serde(skip_serializing_if = "Option::is_none")] - pub page: Option<&'a str>, - /// The search query string. - /// See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for prices](https://stripe.com/docs/search#query-fields-for-prices). - pub query: &'a str, -} -impl<'a> SearchPrice<'a> { - pub fn new(query: &'a str) -> Self { - Self { expand: None, limit: None, page: None, query } - } -} -impl<'a> SearchPrice<'a> { - /// Search for prices you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language). - /// Don’t use search in read-after-write flows where strict consistency is necessary. - /// Under normal operating. - /// conditions, data is searchable in less than a minute. - /// Occasionally, propagation of new or updated data can be up. - /// to an hour behind during outages. Search functionality is not available to merchants in India. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::SearchList<stripe_shared::Price>> { - client.get_query("/prices/search", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Price>> { - stripe::ListPaginator::from_search_params("/prices/search", self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePrice<'a> { /// Whether the price can be used for new purchases. Defaults to `true`. @@ -250,8 +223,7 @@ pub struct CreatePrice<'a> { /// Prices defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: - Option<&'a std::collections::HashMap<stripe_types::Currency, CreatePriceCurrencyOptions>>, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CreatePriceCurrencyOptions>>, /// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. #[serde(skip_serializing_if = "Option::is_none")] pub custom_unit_amount: Option<CustomUnitAmount>, @@ -393,13 +365,7 @@ pub struct CreatePriceCurrencyOptionsTiers { } impl CreatePriceCurrencyOptionsTiers { pub fn new(up_to: CreatePriceCurrencyOptionsTiersUpTo) -> Self { - Self { - flat_amount: None, - flat_amount_decimal: None, - unit_amount: None, - unit_amount_decimal: None, - up_to, - } + Self { flat_amount: None, flat_amount_decimal: None, unit_amount: None, unit_amount_decimal: None, up_to } } } /// Specifies the upper bound of this tier. @@ -448,28 +414,22 @@ pub struct CreatePriceProductData<'a> { } impl<'a> CreatePriceProductData<'a> { pub fn new(name: &'a str) -> Self { - Self { - active: None, - id: None, - metadata: None, - name, - statement_descriptor: None, - tax_code: None, - unit_label: None, - } + Self { active: None, id: None, metadata: None, name, statement_descriptor: None, tax_code: None, unit_label: None } } } /// The recurring components of a price such as `interval` and `usage_type`. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePriceRecurring { - /// Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. + /// Specifies a usage aggregation strategy for prices of `usage_type=metered`. + /// Allowed values are `sum` for summing up all usage during a period, `last_during_period` for using the last usage record reported within a period, `last_ever` for using the last usage record ever (across period bounds) or `max` which uses the usage record with the maximum reported usage during a period. + /// Defaults to `sum`. #[serde(skip_serializing_if = "Option::is_none")] pub aggregate_usage: Option<CreatePriceRecurringAggregateUsage>, /// Specifies billing frequency. Either `day`, `week`, `month` or `year`. pub interval: CreatePriceRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, /// Default number of trial days when subscribing a customer to this price using [`trial_from_plan=true`](https://stripe.com/docs/api#create_subscription-trial_from_plan). @@ -485,16 +445,12 @@ pub struct CreatePriceRecurring { } impl CreatePriceRecurring { pub fn new(interval: CreatePriceRecurringInterval) -> Self { - Self { - aggregate_usage: None, - interval, - interval_count: None, - trial_period_days: None, - usage_type: None, - } + Self { aggregate_usage: None, interval, interval_count: None, trial_period_days: None, usage_type: None } } } -/// Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. +/// Specifies a usage aggregation strategy for prices of `usage_type=metered`. +/// Allowed values are `sum` for summing up all usage during a period, `last_during_period` for using the last usage record reported within a period, `last_ever` for using the last usage record ever (across period bounds) or `max` which uses the usage record with the maximum reported usage during a period. +/// Defaults to `sum`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePriceRecurringAggregateUsage { LastDuringPeriod, @@ -674,13 +630,7 @@ pub struct CreatePriceTiers<'a> { } impl<'a> CreatePriceTiers<'a> { pub fn new(up_to: CreatePriceTiersUpTo) -> Self { - Self { - flat_amount: None, - flat_amount_decimal: None, - unit_amount: None, - unit_amount_decimal: None, - up_to, - } + Self { flat_amount: None, flat_amount_decimal: None, unit_amount: None, unit_amount_decimal: None, up_to } } } /// Specifies the upper bound of this tier. @@ -759,6 +709,23 @@ impl<'a> CreatePrice<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrievePrice<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrievePrice<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrievePrice<'a> { + /// Retrieves the price with the given ID. + pub fn send(&self, client: &stripe::Client, price: &stripe_shared::PriceId) -> stripe::Response<stripe_shared::Price> { + client.get_query(&format!("/prices/{price}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePrice<'a> { /// Whether the price can be used for new purchases. Defaults to `true`. #[serde(skip_serializing_if = "Option::is_none")] @@ -766,8 +733,7 @@ pub struct UpdatePrice<'a> { /// Prices defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: - Option<&'a std::collections::HashMap<stripe_types::Currency, UpdatePriceCurrencyOptions>>, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, UpdatePriceCurrencyOptions>>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -856,13 +822,7 @@ pub struct UpdatePriceCurrencyOptionsTiers { } impl UpdatePriceCurrencyOptionsTiers { pub fn new(up_to: UpdatePriceCurrencyOptionsTiersUpTo) -> Self { - Self { - flat_amount: None, - flat_amount_decimal: None, - unit_amount: None, - unit_amount_decimal: None, - up_to, - } + Self { flat_amount: None, flat_amount_decimal: None, unit_amount: None, unit_amount_decimal: None, up_to } } } /// Specifies the upper bound of this tier. @@ -877,11 +837,7 @@ pub enum UpdatePriceCurrencyOptionsTiersUpTo { impl<'a> UpdatePrice<'a> { /// Updates the specified price by setting the values of the parameters passed. /// Any parameters not provided are left unchanged. - pub fn send( - &self, - client: &stripe::Client, - price: &stripe_shared::PriceId, - ) -> stripe::Response<stripe_shared::Price> { + pub fn send(&self, client: &stripe::Client, price: &stripe_shared::PriceId) -> stripe::Response<stripe_shared::Price> { client.send_form(&format!("/prices/{price}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_product/src/product/requests.rs b/generated/stripe_product/src/product/requests.rs index 4fc865adb..3f42c988d 100644 --- a/generated/stripe_product/src/product/requests.rs +++ b/generated/stripe_product/src/product/requests.rs @@ -1,102 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteProduct {} -impl DeleteProduct { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteProduct { - /// Delete a product. - /// Deleting a product is only possible if it has no prices associated with it. - /// Additionally, deleting a product with `type=good` is only possible if it has no SKUs associated with it. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::ProductId, - ) -> stripe::Response<stripe_shared::DeletedProduct> { - client.send_form(&format!("/products/{id}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListProduct<'a> { - /// Only return products that are active or inactive (e.g., pass `false` to list all inactive products). - #[serde(skip_serializing_if = "Option::is_none")] - pub active: Option<bool>, - /// Only return products that were created during the given date interval. - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Only return products with the given IDs. - /// Cannot be used with [starting_after](https://stripe.com/docs/api#list_products-starting_after) or [ending_before](https://stripe.com/docs/api#list_products-ending_before). - #[serde(skip_serializing_if = "Option::is_none")] - pub ids: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// Only return products that can be shipped (i.e., physical, not digital products). - #[serde(skip_serializing_if = "Option::is_none")] - pub shippable: Option<bool>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// Only return products of this type. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] - pub type_: Option<stripe_shared::ProductType>, - /// Only return products with the given url. - #[serde(skip_serializing_if = "Option::is_none")] - pub url: Option<&'a str>, -} -impl<'a> ListProduct<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListProduct<'a> { - /// Returns a list of your products. - /// The products are returned sorted by creation date, with the most recently created products appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::Product>> { - client.get_query("/products", self) - } - pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Product>> { - stripe::ListPaginator::from_list_params("/products", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveProduct<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveProduct<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveProduct<'a> { - /// Retrieves the details of an existing product. - /// Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::ProductId, - ) -> stripe::Response<stripe_shared::Product> { - client.get_query(&format!("/products/{id}"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct SearchProduct<'a> { /// Specifies which fields in the response should be expanded. @@ -127,15 +28,10 @@ impl<'a> SearchProduct<'a> { /// conditions, data is searchable in less than a minute. /// Occasionally, propagation of new or updated data can be up. /// to an hour behind during outages. Search functionality is not available to merchants in India. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::SearchList<stripe_shared::Product>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::SearchList<stripe_shared::Product>> { client.get_query("/products/search", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Product>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::SearchList<stripe_shared::Product>> { stripe::ListPaginator::from_search_params("/products/search", self) } } @@ -196,7 +92,7 @@ pub struct CreateProduct<'a> { /// Defaults to `service` if not explicitly specified, enabling use of this product with Subscriptions and Plans. /// Set this parameter to `good` to use this product with Orders and SKUs. /// On API versions before `2018-02-05`, this field defaults to `good` for compatibility reasons. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_shared::ProductType>, /// A label that represents units of this product. @@ -239,12 +135,7 @@ pub struct CreateProductDefaultPriceData<'a> { /// Prices defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - &'a std::collections::HashMap< - stripe_types::Currency, - CreateProductDefaultPriceDataCurrencyOptions, - >, - >, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CreateProductDefaultPriceDataCurrencyOptions>>, /// The recurring components of a price such as `interval` and `interval_count`. #[serde(skip_serializing_if = "Option::is_none")] pub recurring: Option<CreateProductDefaultPriceDataRecurring>, @@ -265,14 +156,7 @@ pub struct CreateProductDefaultPriceData<'a> { } impl<'a> CreateProductDefaultPriceData<'a> { pub fn new(currency: stripe_types::Currency) -> Self { - Self { - currency, - currency_options: None, - recurring: None, - tax_behavior: None, - unit_amount: None, - unit_amount_decimal: None, - } + Self { currency, currency_options: None, recurring: None, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } } /// Prices defined in each available currency option. @@ -405,13 +289,7 @@ pub struct CreateProductDefaultPriceDataCurrencyOptionsTiers { } impl CreateProductDefaultPriceDataCurrencyOptionsTiers { pub fn new(up_to: CreateProductDefaultPriceDataCurrencyOptionsTiersUpTo) -> Self { - Self { - flat_amount: None, - flat_amount_decimal: None, - unit_amount: None, - unit_amount_decimal: None, - up_to, - } + Self { flat_amount: None, flat_amount_decimal: None, unit_amount: None, unit_amount_decimal: None, up_to } } } /// Specifies the upper bound of this tier. @@ -430,7 +308,7 @@ pub struct CreateProductDefaultPriceDataRecurring { pub interval: CreateProductDefaultPriceDataRecurringInterval, /// The number of intervals between subscription billings. /// For example, `interval=month` and `interval_count=3` bills every 3 months. - /// Maximum of three years interval allowed (3 years, 36 months, or 156 weeks). + /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). #[serde(skip_serializing_if = "Option::is_none")] pub interval_count: Option<u64>, } @@ -550,6 +428,24 @@ impl<'a> CreateProduct<'a> { } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveProduct<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveProduct<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveProduct<'a> { + /// Retrieves the details of an existing product. + /// Supply the unique product ID from either a product creation request or the product list, and Stripe will return the corresponding product information. + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::ProductId) -> stripe::Response<stripe_shared::Product> { + client.get_query(&format!("/products/{id}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateProduct<'a> { /// Whether the product is available for purchase. #[serde(skip_serializing_if = "Option::is_none")] @@ -615,14 +511,80 @@ impl<'a> UpdateProduct<'a> { impl<'a> UpdateProduct<'a> { /// Updates the specific product by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::ProductId, - ) -> stripe::Response<stripe_shared::Product> { + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::ProductId) -> stripe::Response<stripe_shared::Product> { client.send_form(&format!("/products/{id}"), self, http_types::Method::Post) } } +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListProduct<'a> { + /// Only return products that are active or inactive (e.g., pass `false` to list all inactive products). + #[serde(skip_serializing_if = "Option::is_none")] + pub active: Option<bool>, + /// Only return products that were created during the given date interval. + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Only return products with the given IDs. + /// Cannot be used with [starting_after](https://stripe.com/docs/api#list_products-starting_after) or [ending_before](https://stripe.com/docs/api#list_products-ending_before). + #[serde(skip_serializing_if = "Option::is_none")] + pub ids: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// Only return products that can be shipped (i.e., physical, not digital products). + #[serde(skip_serializing_if = "Option::is_none")] + pub shippable: Option<bool>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// Only return products of this type. + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + #[serde(skip_serializing_if = "Option::is_none")] + pub type_: Option<stripe_shared::ProductType>, + /// Only return products with the given url. + #[serde(skip_serializing_if = "Option::is_none")] + pub url: Option<&'a str>, +} +impl<'a> ListProduct<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListProduct<'a> { + /// Returns a list of your products. + /// The products are returned sorted by creation date, with the most recently created products appearing first. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::Product>> { + client.get_query("/products", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::Product>> { + stripe::ListPaginator::from_list_params("/products", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteProduct {} +impl DeleteProduct { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteProduct { + /// Delete a product. + /// Deleting a product is only possible if it has no prices associated with it. + /// Additionally, deleting a product with `type=good` is only possible if it has no SKUs associated with it. + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::ProductId) -> stripe::Response<stripe_shared::DeletedProduct> { + client.send_form(&format!("/products/{id}"), self, http_types::Method::Delete) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct Features<'a> { /// The feature's name. Up to 80 characters long. diff --git a/generated/stripe_product/src/promotion_code/requests.rs b/generated/stripe_product/src/promotion_code/requests.rs index 9e35b2d1d..8237fe93f 100644 --- a/generated/stripe_product/src/promotion_code/requests.rs +++ b/generated/stripe_product/src/promotion_code/requests.rs @@ -1,59 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListPromotionCode<'a> { - /// Filter promotion codes by whether they are active. - #[serde(skip_serializing_if = "Option::is_none")] - pub active: Option<bool>, - /// Only return promotion codes that have this case-insensitive code. - #[serde(skip_serializing_if = "Option::is_none")] - pub code: Option<&'a str>, - /// Only return promotion codes for this coupon. - #[serde(skip_serializing_if = "Option::is_none")] - pub coupon: Option<&'a str>, - /// A filter on the list, based on the object `created` field. - /// The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options. - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// Only return promotion codes that are restricted to this customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListPromotionCode<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListPromotionCode<'a> { - /// Returns a list of your promotion codes. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::PromotionCode>> { - client.get_query("/promotion_codes", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PromotionCode>> { - stripe::ListPaginator::from_list_params("/promotion_codes", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrievePromotionCode<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -67,11 +12,7 @@ impl<'a> RetrievePromotionCode<'a> { impl<'a> RetrievePromotionCode<'a> { /// Retrieves the promotion code with the given ID. /// In order to retrieve a promotion code by the customer-facing `code` use [list](https://stripe.com/docs/api/promotion_codes/list) with the desired `code`. - pub fn send( - &self, - client: &stripe::Client, - promotion_code: &stripe_shared::PromotionCodeId, - ) -> stripe::Response<stripe_shared::PromotionCode> { + pub fn send(&self, client: &stripe::Client, promotion_code: &stripe_shared::PromotionCodeId) -> stripe::Response<stripe_shared::PromotionCode> { client.get_query(&format!("/promotion_codes/{promotion_code}"), self) } } @@ -114,17 +55,7 @@ pub struct CreatePromotionCode<'a> { } impl<'a> CreatePromotionCode<'a> { pub fn new(coupon: &'a str) -> Self { - Self { - active: None, - code: None, - coupon, - customer: None, - expand: None, - expires_at: None, - max_redemptions: None, - metadata: None, - restrictions: None, - } + Self { active: None, code: None, coupon, customer: None, expand: None, expires_at: None, max_redemptions: None, metadata: None, restrictions: None } } } /// Settings that restrict the redemption of the promotion code. @@ -133,8 +64,7 @@ pub struct CreatePromotionCodeRestrictions<'a> { /// Promotion codes defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: - Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, /// A Boolean indicating if the Promotion Code should only be redeemed for Customers without any successful payments or invoices. #[serde(skip_serializing_if = "Option::is_none")] pub first_time_transaction: Option<bool>, @@ -187,8 +117,7 @@ pub struct UpdatePromotionCodeRestrictions<'a> { /// Promotion codes defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: - Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CurrencyOption>>, } impl<'a> UpdatePromotionCodeRestrictions<'a> { pub fn new() -> Self { @@ -198,16 +127,58 @@ impl<'a> UpdatePromotionCodeRestrictions<'a> { impl<'a> UpdatePromotionCode<'a> { /// Updates the specified promotion code by setting the values of the parameters passed. /// Most fields are, by design, not editable. - pub fn send( - &self, - client: &stripe::Client, - promotion_code: &stripe_shared::PromotionCodeId, - ) -> stripe::Response<stripe_shared::PromotionCode> { - client.send_form( - &format!("/promotion_codes/{promotion_code}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, promotion_code: &stripe_shared::PromotionCodeId) -> stripe::Response<stripe_shared::PromotionCode> { + client.send_form(&format!("/promotion_codes/{promotion_code}"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListPromotionCode<'a> { + /// Filter promotion codes by whether they are active. + #[serde(skip_serializing_if = "Option::is_none")] + pub active: Option<bool>, + /// Only return promotion codes that have this case-insensitive code. + #[serde(skip_serializing_if = "Option::is_none")] + pub code: Option<&'a str>, + /// Only return promotion codes for this coupon. + #[serde(skip_serializing_if = "Option::is_none")] + pub coupon: Option<&'a str>, + /// A filter on the list, based on the object `created` field. + /// The value can be a string with an integer Unix timestamp, or it can be a dictionary with a number of different query options. + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// Only return promotion codes that are restricted to this customer. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListPromotionCode<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListPromotionCode<'a> { + /// Returns a list of your promotion codes. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::PromotionCode>> { + client.get_query("/promotion_codes", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::PromotionCode>> { + stripe::ListPaginator::from_list_params("/promotion_codes", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_product/src/shipping_rate/requests.rs b/generated/stripe_product/src/shipping_rate/requests.rs index c785de5c1..6fd565a21 100644 --- a/generated/stripe_product/src/shipping_rate/requests.rs +++ b/generated/stripe_product/src/shipping_rate/requests.rs @@ -35,15 +35,10 @@ impl<'a> ListShippingRate<'a> { } impl<'a> ListShippingRate<'a> { /// Returns a list of your shipping rates. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::ShippingRate>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::ShippingRate>> { client.get_query("/shipping_rates", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ShippingRate>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::ShippingRate>> { stripe::ListPaginator::from_list_params("/shipping_rates", self) } } @@ -60,11 +55,7 @@ impl<'a> RetrieveShippingRate<'a> { } impl<'a> RetrieveShippingRate<'a> { /// Returns the shipping rate object with the given ID. - pub fn send( - &self, - client: &stripe::Client, - shipping_rate_token: &stripe_shared::ShippingRateId, - ) -> stripe::Response<stripe_shared::ShippingRate> { + pub fn send(&self, client: &stripe::Client, shipping_rate_token: &stripe_shared::ShippingRateId) -> stripe::Response<stripe_shared::ShippingRate> { client.get_query(&format!("/shipping_rates/{shipping_rate_token}"), self) } } @@ -98,22 +89,13 @@ pub struct CreateShippingRate<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub tax_code: Option<&'a str>, /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<stripe_shared::ShippingRateType>, } impl<'a> CreateShippingRate<'a> { pub fn new(display_name: &'a str) -> Self { - Self { - delivery_estimate: None, - display_name, - expand: None, - fixed_amount: None, - metadata: None, - tax_behavior: None, - tax_code: None, - type_: None, - } + Self { delivery_estimate: None, display_name, expand: None, fixed_amount: None, metadata: None, tax_behavior: None, tax_code: None, type_: None } } } /// The estimated range for how long shipping will take, meant to be displayable to the customer. @@ -279,12 +261,7 @@ pub struct CreateShippingRateFixedAmount<'a> { /// Shipping rates defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - &'a std::collections::HashMap< - stripe_types::Currency, - CreateShippingRateFixedAmountCurrencyOptions, - >, - >, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, CreateShippingRateFixedAmountCurrencyOptions>>, } impl<'a> CreateShippingRateFixedAmount<'a> { pub fn new(amount: i64, currency: stripe_types::Currency) -> Self { @@ -346,12 +323,7 @@ pub struct UpdateShippingRateFixedAmount<'a> { /// Shipping rates defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - &'a std::collections::HashMap< - stripe_types::Currency, - UpdateShippingRateFixedAmountCurrencyOptions, - >, - >, + pub currency_options: Option<&'a std::collections::HashMap<stripe_types::Currency, UpdateShippingRateFixedAmountCurrencyOptions>>, } impl<'a> UpdateShippingRateFixedAmount<'a> { pub fn new() -> Self { @@ -377,15 +349,7 @@ impl UpdateShippingRateFixedAmountCurrencyOptions { } impl<'a> UpdateShippingRate<'a> { /// Updates an existing shipping rate object. - pub fn send( - &self, - client: &stripe::Client, - shipping_rate_token: &stripe_shared::ShippingRateId, - ) -> stripe::Response<stripe_shared::ShippingRate> { - client.send_form( - &format!("/shipping_rates/{shipping_rate_token}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, shipping_rate_token: &stripe_shared::ShippingRateId) -> stripe::Response<stripe_shared::ShippingRate> { + client.send_form(&format!("/shipping_rates/{shipping_rate_token}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_product/src/tax_code/requests.rs b/generated/stripe_product/src/tax_code/requests.rs index ee21268c9..702cf5eea 100644 --- a/generated/stripe_product/src/tax_code/requests.rs +++ b/generated/stripe_product/src/tax_code/requests.rs @@ -25,10 +25,7 @@ impl<'a> ListTaxCode<'a> { } impl<'a> ListTaxCode<'a> { /// A list of [all tax codes available](https://stripe.com/docs/tax/tax-categories) to add to Products in order to allow specific tax calculations. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::TaxCode>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::TaxCode>> { client.get_query("/tax_codes", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TaxCode>> { @@ -49,11 +46,7 @@ impl<'a> RetrieveTaxCode<'a> { impl<'a> RetrieveTaxCode<'a> { /// Retrieves the details of an existing tax code. /// Supply the unique tax code ID and Stripe will return the corresponding tax code information. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_shared::TaxCodeId, - ) -> stripe::Response<stripe_shared::TaxCode> { + pub fn send(&self, client: &stripe::Client, id: &stripe_shared::TaxCodeId) -> stripe::Response<stripe_shared::TaxCode> { client.get_query(&format!("/tax_codes/{id}"), self) } } diff --git a/generated/stripe_product/src/tax_rate/requests.rs b/generated/stripe_product/src/tax_rate/requests.rs index fa943d8d6..29181aeca 100644 --- a/generated/stripe_product/src/tax_rate/requests.rs +++ b/generated/stripe_product/src/tax_rate/requests.rs @@ -35,10 +35,7 @@ impl<'a> ListTaxRate<'a> { impl<'a> ListTaxRate<'a> { /// Returns a list of your tax rates. /// Tax rates are returned sorted by creation date, with the most recently created tax rates appearing first. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_shared::TaxRate>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_shared::TaxRate>> { client.get_query("/tax_rates", self) } pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_shared::TaxRate>> { @@ -58,11 +55,7 @@ impl<'a> RetrieveTaxRate<'a> { } impl<'a> RetrieveTaxRate<'a> { /// Retrieves a tax rate with the given ID - pub fn send( - &self, - client: &stripe::Client, - tax_rate: &stripe_shared::TaxRateId, - ) -> stripe::Response<stripe_shared::TaxRate> { + pub fn send(&self, client: &stripe::Client, tax_rate: &stripe_shared::TaxRateId) -> stripe::Response<stripe_shared::TaxRate> { client.get_query(&format!("/tax_rates/{tax_rate}"), self) } } @@ -109,19 +102,7 @@ pub struct CreateTaxRate<'a> { } impl<'a> CreateTaxRate<'a> { pub fn new(display_name: &'a str, inclusive: bool, percentage: f64) -> Self { - Self { - active: None, - country: None, - description: None, - display_name, - expand: None, - inclusive, - jurisdiction: None, - metadata: None, - percentage, - state: None, - tax_type: None, - } + Self { active: None, country: None, description: None, display_name, expand: None, inclusive, jurisdiction: None, metadata: None, percentage, state: None, tax_type: None } } } impl<'a> CreateTaxRate<'a> { @@ -175,11 +156,7 @@ impl<'a> UpdateTaxRate<'a> { } impl<'a> UpdateTaxRate<'a> { /// Updates an existing tax rate. - pub fn send( - &self, - client: &stripe::Client, - tax_rate: &stripe_shared::TaxRateId, - ) -> stripe::Response<stripe_shared::TaxRate> { + pub fn send(&self, client: &stripe::Client, tax_rate: &stripe_shared::TaxRateId) -> stripe::Response<stripe_shared::TaxRate> { client.send_form(&format!("/tax_rates/{tax_rate}"), self, http_types::Method::Post) } } diff --git a/generated/stripe_shared/.rustfmt.toml b/generated/stripe_shared/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_shared/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_shared/Cargo.toml b/generated/stripe_shared/Cargo.toml index abaa68367..422894191 100644 --- a/generated/stripe_shared/Cargo.toml +++ b/generated/stripe_shared/Cargo.toml @@ -18,10 +18,13 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} +[features] +min-ser = ["miniserde","stripe_types/min-ser"] diff --git a/generated/stripe_shared/src/account.rs b/generated/stripe_shared/src/account.rs index c34d82a4d..d8cc8c933 100644 --- a/generated/stripe_shared/src/account.rs +++ b/generated/stripe_shared/src/account.rs @@ -5,76 +5,267 @@ /// For Custom accounts, the properties below are always returned. /// For other accounts, some properties are returned until that. /// account has started to go through Connect Onboarding. -/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions),. -/// some properties are only returned for Custom accounts. -/// Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts). +/// Once you create an [Account Link](https://stripe.com/docs/api/account_links). +/// for a Standard or Express account, some parameters are no longer returned. +/// These are marked as **Custom Only** or **Custom and Express**. +/// below. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts). /// /// For more details see <<https://stripe.com/docs/api/accounts/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Account { /// Business information about the account. - #[serde(skip_serializing_if = "Option::is_none")] pub business_profile: Option<stripe_shared::AccountBusinessProfile>, /// The business type. - /// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property is only returned for Custom accounts. - #[serde(skip_serializing_if = "Option::is_none")] pub business_type: Option<stripe_shared::AccountBusinessType>, - #[serde(skip_serializing_if = "Option::is_none")] pub capabilities: Option<stripe_shared::AccountCapabilities>, /// Whether the account can create live charges. - #[serde(skip_serializing_if = "Option::is_none")] pub charges_enabled: Option<bool>, - #[serde(skip_serializing_if = "Option::is_none")] pub company: Option<stripe_shared::LegalEntityCompany>, - #[serde(skip_serializing_if = "Option::is_none")] pub controller: Option<stripe_shared::AccountUnificationAccountController>, /// The account's country. - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, /// Time at which the account was connected. Measured in seconds since the Unix epoch. - #[serde(skip_serializing_if = "Option::is_none")] pub created: Option<stripe_types::Timestamp>, /// Three-letter ISO currency code representing the default currency for the account. /// This must be a currency that [Stripe supports in the account's country](https://stripe.com/docs/payouts). - #[serde(skip_serializing_if = "Option::is_none")] pub default_currency: Option<stripe_types::Currency>, /// Whether account details have been submitted. /// Standard accounts cannot receive payouts before this is true. - #[serde(skip_serializing_if = "Option::is_none")] pub details_submitted: Option<bool>, /// An email address associated with the account. /// It's not used for authentication and Stripe doesn't market to this field without explicit approval from the platform. - #[serde(skip_serializing_if = "Option::is_none")] pub email: Option<String>, - /// External accounts (bank accounts and debit cards) currently attached to this account. - /// External accounts are only returned for requests where `controller[is_controller]` is true. - #[serde(skip_serializing_if = "Option::is_none")] + /// External accounts (bank accounts and debit cards) currently attached to this account pub external_accounts: Option<stripe_types::List<stripe_shared::ExternalAccount>>, - #[serde(skip_serializing_if = "Option::is_none")] pub future_requirements: Option<stripe_shared::AccountFutureRequirements>, /// Unique identifier for the object. pub id: stripe_shared::AccountId, - #[serde(skip_serializing_if = "Option::is_none")] pub individual: Option<stripe_shared::Person>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. - #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<std::collections::HashMap<String, String>>, /// Whether Stripe can send payouts to this account. - #[serde(skip_serializing_if = "Option::is_none")] pub payouts_enabled: Option<bool>, - #[serde(skip_serializing_if = "Option::is_none")] pub requirements: Option<stripe_shared::AccountRequirements>, /// Options for customizing how the account functions within Stripe. - #[serde(skip_serializing_if = "Option::is_none")] pub settings: Option<stripe_shared::AccountSettings>, - #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option<stripe_shared::AccountTosAcceptance>, /// The Stripe account type. Can be `standard`, `express`, or `custom`. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<stripe_shared::AccountType>, } +#[cfg(feature = "min-ser")] +pub struct AccountBuilder { + business_profile: Option<Option<stripe_shared::AccountBusinessProfile>>, + business_type: Option<Option<stripe_shared::AccountBusinessType>>, + capabilities: Option<Option<stripe_shared::AccountCapabilities>>, + charges_enabled: Option<Option<bool>>, + company: Option<Option<stripe_shared::LegalEntityCompany>>, + controller: Option<Option<stripe_shared::AccountUnificationAccountController>>, + country: Option<Option<String>>, + created: Option<Option<stripe_types::Timestamp>>, + default_currency: Option<Option<stripe_types::Currency>>, + details_submitted: Option<Option<bool>>, + email: Option<Option<String>>, + external_accounts: Option<Option<stripe_types::List<stripe_shared::ExternalAccount>>>, + future_requirements: Option<Option<stripe_shared::AccountFutureRequirements>>, + id: Option<stripe_shared::AccountId>, + individual: Option<Option<stripe_shared::Person>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + payouts_enabled: Option<Option<bool>>, + requirements: Option<Option<stripe_shared::AccountRequirements>>, + settings: Option<Option<stripe_shared::AccountSettings>>, + tos_acceptance: Option<Option<stripe_shared::AccountTosAcceptance>>, + type_: Option<Option<stripe_shared::AccountType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Account { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Account>, + builder: AccountBuilder, + } + + impl Visitor for Place<Account> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountBuilder { + type Out = Account; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "business_profile" => Deserialize::begin(&mut self.business_profile), + "business_type" => Deserialize::begin(&mut self.business_type), + "capabilities" => Deserialize::begin(&mut self.capabilities), + "charges_enabled" => Deserialize::begin(&mut self.charges_enabled), + "company" => Deserialize::begin(&mut self.company), + "controller" => Deserialize::begin(&mut self.controller), + "country" => Deserialize::begin(&mut self.country), + "created" => Deserialize::begin(&mut self.created), + "default_currency" => Deserialize::begin(&mut self.default_currency), + "details_submitted" => Deserialize::begin(&mut self.details_submitted), + "email" => Deserialize::begin(&mut self.email), + "external_accounts" => Deserialize::begin(&mut self.external_accounts), + "future_requirements" => Deserialize::begin(&mut self.future_requirements), + "id" => Deserialize::begin(&mut self.id), + "individual" => Deserialize::begin(&mut self.individual), + "metadata" => Deserialize::begin(&mut self.metadata), + "payouts_enabled" => Deserialize::begin(&mut self.payouts_enabled), + "requirements" => Deserialize::begin(&mut self.requirements), + "settings" => Deserialize::begin(&mut self.settings), + "tos_acceptance" => Deserialize::begin(&mut self.tos_acceptance), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + business_profile: Deserialize::default(), + business_type: Deserialize::default(), + capabilities: Deserialize::default(), + charges_enabled: Deserialize::default(), + company: Deserialize::default(), + controller: Deserialize::default(), + country: Deserialize::default(), + created: Deserialize::default(), + default_currency: Deserialize::default(), + details_submitted: Deserialize::default(), + email: Deserialize::default(), + external_accounts: Deserialize::default(), + future_requirements: Deserialize::default(), + id: Deserialize::default(), + individual: Deserialize::default(), + metadata: Deserialize::default(), + payouts_enabled: Deserialize::default(), + requirements: Deserialize::default(), + settings: Deserialize::default(), + tos_acceptance: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let business_profile = self.business_profile.take()?; + let business_type = self.business_type.take()?; + let capabilities = self.capabilities.take()?; + let charges_enabled = self.charges_enabled.take()?; + let company = self.company.take()?; + let controller = self.controller.take()?; + let country = self.country.take()?; + let created = self.created.take()?; + let default_currency = self.default_currency.take()?; + let details_submitted = self.details_submitted.take()?; + let email = self.email.take()?; + let external_accounts = self.external_accounts.take()?; + let future_requirements = self.future_requirements.take()?; + let id = self.id.take()?; + let individual = self.individual.take()?; + let metadata = self.metadata.take()?; + let payouts_enabled = self.payouts_enabled.take()?; + let requirements = self.requirements.take()?; + let settings = self.settings.take()?; + let tos_acceptance = self.tos_acceptance.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { + business_profile, + business_type, + capabilities, + charges_enabled, + company, + controller, + country, + created, + default_currency, + details_submitted, + email, + external_accounts, + future_requirements, + id, + individual, + metadata, + payouts_enabled, + requirements, + settings, + tos_acceptance, + type_, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Account { + type Builder = AccountBuilder; + } + + impl FromValueOpt for Account { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "business_profile" => b.business_profile = Some(FromValueOpt::from_value(v)?), + "business_type" => b.business_type = Some(FromValueOpt::from_value(v)?), + "capabilities" => b.capabilities = Some(FromValueOpt::from_value(v)?), + "charges_enabled" => b.charges_enabled = Some(FromValueOpt::from_value(v)?), + "company" => b.company = Some(FromValueOpt::from_value(v)?), + "controller" => b.controller = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "default_currency" => b.default_currency = Some(FromValueOpt::from_value(v)?), + "details_submitted" => b.details_submitted = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "external_accounts" => b.external_accounts = Some(FromValueOpt::from_value(v)?), + "future_requirements" => b.future_requirements = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "individual" => b.individual = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "payouts_enabled" => b.payouts_enabled = Some(FromValueOpt::from_value(v)?), + "requirements" => b.requirements = Some(FromValueOpt::from_value(v)?), + "settings" => b.settings = Some(FromValueOpt::from_value(v)?), + "tos_acceptance" => b.tos_acceptance = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Account { type Id = stripe_shared::AccountId; fn id(&self) -> &Self::Id { @@ -137,10 +328,27 @@ impl<'de> serde::Deserialize<'de> for AccountBusinessType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for AccountBusinessType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for AccountBusinessType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for AccountBusinessType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<AccountBusinessType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountBusinessType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(AccountBusinessType); #[derive(Copy, Clone, Eq, PartialEq)] pub enum AccountType { Custom, @@ -196,3 +404,21 @@ impl<'de> serde::Deserialize<'de> for AccountType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for AccountType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for AccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<AccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(AccountType); diff --git a/generated/stripe_shared/src/account_annual_revenue.rs b/generated/stripe_shared/src/account_annual_revenue.rs deleted file mode 100644 index 7f3366455..000000000 --- a/generated/stripe_shared/src/account_annual_revenue.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct AccountAnnualRevenue { - /// A non-negative integer representing the amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). - pub amount: Option<i64>, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: Option<stripe_types::Currency>, - /// The close-out date of the preceding fiscal year in ISO 8601 format. - /// E.g. - /// 2023-12-31 for the 31st of December, 2023. - pub fiscal_year_end: Option<String>, -} diff --git a/generated/stripe_shared/src/account_bacs_debit_payments_settings.rs b/generated/stripe_shared/src/account_bacs_debit_payments_settings.rs index a7f6c20ad..7284dcae1 100644 --- a/generated/stripe_shared/src/account_bacs_debit_payments_settings.rs +++ b/generated/stripe_shared/src/account_bacs_debit_payments_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountBacsDebitPaymentsSettings { /// The Bacs Direct Debit display name for this account. /// For payments made with Bacs Direct Debit, this name appears on the mandate as the statement descriptor. @@ -12,3 +14,93 @@ pub struct AccountBacsDebitPaymentsSettings { /// For payments made with Bacs Direct Debit, this number is a unique identifier of the account with our banking partners. pub service_user_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountBacsDebitPaymentsSettingsBuilder { + display_name: Option<Option<String>>, + service_user_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountBacsDebitPaymentsSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountBacsDebitPaymentsSettings>, + builder: AccountBacsDebitPaymentsSettingsBuilder, + } + + impl Visitor for Place<AccountBacsDebitPaymentsSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountBacsDebitPaymentsSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountBacsDebitPaymentsSettingsBuilder { + type Out = AccountBacsDebitPaymentsSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "display_name" => Deserialize::begin(&mut self.display_name), + "service_user_number" => Deserialize::begin(&mut self.service_user_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { display_name: Deserialize::default(), service_user_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let display_name = self.display_name.take()?; + let service_user_number = self.service_user_number.take()?; + + Some(Self::Out { display_name, service_user_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountBacsDebitPaymentsSettings { + type Builder = AccountBacsDebitPaymentsSettingsBuilder; + } + + impl FromValueOpt for AccountBacsDebitPaymentsSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountBacsDebitPaymentsSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "service_user_number" => b.service_user_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_branding_settings.rs b/generated/stripe_shared/src/account_branding_settings.rs index 8836a20c5..7bb8e86fb 100644 --- a/generated/stripe_shared/src/account_branding_settings.rs +++ b/generated/stripe_shared/src/account_branding_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountBrandingSettings { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) An icon for the account. /// Must be square and at least 128px x 128px. @@ -11,3 +13,101 @@ pub struct AccountBrandingSettings { /// A CSS hex color value representing the secondary branding color for this account pub secondary_color: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountBrandingSettingsBuilder { + icon: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + logo: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + primary_color: Option<Option<String>>, + secondary_color: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountBrandingSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountBrandingSettings>, + builder: AccountBrandingSettingsBuilder, + } + + impl Visitor for Place<AccountBrandingSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountBrandingSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountBrandingSettingsBuilder { + type Out = AccountBrandingSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "icon" => Deserialize::begin(&mut self.icon), + "logo" => Deserialize::begin(&mut self.logo), + "primary_color" => Deserialize::begin(&mut self.primary_color), + "secondary_color" => Deserialize::begin(&mut self.secondary_color), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { icon: Deserialize::default(), logo: Deserialize::default(), primary_color: Deserialize::default(), secondary_color: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let icon = self.icon.take()?; + let logo = self.logo.take()?; + let primary_color = self.primary_color.take()?; + let secondary_color = self.secondary_color.take()?; + + Some(Self::Out { icon, logo, primary_color, secondary_color }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountBrandingSettings { + type Builder = AccountBrandingSettingsBuilder; + } + + impl FromValueOpt for AccountBrandingSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountBrandingSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "icon" => b.icon = Some(FromValueOpt::from_value(v)?), + "logo" => b.logo = Some(FromValueOpt::from_value(v)?), + "primary_color" => b.primary_color = Some(FromValueOpt::from_value(v)?), + "secondary_color" => b.secondary_color = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_business_profile.rs b/generated/stripe_shared/src/account_business_profile.rs index 50c276b7b..15c046230 100644 --- a/generated/stripe_shared/src/account_business_profile.rs +++ b/generated/stripe_shared/src/account_business_profile.rs @@ -1,20 +1,15 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountBusinessProfile { - /// The applicant's gross annual revenue for its preceding fiscal year. - pub annual_revenue: Option<stripe_shared::AccountAnnualRevenue>, - /// An estimated upper bound of employees, contractors, vendors, etc. - /// currently working for the business. - pub estimated_worker_count: Option<u64>, /// [The merchant category code for the account](https://stripe.com/docs/connect/setting-mcc). /// MCCs are used to classify businesses based on the goods or services they provide. pub mcc: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub monthly_estimated_revenue: Option<stripe_shared::AccountMonthlyEstimatedRevenue>, /// The customer-facing business name. pub name: Option<String>, /// Internal-only description of the product sold or service provided by the business. /// It's used by Stripe for risk and underwriting purposes. - #[serde(skip_serializing_if = "Option::is_none")] pub product_description: Option<String>, /// A publicly available mailing address for sending support issues to. pub support_address: Option<stripe_shared::Address>, @@ -27,3 +22,131 @@ pub struct AccountBusinessProfile { /// The business's publicly available website. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountBusinessProfileBuilder { + mcc: Option<Option<String>>, + monthly_estimated_revenue: Option<Option<stripe_shared::AccountMonthlyEstimatedRevenue>>, + name: Option<Option<String>>, + product_description: Option<Option<String>>, + support_address: Option<Option<stripe_shared::Address>>, + support_email: Option<Option<String>>, + support_phone: Option<Option<String>>, + support_url: Option<Option<String>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountBusinessProfile { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountBusinessProfile>, + builder: AccountBusinessProfileBuilder, + } + + impl Visitor for Place<AccountBusinessProfile> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountBusinessProfileBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountBusinessProfileBuilder { + type Out = AccountBusinessProfile; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "mcc" => Deserialize::begin(&mut self.mcc), + "monthly_estimated_revenue" => Deserialize::begin(&mut self.monthly_estimated_revenue), + "name" => Deserialize::begin(&mut self.name), + "product_description" => Deserialize::begin(&mut self.product_description), + "support_address" => Deserialize::begin(&mut self.support_address), + "support_email" => Deserialize::begin(&mut self.support_email), + "support_phone" => Deserialize::begin(&mut self.support_phone), + "support_url" => Deserialize::begin(&mut self.support_url), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + mcc: Deserialize::default(), + monthly_estimated_revenue: Deserialize::default(), + name: Deserialize::default(), + product_description: Deserialize::default(), + support_address: Deserialize::default(), + support_email: Deserialize::default(), + support_phone: Deserialize::default(), + support_url: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let mcc = self.mcc.take()?; + let monthly_estimated_revenue = self.monthly_estimated_revenue.take()?; + let name = self.name.take()?; + let product_description = self.product_description.take()?; + let support_address = self.support_address.take()?; + let support_email = self.support_email.take()?; + let support_phone = self.support_phone.take()?; + let support_url = self.support_url.take()?; + let url = self.url.take()?; + + Some(Self::Out { mcc, monthly_estimated_revenue, name, product_description, support_address, support_email, support_phone, support_url, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountBusinessProfile { + type Builder = AccountBusinessProfileBuilder; + } + + impl FromValueOpt for AccountBusinessProfile { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountBusinessProfileBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "mcc" => b.mcc = Some(FromValueOpt::from_value(v)?), + "monthly_estimated_revenue" => b.monthly_estimated_revenue = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "product_description" => b.product_description = Some(FromValueOpt::from_value(v)?), + "support_address" => b.support_address = Some(FromValueOpt::from_value(v)?), + "support_email" => b.support_email = Some(FromValueOpt::from_value(v)?), + "support_phone" => b.support_phone = Some(FromValueOpt::from_value(v)?), + "support_url" => b.support_url = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_capabilities.rs b/generated/stripe_shared/src/account_capabilities.rs index ba6b0b499..e6c3ab42b 100644 --- a/generated/stripe_shared/src/account_capabilities.rs +++ b/generated/stripe_shared/src/account_capabilities.rs @@ -1,120 +1,388 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountCapabilities { /// The status of the Canadian pre-authorized debits payments capability of the account, or whether the account can directly process Canadian pre-authorized debits charges. - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Affirm capability of the account, or whether the account can directly process Affirm charges. - #[serde(skip_serializing_if = "Option::is_none")] pub affirm_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Afterpay Clearpay capability of the account, or whether the account can directly process Afterpay Clearpay charges. - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the BECS Direct Debit (AU) payments capability of the account, or whether the account can directly process BECS Direct Debit (AU) charges. - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Bacs Direct Debits payments capability of the account, or whether the account can directly process Bacs Direct Debits charges. - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Bancontact payments capability of the account, or whether the account can directly process Bancontact charges. - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the customer_balance payments capability of the account, or whether the account can directly process customer_balance charges. - #[serde(skip_serializing_if = "Option::is_none")] pub bank_transfer_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the blik payments capability of the account, or whether the account can directly process blik charges. - #[serde(skip_serializing_if = "Option::is_none")] pub blik_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the boleto payments capability of the account, or whether the account can directly process boleto charges. - #[serde(skip_serializing_if = "Option::is_none")] pub boleto_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the card issuing capability of the account, or whether you can use Issuing to distribute funds on cards. - #[serde(skip_serializing_if = "Option::is_none")] pub card_issuing: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the card payments capability of the account, or whether the account can directly process credit and debit card charges. - #[serde(skip_serializing_if = "Option::is_none")] pub card_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Cartes Bancaires payments capability of the account, or whether the account can directly process Cartes Bancaires card charges in EUR currency. - #[serde(skip_serializing_if = "Option::is_none")] pub cartes_bancaires_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Cash App Pay capability of the account, or whether the account can directly process Cash App Pay payments. - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the EPS payments capability of the account, or whether the account can directly process EPS charges. - #[serde(skip_serializing_if = "Option::is_none")] pub eps_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the FPX payments capability of the account, or whether the account can directly process FPX charges. - #[serde(skip_serializing_if = "Option::is_none")] pub fpx_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the giropay payments capability of the account, or whether the account can directly process giropay charges. - #[serde(skip_serializing_if = "Option::is_none")] pub giropay_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the GrabPay payments capability of the account, or whether the account can directly process GrabPay charges. - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the iDEAL payments capability of the account, or whether the account can directly process iDEAL charges. - #[serde(skip_serializing_if = "Option::is_none")] pub ideal_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the india_international_payments capability of the account, or whether the account can process international charges (non INR) in India. - #[serde(skip_serializing_if = "Option::is_none")] pub india_international_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the JCB payments capability of the account, or whether the account (Japan only) can directly process JCB credit card charges in JPY currency. - #[serde(skip_serializing_if = "Option::is_none")] pub jcb_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Klarna payments capability of the account, or whether the account can directly process Klarna charges. - #[serde(skip_serializing_if = "Option::is_none")] pub klarna_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the konbini payments capability of the account, or whether the account can directly process konbini charges. - #[serde(skip_serializing_if = "Option::is_none")] pub konbini_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the legacy payments capability of the account. - #[serde(skip_serializing_if = "Option::is_none")] pub legacy_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the link_payments capability of the account, or whether the account can directly process Link charges. - #[serde(skip_serializing_if = "Option::is_none")] pub link_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the OXXO payments capability of the account, or whether the account can directly process OXXO charges. - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the P24 payments capability of the account, or whether the account can directly process P24 charges. - #[serde(skip_serializing_if = "Option::is_none")] pub p24_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the paynow payments capability of the account, or whether the account can directly process paynow charges. - #[serde(skip_serializing_if = "Option::is_none")] pub paynow_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the promptpay payments capability of the account, or whether the account can directly process promptpay charges. - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the RevolutPay capability of the account, or whether the account can directly process RevolutPay payments. - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the SEPA Direct Debits payments capability of the account, or whether the account can directly process SEPA Direct Debits charges. - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Sofort payments capability of the account, or whether the account can directly process Sofort charges. - #[serde(skip_serializing_if = "Option::is_none")] pub sofort_payments: Option<stripe_shared::AccountCapabilitiesStatus>, - /// The status of the Swish capability of the account, or whether the account can directly process Swish payments. - #[serde(skip_serializing_if = "Option::is_none")] - pub swish_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the tax reporting 1099-K (US) capability of the account. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_reporting_us_1099_k: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the tax reporting 1099-MISC (US) capability of the account. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_reporting_us_1099_misc: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the transfers capability of the account, or whether your platform can transfer funds to the account. - #[serde(skip_serializing_if = "Option::is_none")] pub transfers: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the banking capability, or whether the account can have bank accounts. - #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the US bank account ACH payments capability of the account, or whether the account can directly process US bank account charges. - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account_ach_payments: Option<stripe_shared::AccountCapabilitiesStatus>, /// The status of the Zip capability of the account, or whether the account can directly process Zip charges. - #[serde(skip_serializing_if = "Option::is_none")] pub zip_payments: Option<stripe_shared::AccountCapabilitiesStatus>, } +#[cfg(feature = "min-ser")] +pub struct AccountCapabilitiesBuilder { + acss_debit_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + affirm_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + afterpay_clearpay_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + au_becs_debit_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + bacs_debit_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + bancontact_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + bank_transfer_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + blik_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + boleto_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + card_issuing: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + card_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + cartes_bancaires_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + cashapp_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + eps_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + fpx_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + giropay_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + grabpay_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + ideal_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + india_international_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + jcb_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + klarna_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + konbini_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + legacy_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + link_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + oxxo_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + p24_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + paynow_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + promptpay_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + revolut_pay_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + sepa_debit_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + sofort_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + tax_reporting_us_1099_k: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + tax_reporting_us_1099_misc: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + transfers: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + treasury: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + us_bank_account_ach_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, + zip_payments: Option<Option<stripe_shared::AccountCapabilitiesStatus>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountCapabilities { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountCapabilities>, + builder: AccountCapabilitiesBuilder, + } + + impl Visitor for Place<AccountCapabilities> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountCapabilitiesBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountCapabilitiesBuilder { + type Out = AccountCapabilities; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit_payments" => Deserialize::begin(&mut self.acss_debit_payments), + "affirm_payments" => Deserialize::begin(&mut self.affirm_payments), + "afterpay_clearpay_payments" => Deserialize::begin(&mut self.afterpay_clearpay_payments), + "au_becs_debit_payments" => Deserialize::begin(&mut self.au_becs_debit_payments), + "bacs_debit_payments" => Deserialize::begin(&mut self.bacs_debit_payments), + "bancontact_payments" => Deserialize::begin(&mut self.bancontact_payments), + "bank_transfer_payments" => Deserialize::begin(&mut self.bank_transfer_payments), + "blik_payments" => Deserialize::begin(&mut self.blik_payments), + "boleto_payments" => Deserialize::begin(&mut self.boleto_payments), + "card_issuing" => Deserialize::begin(&mut self.card_issuing), + "card_payments" => Deserialize::begin(&mut self.card_payments), + "cartes_bancaires_payments" => Deserialize::begin(&mut self.cartes_bancaires_payments), + "cashapp_payments" => Deserialize::begin(&mut self.cashapp_payments), + "eps_payments" => Deserialize::begin(&mut self.eps_payments), + "fpx_payments" => Deserialize::begin(&mut self.fpx_payments), + "giropay_payments" => Deserialize::begin(&mut self.giropay_payments), + "grabpay_payments" => Deserialize::begin(&mut self.grabpay_payments), + "ideal_payments" => Deserialize::begin(&mut self.ideal_payments), + "india_international_payments" => Deserialize::begin(&mut self.india_international_payments), + "jcb_payments" => Deserialize::begin(&mut self.jcb_payments), + "klarna_payments" => Deserialize::begin(&mut self.klarna_payments), + "konbini_payments" => Deserialize::begin(&mut self.konbini_payments), + "legacy_payments" => Deserialize::begin(&mut self.legacy_payments), + "link_payments" => Deserialize::begin(&mut self.link_payments), + "oxxo_payments" => Deserialize::begin(&mut self.oxxo_payments), + "p24_payments" => Deserialize::begin(&mut self.p24_payments), + "paynow_payments" => Deserialize::begin(&mut self.paynow_payments), + "promptpay_payments" => Deserialize::begin(&mut self.promptpay_payments), + "revolut_pay_payments" => Deserialize::begin(&mut self.revolut_pay_payments), + "sepa_debit_payments" => Deserialize::begin(&mut self.sepa_debit_payments), + "sofort_payments" => Deserialize::begin(&mut self.sofort_payments), + "tax_reporting_us_1099_k" => Deserialize::begin(&mut self.tax_reporting_us_1099_k), + "tax_reporting_us_1099_misc" => Deserialize::begin(&mut self.tax_reporting_us_1099_misc), + "transfers" => Deserialize::begin(&mut self.transfers), + "treasury" => Deserialize::begin(&mut self.treasury), + "us_bank_account_ach_payments" => Deserialize::begin(&mut self.us_bank_account_ach_payments), + "zip_payments" => Deserialize::begin(&mut self.zip_payments), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit_payments: Deserialize::default(), + affirm_payments: Deserialize::default(), + afterpay_clearpay_payments: Deserialize::default(), + au_becs_debit_payments: Deserialize::default(), + bacs_debit_payments: Deserialize::default(), + bancontact_payments: Deserialize::default(), + bank_transfer_payments: Deserialize::default(), + blik_payments: Deserialize::default(), + boleto_payments: Deserialize::default(), + card_issuing: Deserialize::default(), + card_payments: Deserialize::default(), + cartes_bancaires_payments: Deserialize::default(), + cashapp_payments: Deserialize::default(), + eps_payments: Deserialize::default(), + fpx_payments: Deserialize::default(), + giropay_payments: Deserialize::default(), + grabpay_payments: Deserialize::default(), + ideal_payments: Deserialize::default(), + india_international_payments: Deserialize::default(), + jcb_payments: Deserialize::default(), + klarna_payments: Deserialize::default(), + konbini_payments: Deserialize::default(), + legacy_payments: Deserialize::default(), + link_payments: Deserialize::default(), + oxxo_payments: Deserialize::default(), + p24_payments: Deserialize::default(), + paynow_payments: Deserialize::default(), + promptpay_payments: Deserialize::default(), + revolut_pay_payments: Deserialize::default(), + sepa_debit_payments: Deserialize::default(), + sofort_payments: Deserialize::default(), + tax_reporting_us_1099_k: Deserialize::default(), + tax_reporting_us_1099_misc: Deserialize::default(), + transfers: Deserialize::default(), + treasury: Deserialize::default(), + us_bank_account_ach_payments: Deserialize::default(), + zip_payments: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit_payments = self.acss_debit_payments.take()?; + let affirm_payments = self.affirm_payments.take()?; + let afterpay_clearpay_payments = self.afterpay_clearpay_payments.take()?; + let au_becs_debit_payments = self.au_becs_debit_payments.take()?; + let bacs_debit_payments = self.bacs_debit_payments.take()?; + let bancontact_payments = self.bancontact_payments.take()?; + let bank_transfer_payments = self.bank_transfer_payments.take()?; + let blik_payments = self.blik_payments.take()?; + let boleto_payments = self.boleto_payments.take()?; + let card_issuing = self.card_issuing.take()?; + let card_payments = self.card_payments.take()?; + let cartes_bancaires_payments = self.cartes_bancaires_payments.take()?; + let cashapp_payments = self.cashapp_payments.take()?; + let eps_payments = self.eps_payments.take()?; + let fpx_payments = self.fpx_payments.take()?; + let giropay_payments = self.giropay_payments.take()?; + let grabpay_payments = self.grabpay_payments.take()?; + let ideal_payments = self.ideal_payments.take()?; + let india_international_payments = self.india_international_payments.take()?; + let jcb_payments = self.jcb_payments.take()?; + let klarna_payments = self.klarna_payments.take()?; + let konbini_payments = self.konbini_payments.take()?; + let legacy_payments = self.legacy_payments.take()?; + let link_payments = self.link_payments.take()?; + let oxxo_payments = self.oxxo_payments.take()?; + let p24_payments = self.p24_payments.take()?; + let paynow_payments = self.paynow_payments.take()?; + let promptpay_payments = self.promptpay_payments.take()?; + let revolut_pay_payments = self.revolut_pay_payments.take()?; + let sepa_debit_payments = self.sepa_debit_payments.take()?; + let sofort_payments = self.sofort_payments.take()?; + let tax_reporting_us_1099_k = self.tax_reporting_us_1099_k.take()?; + let tax_reporting_us_1099_misc = self.tax_reporting_us_1099_misc.take()?; + let transfers = self.transfers.take()?; + let treasury = self.treasury.take()?; + let us_bank_account_ach_payments = self.us_bank_account_ach_payments.take()?; + let zip_payments = self.zip_payments.take()?; + + Some(Self::Out { + acss_debit_payments, + affirm_payments, + afterpay_clearpay_payments, + au_becs_debit_payments, + bacs_debit_payments, + bancontact_payments, + bank_transfer_payments, + blik_payments, + boleto_payments, + card_issuing, + card_payments, + cartes_bancaires_payments, + cashapp_payments, + eps_payments, + fpx_payments, + giropay_payments, + grabpay_payments, + ideal_payments, + india_international_payments, + jcb_payments, + klarna_payments, + konbini_payments, + legacy_payments, + link_payments, + oxxo_payments, + p24_payments, + paynow_payments, + promptpay_payments, + revolut_pay_payments, + sepa_debit_payments, + sofort_payments, + tax_reporting_us_1099_k, + tax_reporting_us_1099_misc, + transfers, + treasury, + us_bank_account_ach_payments, + zip_payments, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountCapabilities { + type Builder = AccountCapabilitiesBuilder; + } + + impl FromValueOpt for AccountCapabilities { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountCapabilitiesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit_payments" => b.acss_debit_payments = Some(FromValueOpt::from_value(v)?), + "affirm_payments" => b.affirm_payments = Some(FromValueOpt::from_value(v)?), + "afterpay_clearpay_payments" => b.afterpay_clearpay_payments = Some(FromValueOpt::from_value(v)?), + "au_becs_debit_payments" => b.au_becs_debit_payments = Some(FromValueOpt::from_value(v)?), + "bacs_debit_payments" => b.bacs_debit_payments = Some(FromValueOpt::from_value(v)?), + "bancontact_payments" => b.bancontact_payments = Some(FromValueOpt::from_value(v)?), + "bank_transfer_payments" => b.bank_transfer_payments = Some(FromValueOpt::from_value(v)?), + "blik_payments" => b.blik_payments = Some(FromValueOpt::from_value(v)?), + "boleto_payments" => b.boleto_payments = Some(FromValueOpt::from_value(v)?), + "card_issuing" => b.card_issuing = Some(FromValueOpt::from_value(v)?), + "card_payments" => b.card_payments = Some(FromValueOpt::from_value(v)?), + "cartes_bancaires_payments" => b.cartes_bancaires_payments = Some(FromValueOpt::from_value(v)?), + "cashapp_payments" => b.cashapp_payments = Some(FromValueOpt::from_value(v)?), + "eps_payments" => b.eps_payments = Some(FromValueOpt::from_value(v)?), + "fpx_payments" => b.fpx_payments = Some(FromValueOpt::from_value(v)?), + "giropay_payments" => b.giropay_payments = Some(FromValueOpt::from_value(v)?), + "grabpay_payments" => b.grabpay_payments = Some(FromValueOpt::from_value(v)?), + "ideal_payments" => b.ideal_payments = Some(FromValueOpt::from_value(v)?), + "india_international_payments" => b.india_international_payments = Some(FromValueOpt::from_value(v)?), + "jcb_payments" => b.jcb_payments = Some(FromValueOpt::from_value(v)?), + "klarna_payments" => b.klarna_payments = Some(FromValueOpt::from_value(v)?), + "konbini_payments" => b.konbini_payments = Some(FromValueOpt::from_value(v)?), + "legacy_payments" => b.legacy_payments = Some(FromValueOpt::from_value(v)?), + "link_payments" => b.link_payments = Some(FromValueOpt::from_value(v)?), + "oxxo_payments" => b.oxxo_payments = Some(FromValueOpt::from_value(v)?), + "p24_payments" => b.p24_payments = Some(FromValueOpt::from_value(v)?), + "paynow_payments" => b.paynow_payments = Some(FromValueOpt::from_value(v)?), + "promptpay_payments" => b.promptpay_payments = Some(FromValueOpt::from_value(v)?), + "revolut_pay_payments" => b.revolut_pay_payments = Some(FromValueOpt::from_value(v)?), + "sepa_debit_payments" => b.sepa_debit_payments = Some(FromValueOpt::from_value(v)?), + "sofort_payments" => b.sofort_payments = Some(FromValueOpt::from_value(v)?), + "tax_reporting_us_1099_k" => b.tax_reporting_us_1099_k = Some(FromValueOpt::from_value(v)?), + "tax_reporting_us_1099_misc" => b.tax_reporting_us_1099_misc = Some(FromValueOpt::from_value(v)?), + "transfers" => b.transfers = Some(FromValueOpt::from_value(v)?), + "treasury" => b.treasury = Some(FromValueOpt::from_value(v)?), + "us_bank_account_ach_payments" => b.us_bank_account_ach_payments = Some(FromValueOpt::from_value(v)?), + "zip_payments" => b.zip_payments = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; #[derive(Copy, Clone, Eq, PartialEq)] pub enum AccountCapabilitiesStatus { Active, @@ -167,7 +435,24 @@ impl<'de> serde::Deserialize<'de> for AccountCapabilitiesStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for AccountCapabilitiesStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for AccountCapabilitiesStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for AccountCapabilitiesStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<AccountCapabilitiesStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountCapabilitiesStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(AccountCapabilitiesStatus); diff --git a/generated/stripe_shared/src/account_capability_future_requirements.rs b/generated/stripe_shared/src/account_capability_future_requirements.rs index ece1afa90..760deedec 100644 --- a/generated/stripe_shared/src/account_capability_future_requirements.rs +++ b/generated/stripe_shared/src/account_capability_future_requirements.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountCapabilityFutureRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>, @@ -24,3 +26,126 @@ pub struct AccountCapabilityFutureRequirements { /// If verification fails, these fields move to `eventually_due` or `currently_due`. pub pending_verification: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountCapabilityFutureRequirementsBuilder { + alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>, + current_deadline: Option<Option<stripe_types::Timestamp>>, + currently_due: Option<Vec<String>>, + disabled_reason: Option<Option<String>>, + errors: Option<Vec<stripe_shared::AccountRequirementsError>>, + eventually_due: Option<Vec<String>>, + past_due: Option<Vec<String>>, + pending_verification: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountCapabilityFutureRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountCapabilityFutureRequirements>, + builder: AccountCapabilityFutureRequirementsBuilder, + } + + impl Visitor for Place<AccountCapabilityFutureRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountCapabilityFutureRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountCapabilityFutureRequirementsBuilder { + type Out = AccountCapabilityFutureRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alternatives" => Deserialize::begin(&mut self.alternatives), + "current_deadline" => Deserialize::begin(&mut self.current_deadline), + "currently_due" => Deserialize::begin(&mut self.currently_due), + "disabled_reason" => Deserialize::begin(&mut self.disabled_reason), + "errors" => Deserialize::begin(&mut self.errors), + "eventually_due" => Deserialize::begin(&mut self.eventually_due), + "past_due" => Deserialize::begin(&mut self.past_due), + "pending_verification" => Deserialize::begin(&mut self.pending_verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alternatives: Deserialize::default(), + current_deadline: Deserialize::default(), + currently_due: Deserialize::default(), + disabled_reason: Deserialize::default(), + errors: Deserialize::default(), + eventually_due: Deserialize::default(), + past_due: Deserialize::default(), + pending_verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alternatives = self.alternatives.take()?; + let current_deadline = self.current_deadline.take()?; + let currently_due = self.currently_due.take()?; + let disabled_reason = self.disabled_reason.take()?; + let errors = self.errors.take()?; + let eventually_due = self.eventually_due.take()?; + let past_due = self.past_due.take()?; + let pending_verification = self.pending_verification.take()?; + + Some(Self::Out { alternatives, current_deadline, currently_due, disabled_reason, errors, eventually_due, past_due, pending_verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountCapabilityFutureRequirements { + type Builder = AccountCapabilityFutureRequirementsBuilder; + } + + impl FromValueOpt for AccountCapabilityFutureRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountCapabilityFutureRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alternatives" => b.alternatives = Some(FromValueOpt::from_value(v)?), + "current_deadline" => b.current_deadline = Some(FromValueOpt::from_value(v)?), + "currently_due" => b.currently_due = Some(FromValueOpt::from_value(v)?), + "disabled_reason" => b.disabled_reason = Some(FromValueOpt::from_value(v)?), + "errors" => b.errors = Some(FromValueOpt::from_value(v)?), + "eventually_due" => b.eventually_due = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "pending_verification" => b.pending_verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_capability_requirements.rs b/generated/stripe_shared/src/account_capability_requirements.rs index b38d68d93..cdb48b668 100644 --- a/generated/stripe_shared/src/account_capability_requirements.rs +++ b/generated/stripe_shared/src/account_capability_requirements.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountCapabilityRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>, @@ -31,3 +33,126 @@ pub struct AccountCapabilityRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountCapabilityRequirementsBuilder { + alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>, + current_deadline: Option<Option<stripe_types::Timestamp>>, + currently_due: Option<Vec<String>>, + disabled_reason: Option<Option<String>>, + errors: Option<Vec<stripe_shared::AccountRequirementsError>>, + eventually_due: Option<Vec<String>>, + past_due: Option<Vec<String>>, + pending_verification: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountCapabilityRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountCapabilityRequirements>, + builder: AccountCapabilityRequirementsBuilder, + } + + impl Visitor for Place<AccountCapabilityRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountCapabilityRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountCapabilityRequirementsBuilder { + type Out = AccountCapabilityRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alternatives" => Deserialize::begin(&mut self.alternatives), + "current_deadline" => Deserialize::begin(&mut self.current_deadline), + "currently_due" => Deserialize::begin(&mut self.currently_due), + "disabled_reason" => Deserialize::begin(&mut self.disabled_reason), + "errors" => Deserialize::begin(&mut self.errors), + "eventually_due" => Deserialize::begin(&mut self.eventually_due), + "past_due" => Deserialize::begin(&mut self.past_due), + "pending_verification" => Deserialize::begin(&mut self.pending_verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alternatives: Deserialize::default(), + current_deadline: Deserialize::default(), + currently_due: Deserialize::default(), + disabled_reason: Deserialize::default(), + errors: Deserialize::default(), + eventually_due: Deserialize::default(), + past_due: Deserialize::default(), + pending_verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alternatives = self.alternatives.take()?; + let current_deadline = self.current_deadline.take()?; + let currently_due = self.currently_due.take()?; + let disabled_reason = self.disabled_reason.take()?; + let errors = self.errors.take()?; + let eventually_due = self.eventually_due.take()?; + let past_due = self.past_due.take()?; + let pending_verification = self.pending_verification.take()?; + + Some(Self::Out { alternatives, current_deadline, currently_due, disabled_reason, errors, eventually_due, past_due, pending_verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountCapabilityRequirements { + type Builder = AccountCapabilityRequirementsBuilder; + } + + impl FromValueOpt for AccountCapabilityRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountCapabilityRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alternatives" => b.alternatives = Some(FromValueOpt::from_value(v)?), + "current_deadline" => b.current_deadline = Some(FromValueOpt::from_value(v)?), + "currently_due" => b.currently_due = Some(FromValueOpt::from_value(v)?), + "disabled_reason" => b.disabled_reason = Some(FromValueOpt::from_value(v)?), + "errors" => b.errors = Some(FromValueOpt::from_value(v)?), + "eventually_due" => b.eventually_due = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "pending_verification" => b.pending_verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_card_issuing_settings.rs b/generated/stripe_shared/src/account_card_issuing_settings.rs index 7c781fa69..596e69596 100644 --- a/generated/stripe_shared/src/account_card_issuing_settings.rs +++ b/generated/stripe_shared/src/account_card_issuing_settings.rs @@ -1,5 +1,92 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountCardIssuingSettings { - #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option<stripe_shared::CardIssuingAccountTermsOfService>, } +#[cfg(feature = "min-ser")] +pub struct AccountCardIssuingSettingsBuilder { + tos_acceptance: Option<Option<stripe_shared::CardIssuingAccountTermsOfService>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountCardIssuingSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountCardIssuingSettings>, + builder: AccountCardIssuingSettingsBuilder, + } + + impl Visitor for Place<AccountCardIssuingSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountCardIssuingSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountCardIssuingSettingsBuilder { + type Out = AccountCardIssuingSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "tos_acceptance" => Deserialize::begin(&mut self.tos_acceptance), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tos_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let tos_acceptance = self.tos_acceptance.take()?; + + Some(Self::Out { tos_acceptance }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountCardIssuingSettings { + type Builder = AccountCardIssuingSettingsBuilder; + } + + impl FromValueOpt for AccountCardIssuingSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountCardIssuingSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "tos_acceptance" => b.tos_acceptance = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_card_payments_settings.rs b/generated/stripe_shared/src/account_card_payments_settings.rs index 13dbad24a..a5f8e645f 100644 --- a/generated/stripe_shared/src/account_card_payments_settings.rs +++ b/generated/stripe_shared/src/account_card_payments_settings.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountCardPaymentsSettings { - #[serde(skip_serializing_if = "Option::is_none")] pub decline_on: Option<stripe_shared::AccountDeclineChargeOn>, /// The default text that appears on credit card statements when a charge is made. /// This field prefixes any dynamic `statement_descriptor` specified on the charge. @@ -15,3 +16,106 @@ pub struct AccountCardPaymentsSettings { /// `statement_descriptor_prefix_kanji` is useful for maximizing descriptor space for the dynamic portion. pub statement_descriptor_prefix_kanji: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountCardPaymentsSettingsBuilder { + decline_on: Option<Option<stripe_shared::AccountDeclineChargeOn>>, + statement_descriptor_prefix: Option<Option<String>>, + statement_descriptor_prefix_kana: Option<Option<String>>, + statement_descriptor_prefix_kanji: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountCardPaymentsSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountCardPaymentsSettings>, + builder: AccountCardPaymentsSettingsBuilder, + } + + impl Visitor for Place<AccountCardPaymentsSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountCardPaymentsSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountCardPaymentsSettingsBuilder { + type Out = AccountCardPaymentsSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "decline_on" => Deserialize::begin(&mut self.decline_on), + "statement_descriptor_prefix" => Deserialize::begin(&mut self.statement_descriptor_prefix), + "statement_descriptor_prefix_kana" => Deserialize::begin(&mut self.statement_descriptor_prefix_kana), + "statement_descriptor_prefix_kanji" => Deserialize::begin(&mut self.statement_descriptor_prefix_kanji), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + decline_on: Deserialize::default(), + statement_descriptor_prefix: Deserialize::default(), + statement_descriptor_prefix_kana: Deserialize::default(), + statement_descriptor_prefix_kanji: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let decline_on = self.decline_on.take()?; + let statement_descriptor_prefix = self.statement_descriptor_prefix.take()?; + let statement_descriptor_prefix_kana = self.statement_descriptor_prefix_kana.take()?; + let statement_descriptor_prefix_kanji = self.statement_descriptor_prefix_kanji.take()?; + + Some(Self::Out { decline_on, statement_descriptor_prefix, statement_descriptor_prefix_kana, statement_descriptor_prefix_kanji }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountCardPaymentsSettings { + type Builder = AccountCardPaymentsSettingsBuilder; + } + + impl FromValueOpt for AccountCardPaymentsSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountCardPaymentsSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "decline_on" => b.decline_on = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_prefix" => b.statement_descriptor_prefix = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_prefix_kana" => b.statement_descriptor_prefix_kana = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_prefix_kanji" => b.statement_descriptor_prefix_kanji = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_dashboard_settings.rs b/generated/stripe_shared/src/account_dashboard_settings.rs index 59f2808aa..079d40595 100644 --- a/generated/stripe_shared/src/account_dashboard_settings.rs +++ b/generated/stripe_shared/src/account_dashboard_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountDashboardSettings { /// The display name for this account. /// This is used on the Stripe Dashboard to differentiate between accounts. @@ -7,3 +9,93 @@ pub struct AccountDashboardSettings { /// A list of possible time zone values is maintained at the [IANA Time Zone Database](http://www.iana.org/time-zones). pub timezone: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountDashboardSettingsBuilder { + display_name: Option<Option<String>>, + timezone: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountDashboardSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountDashboardSettings>, + builder: AccountDashboardSettingsBuilder, + } + + impl Visitor for Place<AccountDashboardSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountDashboardSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountDashboardSettingsBuilder { + type Out = AccountDashboardSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "display_name" => Deserialize::begin(&mut self.display_name), + "timezone" => Deserialize::begin(&mut self.timezone), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { display_name: Deserialize::default(), timezone: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let display_name = self.display_name.take()?; + let timezone = self.timezone.take()?; + + Some(Self::Out { display_name, timezone }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountDashboardSettings { + type Builder = AccountDashboardSettingsBuilder; + } + + impl FromValueOpt for AccountDashboardSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountDashboardSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "timezone" => b.timezone = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_decline_charge_on.rs b/generated/stripe_shared/src/account_decline_charge_on.rs index 122a38980..557ee918a 100644 --- a/generated/stripe_shared/src/account_decline_charge_on.rs +++ b/generated/stripe_shared/src/account_decline_charge_on.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountDeclineChargeOn { /// Whether Stripe automatically declines charges with an incorrect ZIP or postal code. /// This setting only applies when a ZIP or postal code is provided and they fail bank verification. @@ -7,3 +9,93 @@ pub struct AccountDeclineChargeOn { /// This setting only applies when a CVC is provided and it fails bank verification. pub cvc_failure: bool, } +#[cfg(feature = "min-ser")] +pub struct AccountDeclineChargeOnBuilder { + avs_failure: Option<bool>, + cvc_failure: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountDeclineChargeOn { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountDeclineChargeOn>, + builder: AccountDeclineChargeOnBuilder, + } + + impl Visitor for Place<AccountDeclineChargeOn> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountDeclineChargeOnBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountDeclineChargeOnBuilder { + type Out = AccountDeclineChargeOn; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "avs_failure" => Deserialize::begin(&mut self.avs_failure), + "cvc_failure" => Deserialize::begin(&mut self.cvc_failure), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { avs_failure: Deserialize::default(), cvc_failure: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let avs_failure = self.avs_failure.take()?; + let cvc_failure = self.cvc_failure.take()?; + + Some(Self::Out { avs_failure, cvc_failure }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountDeclineChargeOn { + type Builder = AccountDeclineChargeOnBuilder; + } + + impl FromValueOpt for AccountDeclineChargeOn { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountDeclineChargeOnBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "avs_failure" => b.avs_failure = Some(FromValueOpt::from_value(v)?), + "cvc_failure" => b.cvc_failure = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_future_requirements.rs b/generated/stripe_shared/src/account_future_requirements.rs index 2edb3fecc..4803b7091 100644 --- a/generated/stripe_shared/src/account_future_requirements.rs +++ b/generated/stripe_shared/src/account_future_requirements.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountFutureRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>, @@ -24,3 +26,126 @@ pub struct AccountFutureRequirements { /// If verification fails, these fields move to `eventually_due` or `currently_due`. pub pending_verification: Option<Vec<String>>, } +#[cfg(feature = "min-ser")] +pub struct AccountFutureRequirementsBuilder { + alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>, + current_deadline: Option<Option<stripe_types::Timestamp>>, + currently_due: Option<Option<Vec<String>>>, + disabled_reason: Option<Option<String>>, + errors: Option<Option<Vec<stripe_shared::AccountRequirementsError>>>, + eventually_due: Option<Option<Vec<String>>>, + past_due: Option<Option<Vec<String>>>, + pending_verification: Option<Option<Vec<String>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountFutureRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountFutureRequirements>, + builder: AccountFutureRequirementsBuilder, + } + + impl Visitor for Place<AccountFutureRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountFutureRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountFutureRequirementsBuilder { + type Out = AccountFutureRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alternatives" => Deserialize::begin(&mut self.alternatives), + "current_deadline" => Deserialize::begin(&mut self.current_deadline), + "currently_due" => Deserialize::begin(&mut self.currently_due), + "disabled_reason" => Deserialize::begin(&mut self.disabled_reason), + "errors" => Deserialize::begin(&mut self.errors), + "eventually_due" => Deserialize::begin(&mut self.eventually_due), + "past_due" => Deserialize::begin(&mut self.past_due), + "pending_verification" => Deserialize::begin(&mut self.pending_verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alternatives: Deserialize::default(), + current_deadline: Deserialize::default(), + currently_due: Deserialize::default(), + disabled_reason: Deserialize::default(), + errors: Deserialize::default(), + eventually_due: Deserialize::default(), + past_due: Deserialize::default(), + pending_verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alternatives = self.alternatives.take()?; + let current_deadline = self.current_deadline.take()?; + let currently_due = self.currently_due.take()?; + let disabled_reason = self.disabled_reason.take()?; + let errors = self.errors.take()?; + let eventually_due = self.eventually_due.take()?; + let past_due = self.past_due.take()?; + let pending_verification = self.pending_verification.take()?; + + Some(Self::Out { alternatives, current_deadline, currently_due, disabled_reason, errors, eventually_due, past_due, pending_verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountFutureRequirements { + type Builder = AccountFutureRequirementsBuilder; + } + + impl FromValueOpt for AccountFutureRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountFutureRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alternatives" => b.alternatives = Some(FromValueOpt::from_value(v)?), + "current_deadline" => b.current_deadline = Some(FromValueOpt::from_value(v)?), + "currently_due" => b.currently_due = Some(FromValueOpt::from_value(v)?), + "disabled_reason" => b.disabled_reason = Some(FromValueOpt::from_value(v)?), + "errors" => b.errors = Some(FromValueOpt::from_value(v)?), + "eventually_due" => b.eventually_due = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "pending_verification" => b.pending_verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_invoices_settings.rs b/generated/stripe_shared/src/account_invoices_settings.rs deleted file mode 100644 index f493594a8..000000000 --- a/generated/stripe_shared/src/account_invoices_settings.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct AccountInvoicesSettings { - /// The list of default Account Tax IDs to automatically include on invoices. - /// Account Tax IDs get added when an invoice is finalized. - pub default_account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>, -} diff --git a/generated/stripe_shared/src/account_monthly_estimated_revenue.rs b/generated/stripe_shared/src/account_monthly_estimated_revenue.rs index 276f7ec27..ba15fa552 100644 --- a/generated/stripe_shared/src/account_monthly_estimated_revenue.rs +++ b/generated/stripe_shared/src/account_monthly_estimated_revenue.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountMonthlyEstimatedRevenue { /// A non-negative integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub amount: i64, @@ -6,3 +8,93 @@ pub struct AccountMonthlyEstimatedRevenue { /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: stripe_types::Currency, } +#[cfg(feature = "min-ser")] +pub struct AccountMonthlyEstimatedRevenueBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountMonthlyEstimatedRevenue { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountMonthlyEstimatedRevenue>, + builder: AccountMonthlyEstimatedRevenueBuilder, + } + + impl Visitor for Place<AccountMonthlyEstimatedRevenue> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountMonthlyEstimatedRevenueBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountMonthlyEstimatedRevenueBuilder { + type Out = AccountMonthlyEstimatedRevenue; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + + Some(Self::Out { amount, currency }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountMonthlyEstimatedRevenue { + type Builder = AccountMonthlyEstimatedRevenueBuilder; + } + + impl FromValueOpt for AccountMonthlyEstimatedRevenue { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountMonthlyEstimatedRevenueBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_payments_settings.rs b/generated/stripe_shared/src/account_payments_settings.rs index a7567f7fc..aa6284155 100644 --- a/generated/stripe_shared/src/account_payments_settings.rs +++ b/generated/stripe_shared/src/account_payments_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountPaymentsSettings { /// The default text that appears on credit card statements when a charge is made. /// This field prefixes any dynamic `statement_descriptor` specified on the charge. @@ -16,3 +18,111 @@ pub struct AccountPaymentsSettings { /// `statement_descriptor_prefix_kanji` is useful for maximizing descriptor space for the dynamic portion. pub statement_descriptor_prefix_kanji: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountPaymentsSettingsBuilder { + statement_descriptor: Option<Option<String>>, + statement_descriptor_kana: Option<Option<String>>, + statement_descriptor_kanji: Option<Option<String>>, + statement_descriptor_prefix_kana: Option<Option<String>>, + statement_descriptor_prefix_kanji: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountPaymentsSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountPaymentsSettings>, + builder: AccountPaymentsSettingsBuilder, + } + + impl Visitor for Place<AccountPaymentsSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountPaymentsSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountPaymentsSettingsBuilder { + type Out = AccountPaymentsSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "statement_descriptor_kana" => Deserialize::begin(&mut self.statement_descriptor_kana), + "statement_descriptor_kanji" => Deserialize::begin(&mut self.statement_descriptor_kanji), + "statement_descriptor_prefix_kana" => Deserialize::begin(&mut self.statement_descriptor_prefix_kana), + "statement_descriptor_prefix_kanji" => Deserialize::begin(&mut self.statement_descriptor_prefix_kanji), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + statement_descriptor: Deserialize::default(), + statement_descriptor_kana: Deserialize::default(), + statement_descriptor_kanji: Deserialize::default(), + statement_descriptor_prefix_kana: Deserialize::default(), + statement_descriptor_prefix_kanji: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let statement_descriptor = self.statement_descriptor.take()?; + let statement_descriptor_kana = self.statement_descriptor_kana.take()?; + let statement_descriptor_kanji = self.statement_descriptor_kanji.take()?; + let statement_descriptor_prefix_kana = self.statement_descriptor_prefix_kana.take()?; + let statement_descriptor_prefix_kanji = self.statement_descriptor_prefix_kanji.take()?; + + Some(Self::Out { statement_descriptor, statement_descriptor_kana, statement_descriptor_kanji, statement_descriptor_prefix_kana, statement_descriptor_prefix_kanji }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountPaymentsSettings { + type Builder = AccountPaymentsSettingsBuilder; + } + + impl FromValueOpt for AccountPaymentsSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountPaymentsSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_kana" => b.statement_descriptor_kana = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_kanji" => b.statement_descriptor_kanji = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_prefix_kana" => b.statement_descriptor_prefix_kana = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_prefix_kanji" => b.statement_descriptor_prefix_kanji = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_payout_settings.rs b/generated/stripe_shared/src/account_payout_settings.rs index 2cfd61c37..fb5a2bfcb 100644 --- a/generated/stripe_shared/src/account_payout_settings.rs +++ b/generated/stripe_shared/src/account_payout_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountPayoutSettings { /// A Boolean indicating if Stripe should try to reclaim negative balances from an attached bank account. /// See our [Understanding Connect Account Balances](https://stripe.com/docs/connect/account-balances) documentation for details. @@ -9,3 +11,97 @@ pub struct AccountPayoutSettings { /// If not set, this defaults to the platform's bank descriptor as set in the Dashboard. pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountPayoutSettingsBuilder { + debit_negative_balances: Option<bool>, + schedule: Option<stripe_shared::TransferSchedule>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountPayoutSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountPayoutSettings>, + builder: AccountPayoutSettingsBuilder, + } + + impl Visitor for Place<AccountPayoutSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountPayoutSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountPayoutSettingsBuilder { + type Out = AccountPayoutSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "debit_negative_balances" => Deserialize::begin(&mut self.debit_negative_balances), + "schedule" => Deserialize::begin(&mut self.schedule), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { debit_negative_balances: Deserialize::default(), schedule: Deserialize::default(), statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let debit_negative_balances = self.debit_negative_balances.take()?; + let schedule = self.schedule.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { debit_negative_balances, schedule, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountPayoutSettings { + type Builder = AccountPayoutSettingsBuilder; + } + + impl FromValueOpt for AccountPayoutSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountPayoutSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "debit_negative_balances" => b.debit_negative_balances = Some(FromValueOpt::from_value(v)?), + "schedule" => b.schedule = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_requirements.rs b/generated/stripe_shared/src/account_requirements.rs index 0aa4c8a44..577c2120f 100644 --- a/generated/stripe_shared/src/account_requirements.rs +++ b/generated/stripe_shared/src/account_requirements.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>, @@ -25,3 +27,126 @@ pub struct AccountRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Option<Vec<String>>, } +#[cfg(feature = "min-ser")] +pub struct AccountRequirementsBuilder { + alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>, + current_deadline: Option<Option<stripe_types::Timestamp>>, + currently_due: Option<Option<Vec<String>>>, + disabled_reason: Option<Option<String>>, + errors: Option<Option<Vec<stripe_shared::AccountRequirementsError>>>, + eventually_due: Option<Option<Vec<String>>>, + past_due: Option<Option<Vec<String>>>, + pending_verification: Option<Option<Vec<String>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountRequirements>, + builder: AccountRequirementsBuilder, + } + + impl Visitor for Place<AccountRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountRequirementsBuilder { + type Out = AccountRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alternatives" => Deserialize::begin(&mut self.alternatives), + "current_deadline" => Deserialize::begin(&mut self.current_deadline), + "currently_due" => Deserialize::begin(&mut self.currently_due), + "disabled_reason" => Deserialize::begin(&mut self.disabled_reason), + "errors" => Deserialize::begin(&mut self.errors), + "eventually_due" => Deserialize::begin(&mut self.eventually_due), + "past_due" => Deserialize::begin(&mut self.past_due), + "pending_verification" => Deserialize::begin(&mut self.pending_verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alternatives: Deserialize::default(), + current_deadline: Deserialize::default(), + currently_due: Deserialize::default(), + disabled_reason: Deserialize::default(), + errors: Deserialize::default(), + eventually_due: Deserialize::default(), + past_due: Deserialize::default(), + pending_verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alternatives = self.alternatives.take()?; + let current_deadline = self.current_deadline.take()?; + let currently_due = self.currently_due.take()?; + let disabled_reason = self.disabled_reason.take()?; + let errors = self.errors.take()?; + let eventually_due = self.eventually_due.take()?; + let past_due = self.past_due.take()?; + let pending_verification = self.pending_verification.take()?; + + Some(Self::Out { alternatives, current_deadline, currently_due, disabled_reason, errors, eventually_due, past_due, pending_verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountRequirements { + type Builder = AccountRequirementsBuilder; + } + + impl FromValueOpt for AccountRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alternatives" => b.alternatives = Some(FromValueOpt::from_value(v)?), + "current_deadline" => b.current_deadline = Some(FromValueOpt::from_value(v)?), + "currently_due" => b.currently_due = Some(FromValueOpt::from_value(v)?), + "disabled_reason" => b.disabled_reason = Some(FromValueOpt::from_value(v)?), + "errors" => b.errors = Some(FromValueOpt::from_value(v)?), + "eventually_due" => b.eventually_due = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "pending_verification" => b.pending_verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_requirements_alternative.rs b/generated/stripe_shared/src/account_requirements_alternative.rs index 31d08a601..956d9b34d 100644 --- a/generated/stripe_shared/src/account_requirements_alternative.rs +++ b/generated/stripe_shared/src/account_requirements_alternative.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountRequirementsAlternative { /// Fields that can be provided to satisfy all fields in `original_fields_due`. pub alternative_fields_due: Vec<String>, /// Fields that are due and can be satisfied by providing all fields in `alternative_fields_due`. pub original_fields_due: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountRequirementsAlternativeBuilder { + alternative_fields_due: Option<Vec<String>>, + original_fields_due: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountRequirementsAlternative { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountRequirementsAlternative>, + builder: AccountRequirementsAlternativeBuilder, + } + + impl Visitor for Place<AccountRequirementsAlternative> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountRequirementsAlternativeBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountRequirementsAlternativeBuilder { + type Out = AccountRequirementsAlternative; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alternative_fields_due" => Deserialize::begin(&mut self.alternative_fields_due), + "original_fields_due" => Deserialize::begin(&mut self.original_fields_due), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { alternative_fields_due: Deserialize::default(), original_fields_due: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alternative_fields_due = self.alternative_fields_due.take()?; + let original_fields_due = self.original_fields_due.take()?; + + Some(Self::Out { alternative_fields_due, original_fields_due }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountRequirementsAlternative { + type Builder = AccountRequirementsAlternativeBuilder; + } + + impl FromValueOpt for AccountRequirementsAlternative { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountRequirementsAlternativeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alternative_fields_due" => b.alternative_fields_due = Some(FromValueOpt::from_value(v)?), + "original_fields_due" => b.original_fields_due = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_requirements_error.rs b/generated/stripe_shared/src/account_requirements_error.rs index b8f37c96f..891ff3e7a 100644 --- a/generated/stripe_shared/src/account_requirements_error.rs +++ b/generated/stripe_shared/src/account_requirements_error.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountRequirementsError { /// The code for the type of error. pub code: AccountRequirementsErrorCode, @@ -7,6 +9,100 @@ pub struct AccountRequirementsError { /// The specific user onboarding requirement field (in the requirements hash) that needs to be resolved. pub requirement: String, } +#[cfg(feature = "min-ser")] +pub struct AccountRequirementsErrorBuilder { + code: Option<AccountRequirementsErrorCode>, + reason: Option<String>, + requirement: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountRequirementsError { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountRequirementsError>, + builder: AccountRequirementsErrorBuilder, + } + + impl Visitor for Place<AccountRequirementsError> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountRequirementsErrorBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountRequirementsErrorBuilder { + type Out = AccountRequirementsError; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "reason" => Deserialize::begin(&mut self.reason), + "requirement" => Deserialize::begin(&mut self.requirement), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default(), requirement: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let reason = self.reason.take()?; + let requirement = self.requirement.take()?; + + Some(Self::Out { code, reason, requirement }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountRequirementsError { + type Builder = AccountRequirementsErrorBuilder; + } + + impl FromValueOpt for AccountRequirementsError { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountRequirementsErrorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "requirement" => b.requirement = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The code for the type of error. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -117,17 +213,11 @@ impl AccountRequirementsErrorCode { InvalidProductDescriptionLength => "invalid_product_description_length", InvalidProductDescriptionUrlMatch => "invalid_product_description_url_match", InvalidRepresentativeCountry => "invalid_representative_country", - InvalidStatementDescriptorBusinessMismatch => { - "invalid_statement_descriptor_business_mismatch" - } + InvalidStatementDescriptorBusinessMismatch => "invalid_statement_descriptor_business_mismatch", InvalidStatementDescriptorDenylisted => "invalid_statement_descriptor_denylisted", InvalidStatementDescriptorLength => "invalid_statement_descriptor_length", - InvalidStatementDescriptorPrefixDenylisted => { - "invalid_statement_descriptor_prefix_denylisted" - } - InvalidStatementDescriptorPrefixMismatch => { - "invalid_statement_descriptor_prefix_mismatch" - } + InvalidStatementDescriptorPrefixDenylisted => "invalid_statement_descriptor_prefix_denylisted", + InvalidStatementDescriptorPrefixMismatch => "invalid_statement_descriptor_prefix_mismatch", InvalidStreetAddress => "invalid_street_address", InvalidTaxId => "invalid_tax_id", InvalidTaxIdFormat => "invalid_tax_id_format", @@ -136,48 +226,26 @@ impl AccountRequirementsErrorCode { InvalidUrlFormat => "invalid_url_format", InvalidUrlLength => "invalid_url_length", InvalidUrlWebPresenceDetected => "invalid_url_web_presence_detected", - InvalidUrlWebsiteBusinessInformationMismatch => { - "invalid_url_website_business_information_mismatch" - } + InvalidUrlWebsiteBusinessInformationMismatch => "invalid_url_website_business_information_mismatch", InvalidUrlWebsiteEmpty => "invalid_url_website_empty", InvalidUrlWebsiteInaccessible => "invalid_url_website_inaccessible", - InvalidUrlWebsiteInaccessibleGeoblocked => { - "invalid_url_website_inaccessible_geoblocked" - } - InvalidUrlWebsiteInaccessiblePasswordProtected => { - "invalid_url_website_inaccessible_password_protected" - } + InvalidUrlWebsiteInaccessibleGeoblocked => "invalid_url_website_inaccessible_geoblocked", + InvalidUrlWebsiteInaccessiblePasswordProtected => "invalid_url_website_inaccessible_password_protected", InvalidUrlWebsiteIncomplete => "invalid_url_website_incomplete", - InvalidUrlWebsiteIncompleteCancellationPolicy => { - "invalid_url_website_incomplete_cancellation_policy" - } - InvalidUrlWebsiteIncompleteCustomerServiceDetails => { - "invalid_url_website_incomplete_customer_service_details" - } - InvalidUrlWebsiteIncompleteLegalRestrictions => { - "invalid_url_website_incomplete_legal_restrictions" - } - InvalidUrlWebsiteIncompleteRefundPolicy => { - "invalid_url_website_incomplete_refund_policy" - } - InvalidUrlWebsiteIncompleteReturnPolicy => { - "invalid_url_website_incomplete_return_policy" - } - InvalidUrlWebsiteIncompleteTermsAndConditions => { - "invalid_url_website_incomplete_terms_and_conditions" - } - InvalidUrlWebsiteIncompleteUnderConstruction => { - "invalid_url_website_incomplete_under_construction" - } + InvalidUrlWebsiteIncompleteCancellationPolicy => "invalid_url_website_incomplete_cancellation_policy", + InvalidUrlWebsiteIncompleteCustomerServiceDetails => "invalid_url_website_incomplete_customer_service_details", + InvalidUrlWebsiteIncompleteLegalRestrictions => "invalid_url_website_incomplete_legal_restrictions", + InvalidUrlWebsiteIncompleteRefundPolicy => "invalid_url_website_incomplete_refund_policy", + InvalidUrlWebsiteIncompleteReturnPolicy => "invalid_url_website_incomplete_return_policy", + InvalidUrlWebsiteIncompleteTermsAndConditions => "invalid_url_website_incomplete_terms_and_conditions", + InvalidUrlWebsiteIncompleteUnderConstruction => "invalid_url_website_incomplete_under_construction", InvalidUrlWebsiteOther => "invalid_url_website_other", InvalidValueOther => "invalid_value_other", VerificationDirectorsMismatch => "verification_directors_mismatch", VerificationDocumentAddressMismatch => "verification_document_address_mismatch", VerificationDocumentAddressMissing => "verification_document_address_missing", VerificationDocumentCorrupt => "verification_document_corrupt", - VerificationDocumentCountryNotSupported => { - "verification_document_country_not_supported" - } + VerificationDocumentCountryNotSupported => "verification_document_country_not_supported", VerificationDocumentDirectorsMismatch => "verification_document_directors_mismatch", VerificationDocumentDobMismatch => "verification_document_dob_mismatch", VerificationDocumentDuplicateType => "verification_document_duplicate_type", @@ -191,9 +259,7 @@ impl AccountRequirementsErrorCode { VerificationDocumentIdNumberMissing => "verification_document_id_number_missing", VerificationDocumentIncomplete => "verification_document_incomplete", VerificationDocumentInvalid => "verification_document_invalid", - VerificationDocumentIssueOrExpiryDateMissing => { - "verification_document_issue_or_expiry_date_missing" - } + VerificationDocumentIssueOrExpiryDateMissing => "verification_document_issue_or_expiry_date_missing", VerificationDocumentManipulated => "verification_document_manipulated", VerificationDocumentMissingBack => "verification_document_missing_back", VerificationDocumentMissingFront => "verification_document_missing_front", @@ -221,9 +287,7 @@ impl AccountRequirementsErrorCode { VerificationMissingDirectors => "verification_missing_directors", VerificationMissingExecutives => "verification_missing_executives", VerificationMissingOwners => "verification_missing_owners", - VerificationRequiresAdditionalMemorandumOfAssociations => { - "verification_requires_additional_memorandum_of_associations" - } + VerificationRequiresAdditionalMemorandumOfAssociations => "verification_requires_additional_memorandum_of_associations", Unknown => "unknown", } } @@ -246,17 +310,11 @@ impl std::str::FromStr for AccountRequirementsErrorCode { "invalid_product_description_length" => Ok(InvalidProductDescriptionLength), "invalid_product_description_url_match" => Ok(InvalidProductDescriptionUrlMatch), "invalid_representative_country" => Ok(InvalidRepresentativeCountry), - "invalid_statement_descriptor_business_mismatch" => { - Ok(InvalidStatementDescriptorBusinessMismatch) - } + "invalid_statement_descriptor_business_mismatch" => Ok(InvalidStatementDescriptorBusinessMismatch), "invalid_statement_descriptor_denylisted" => Ok(InvalidStatementDescriptorDenylisted), "invalid_statement_descriptor_length" => Ok(InvalidStatementDescriptorLength), - "invalid_statement_descriptor_prefix_denylisted" => { - Ok(InvalidStatementDescriptorPrefixDenylisted) - } - "invalid_statement_descriptor_prefix_mismatch" => { - Ok(InvalidStatementDescriptorPrefixMismatch) - } + "invalid_statement_descriptor_prefix_denylisted" => Ok(InvalidStatementDescriptorPrefixDenylisted), + "invalid_statement_descriptor_prefix_mismatch" => Ok(InvalidStatementDescriptorPrefixMismatch), "invalid_street_address" => Ok(InvalidStreetAddress), "invalid_tax_id" => Ok(InvalidTaxId), "invalid_tax_id_format" => Ok(InvalidTaxIdFormat), @@ -265,48 +323,26 @@ impl std::str::FromStr for AccountRequirementsErrorCode { "invalid_url_format" => Ok(InvalidUrlFormat), "invalid_url_length" => Ok(InvalidUrlLength), "invalid_url_web_presence_detected" => Ok(InvalidUrlWebPresenceDetected), - "invalid_url_website_business_information_mismatch" => { - Ok(InvalidUrlWebsiteBusinessInformationMismatch) - } + "invalid_url_website_business_information_mismatch" => Ok(InvalidUrlWebsiteBusinessInformationMismatch), "invalid_url_website_empty" => Ok(InvalidUrlWebsiteEmpty), "invalid_url_website_inaccessible" => Ok(InvalidUrlWebsiteInaccessible), - "invalid_url_website_inaccessible_geoblocked" => { - Ok(InvalidUrlWebsiteInaccessibleGeoblocked) - } - "invalid_url_website_inaccessible_password_protected" => { - Ok(InvalidUrlWebsiteInaccessiblePasswordProtected) - } + "invalid_url_website_inaccessible_geoblocked" => Ok(InvalidUrlWebsiteInaccessibleGeoblocked), + "invalid_url_website_inaccessible_password_protected" => Ok(InvalidUrlWebsiteInaccessiblePasswordProtected), "invalid_url_website_incomplete" => Ok(InvalidUrlWebsiteIncomplete), - "invalid_url_website_incomplete_cancellation_policy" => { - Ok(InvalidUrlWebsiteIncompleteCancellationPolicy) - } - "invalid_url_website_incomplete_customer_service_details" => { - Ok(InvalidUrlWebsiteIncompleteCustomerServiceDetails) - } - "invalid_url_website_incomplete_legal_restrictions" => { - Ok(InvalidUrlWebsiteIncompleteLegalRestrictions) - } - "invalid_url_website_incomplete_refund_policy" => { - Ok(InvalidUrlWebsiteIncompleteRefundPolicy) - } - "invalid_url_website_incomplete_return_policy" => { - Ok(InvalidUrlWebsiteIncompleteReturnPolicy) - } - "invalid_url_website_incomplete_terms_and_conditions" => { - Ok(InvalidUrlWebsiteIncompleteTermsAndConditions) - } - "invalid_url_website_incomplete_under_construction" => { - Ok(InvalidUrlWebsiteIncompleteUnderConstruction) - } + "invalid_url_website_incomplete_cancellation_policy" => Ok(InvalidUrlWebsiteIncompleteCancellationPolicy), + "invalid_url_website_incomplete_customer_service_details" => Ok(InvalidUrlWebsiteIncompleteCustomerServiceDetails), + "invalid_url_website_incomplete_legal_restrictions" => Ok(InvalidUrlWebsiteIncompleteLegalRestrictions), + "invalid_url_website_incomplete_refund_policy" => Ok(InvalidUrlWebsiteIncompleteRefundPolicy), + "invalid_url_website_incomplete_return_policy" => Ok(InvalidUrlWebsiteIncompleteReturnPolicy), + "invalid_url_website_incomplete_terms_and_conditions" => Ok(InvalidUrlWebsiteIncompleteTermsAndConditions), + "invalid_url_website_incomplete_under_construction" => Ok(InvalidUrlWebsiteIncompleteUnderConstruction), "invalid_url_website_other" => Ok(InvalidUrlWebsiteOther), "invalid_value_other" => Ok(InvalidValueOther), "verification_directors_mismatch" => Ok(VerificationDirectorsMismatch), "verification_document_address_mismatch" => Ok(VerificationDocumentAddressMismatch), "verification_document_address_missing" => Ok(VerificationDocumentAddressMissing), "verification_document_corrupt" => Ok(VerificationDocumentCorrupt), - "verification_document_country_not_supported" => { - Ok(VerificationDocumentCountryNotSupported) - } + "verification_document_country_not_supported" => Ok(VerificationDocumentCountryNotSupported), "verification_document_directors_mismatch" => Ok(VerificationDocumentDirectorsMismatch), "verification_document_dob_mismatch" => Ok(VerificationDocumentDobMismatch), "verification_document_duplicate_type" => Ok(VerificationDocumentDuplicateType), @@ -320,17 +356,13 @@ impl std::str::FromStr for AccountRequirementsErrorCode { "verification_document_id_number_missing" => Ok(VerificationDocumentIdNumberMissing), "verification_document_incomplete" => Ok(VerificationDocumentIncomplete), "verification_document_invalid" => Ok(VerificationDocumentInvalid), - "verification_document_issue_or_expiry_date_missing" => { - Ok(VerificationDocumentIssueOrExpiryDateMissing) - } + "verification_document_issue_or_expiry_date_missing" => Ok(VerificationDocumentIssueOrExpiryDateMissing), "verification_document_manipulated" => Ok(VerificationDocumentManipulated), "verification_document_missing_back" => Ok(VerificationDocumentMissingBack), "verification_document_missing_front" => Ok(VerificationDocumentMissingFront), "verification_document_name_mismatch" => Ok(VerificationDocumentNameMismatch), "verification_document_name_missing" => Ok(VerificationDocumentNameMissing), - "verification_document_nationality_mismatch" => { - Ok(VerificationDocumentNationalityMismatch) - } + "verification_document_nationality_mismatch" => Ok(VerificationDocumentNationalityMismatch), "verification_document_not_readable" => Ok(VerificationDocumentNotReadable), "verification_document_not_signed" => Ok(VerificationDocumentNotSigned), "verification_document_not_uploaded" => Ok(VerificationDocumentNotUploaded), @@ -352,9 +384,7 @@ impl std::str::FromStr for AccountRequirementsErrorCode { "verification_missing_directors" => Ok(VerificationMissingDirectors), "verification_missing_executives" => Ok(VerificationMissingExecutives), "verification_missing_owners" => Ok(VerificationMissingOwners), - "verification_requires_additional_memorandum_of_associations" => { - Ok(VerificationRequiresAdditionalMemorandumOfAssociations) - } + "verification_requires_additional_memorandum_of_associations" => Ok(VerificationRequiresAdditionalMemorandumOfAssociations), _ => Err(()), } } @@ -382,6 +412,24 @@ impl<'de> serde::Deserialize<'de> for AccountRequirementsErrorCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(AccountRequirementsErrorCode::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for AccountRequirementsErrorCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<AccountRequirementsErrorCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountRequirementsErrorCode::from_str(s).unwrap_or(AccountRequirementsErrorCode::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(AccountRequirementsErrorCode); diff --git a/generated/stripe_shared/src/account_sepa_debit_payments_settings.rs b/generated/stripe_shared/src/account_sepa_debit_payments_settings.rs index 9da113cc0..5a4c03eb6 100644 --- a/generated/stripe_shared/src/account_sepa_debit_payments_settings.rs +++ b/generated/stripe_shared/src/account_sepa_debit_payments_settings.rs @@ -1,6 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountSepaDebitPaymentsSettings { /// SEPA creditor identifier that identifies the company making the payment. - #[serde(skip_serializing_if = "Option::is_none")] pub creditor_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountSepaDebitPaymentsSettingsBuilder { + creditor_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountSepaDebitPaymentsSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountSepaDebitPaymentsSettings>, + builder: AccountSepaDebitPaymentsSettingsBuilder, + } + + impl Visitor for Place<AccountSepaDebitPaymentsSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountSepaDebitPaymentsSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountSepaDebitPaymentsSettingsBuilder { + type Out = AccountSepaDebitPaymentsSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "creditor_id" => Deserialize::begin(&mut self.creditor_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { creditor_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let creditor_id = self.creditor_id.take()?; + + Some(Self::Out { creditor_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountSepaDebitPaymentsSettings { + type Builder = AccountSepaDebitPaymentsSettingsBuilder; + } + + impl FromValueOpt for AccountSepaDebitPaymentsSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountSepaDebitPaymentsSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "creditor_id" => b.creditor_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_settings.rs b/generated/stripe_shared/src/account_settings.rs index 6fd008740..581b681ee 100644 --- a/generated/stripe_shared/src/account_settings.rs +++ b/generated/stripe_shared/src/account_settings.rs @@ -1,19 +1,142 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountSettings { - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit_payments: Option<stripe_shared::AccountBacsDebitPaymentsSettings>, pub branding: stripe_shared::AccountBrandingSettings, - #[serde(skip_serializing_if = "Option::is_none")] pub card_issuing: Option<stripe_shared::AccountCardIssuingSettings>, pub card_payments: stripe_shared::AccountCardPaymentsSettings, pub dashboard: stripe_shared::AccountDashboardSettings, - #[serde(skip_serializing_if = "Option::is_none")] - pub invoices: Option<stripe_shared::AccountInvoicesSettings>, pub payments: stripe_shared::AccountPaymentsSettings, - #[serde(skip_serializing_if = "Option::is_none")] pub payouts: Option<stripe_shared::AccountPayoutSettings>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit_payments: Option<stripe_shared::AccountSepaDebitPaymentsSettings>, - #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option<stripe_shared::AccountTreasurySettings>, } +#[cfg(feature = "min-ser")] +pub struct AccountSettingsBuilder { + bacs_debit_payments: Option<Option<stripe_shared::AccountBacsDebitPaymentsSettings>>, + branding: Option<stripe_shared::AccountBrandingSettings>, + card_issuing: Option<Option<stripe_shared::AccountCardIssuingSettings>>, + card_payments: Option<stripe_shared::AccountCardPaymentsSettings>, + dashboard: Option<stripe_shared::AccountDashboardSettings>, + payments: Option<stripe_shared::AccountPaymentsSettings>, + payouts: Option<Option<stripe_shared::AccountPayoutSettings>>, + sepa_debit_payments: Option<Option<stripe_shared::AccountSepaDebitPaymentsSettings>>, + treasury: Option<Option<stripe_shared::AccountTreasurySettings>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountSettings>, + builder: AccountSettingsBuilder, + } + + impl Visitor for Place<AccountSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountSettingsBuilder { + type Out = AccountSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bacs_debit_payments" => Deserialize::begin(&mut self.bacs_debit_payments), + "branding" => Deserialize::begin(&mut self.branding), + "card_issuing" => Deserialize::begin(&mut self.card_issuing), + "card_payments" => Deserialize::begin(&mut self.card_payments), + "dashboard" => Deserialize::begin(&mut self.dashboard), + "payments" => Deserialize::begin(&mut self.payments), + "payouts" => Deserialize::begin(&mut self.payouts), + "sepa_debit_payments" => Deserialize::begin(&mut self.sepa_debit_payments), + "treasury" => Deserialize::begin(&mut self.treasury), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bacs_debit_payments: Deserialize::default(), + branding: Deserialize::default(), + card_issuing: Deserialize::default(), + card_payments: Deserialize::default(), + dashboard: Deserialize::default(), + payments: Deserialize::default(), + payouts: Deserialize::default(), + sepa_debit_payments: Deserialize::default(), + treasury: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bacs_debit_payments = self.bacs_debit_payments.take()?; + let branding = self.branding.take()?; + let card_issuing = self.card_issuing.take()?; + let card_payments = self.card_payments.take()?; + let dashboard = self.dashboard.take()?; + let payments = self.payments.take()?; + let payouts = self.payouts.take()?; + let sepa_debit_payments = self.sepa_debit_payments.take()?; + let treasury = self.treasury.take()?; + + Some(Self::Out { bacs_debit_payments, branding, card_issuing, card_payments, dashboard, payments, payouts, sepa_debit_payments, treasury }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountSettings { + type Builder = AccountSettingsBuilder; + } + + impl FromValueOpt for AccountSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bacs_debit_payments" => b.bacs_debit_payments = Some(FromValueOpt::from_value(v)?), + "branding" => b.branding = Some(FromValueOpt::from_value(v)?), + "card_issuing" => b.card_issuing = Some(FromValueOpt::from_value(v)?), + "card_payments" => b.card_payments = Some(FromValueOpt::from_value(v)?), + "dashboard" => b.dashboard = Some(FromValueOpt::from_value(v)?), + "payments" => b.payments = Some(FromValueOpt::from_value(v)?), + "payouts" => b.payouts = Some(FromValueOpt::from_value(v)?), + "sepa_debit_payments" => b.sepa_debit_payments = Some(FromValueOpt::from_value(v)?), + "treasury" => b.treasury = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_terms_of_service.rs b/generated/stripe_shared/src/account_terms_of_service.rs index a096416f5..c2cf85856 100644 --- a/generated/stripe_shared/src/account_terms_of_service.rs +++ b/generated/stripe_shared/src/account_terms_of_service.rs @@ -1,10 +1,105 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountTermsOfService { /// The Unix timestamp marking when the account representative accepted the service agreement. pub date: Option<stripe_types::Timestamp>, /// The IP address from which the account representative accepted the service agreement. pub ip: Option<String>, /// The user agent of the browser from which the account representative accepted the service agreement. - #[serde(skip_serializing_if = "Option::is_none")] pub user_agent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountTermsOfServiceBuilder { + date: Option<Option<stripe_types::Timestamp>>, + ip: Option<Option<String>>, + user_agent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountTermsOfService { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountTermsOfService>, + builder: AccountTermsOfServiceBuilder, + } + + impl Visitor for Place<AccountTermsOfService> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountTermsOfServiceBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountTermsOfServiceBuilder { + type Out = AccountTermsOfService; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "date" => Deserialize::begin(&mut self.date), + "ip" => Deserialize::begin(&mut self.ip), + "user_agent" => Deserialize::begin(&mut self.user_agent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { date: Deserialize::default(), ip: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let date = self.date.take()?; + let ip = self.ip.take()?; + let user_agent = self.user_agent.take()?; + + Some(Self::Out { date, ip, user_agent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountTermsOfService { + type Builder = AccountTermsOfServiceBuilder; + } + + impl FromValueOpt for AccountTermsOfService { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountTermsOfServiceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "date" => b.date = Some(FromValueOpt::from_value(v)?), + "ip" => b.ip = Some(FromValueOpt::from_value(v)?), + "user_agent" => b.user_agent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_tos_acceptance.rs b/generated/stripe_shared/src/account_tos_acceptance.rs index 9874a88f7..0dc66f946 100644 --- a/generated/stripe_shared/src/account_tos_acceptance.rs +++ b/generated/stripe_shared/src/account_tos_acceptance.rs @@ -1,15 +1,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountTosAcceptance { /// The Unix timestamp marking when the account representative accepted their service agreement - #[serde(skip_serializing_if = "Option::is_none")] pub date: Option<stripe_types::Timestamp>, /// The IP address from which the account representative accepted their service agreement - #[serde(skip_serializing_if = "Option::is_none")] pub ip: Option<String>, /// The user's service agreement type - #[serde(skip_serializing_if = "Option::is_none")] pub service_agreement: Option<String>, /// The user agent of the browser from which the account representative accepted their service agreement. - #[serde(skip_serializing_if = "Option::is_none")] pub user_agent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AccountTosAcceptanceBuilder { + date: Option<Option<stripe_types::Timestamp>>, + ip: Option<Option<String>>, + service_agreement: Option<Option<String>>, + user_agent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountTosAcceptance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountTosAcceptance>, + builder: AccountTosAcceptanceBuilder, + } + + impl Visitor for Place<AccountTosAcceptance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountTosAcceptanceBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountTosAcceptanceBuilder { + type Out = AccountTosAcceptance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "date" => Deserialize::begin(&mut self.date), + "ip" => Deserialize::begin(&mut self.ip), + "service_agreement" => Deserialize::begin(&mut self.service_agreement), + "user_agent" => Deserialize::begin(&mut self.user_agent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { date: Deserialize::default(), ip: Deserialize::default(), service_agreement: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let date = self.date.take()?; + let ip = self.ip.take()?; + let service_agreement = self.service_agreement.take()?; + let user_agent = self.user_agent.take()?; + + Some(Self::Out { date, ip, service_agreement, user_agent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountTosAcceptance { + type Builder = AccountTosAcceptanceBuilder; + } + + impl FromValueOpt for AccountTosAcceptance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountTosAcceptanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "date" => b.date = Some(FromValueOpt::from_value(v)?), + "ip" => b.ip = Some(FromValueOpt::from_value(v)?), + "service_agreement" => b.service_agreement = Some(FromValueOpt::from_value(v)?), + "user_agent" => b.user_agent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_treasury_settings.rs b/generated/stripe_shared/src/account_treasury_settings.rs index 37f832a0e..d325b97f8 100644 --- a/generated/stripe_shared/src/account_treasury_settings.rs +++ b/generated/stripe_shared/src/account_treasury_settings.rs @@ -1,5 +1,92 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountTreasurySettings { - #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option<stripe_shared::AccountTermsOfService>, } +#[cfg(feature = "min-ser")] +pub struct AccountTreasurySettingsBuilder { + tos_acceptance: Option<Option<stripe_shared::AccountTermsOfService>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountTreasurySettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountTreasurySettings>, + builder: AccountTreasurySettingsBuilder, + } + + impl Visitor for Place<AccountTreasurySettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountTreasurySettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountTreasurySettingsBuilder { + type Out = AccountTreasurySettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "tos_acceptance" => Deserialize::begin(&mut self.tos_acceptance), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tos_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let tos_acceptance = self.tos_acceptance.take()?; + + Some(Self::Out { tos_acceptance }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountTreasurySettings { + type Builder = AccountTreasurySettingsBuilder; + } + + impl FromValueOpt for AccountTreasurySettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountTreasurySettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "tos_acceptance" => b.tos_acceptance = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_unification_account_controller.rs b/generated/stripe_shared/src/account_unification_account_controller.rs index 196772550..7fb6d92f5 100644 --- a/generated/stripe_shared/src/account_unification_account_controller.rs +++ b/generated/stripe_shared/src/account_unification_account_controller.rs @@ -1,14 +1,105 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AccountUnificationAccountController { /// `true` if the Connect application retrieving the resource controls the account and can therefore exercise [platform controls](https://stripe.com/docs/connect/platform-controls-for-standard-accounts). /// Otherwise, this field is null. - #[serde(skip_serializing_if = "Option::is_none")] pub is_controller: Option<bool>, /// The controller type. /// Can be `application`, if a Connect application controls the account, or `account`, if the account controls itself. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: AccountUnificationAccountControllerType, } +#[cfg(feature = "min-ser")] +pub struct AccountUnificationAccountControllerBuilder { + is_controller: Option<Option<bool>>, + type_: Option<AccountUnificationAccountControllerType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountUnificationAccountController { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AccountUnificationAccountController>, + builder: AccountUnificationAccountControllerBuilder, + } + + impl Visitor for Place<AccountUnificationAccountController> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AccountUnificationAccountControllerBuilder::deser_default() })) + } + } + + impl MapBuilder for AccountUnificationAccountControllerBuilder { + type Out = AccountUnificationAccountController; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "is_controller" => Deserialize::begin(&mut self.is_controller), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { is_controller: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let is_controller = self.is_controller.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { is_controller, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountUnificationAccountController { + type Builder = AccountUnificationAccountControllerBuilder; + } + + impl FromValueOpt for AccountUnificationAccountController { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountUnificationAccountControllerBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "is_controller" => b.is_controller = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The controller type. /// Can be `application`, if a Connect application controls the account, or `account`, if the account controls itself. #[derive(Copy, Clone, Eq, PartialEq)] @@ -60,8 +151,24 @@ impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for AccountUnificationAccountControllerType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for AccountUnificationAccountControllerType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for AccountUnificationAccountControllerType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<AccountUnificationAccountControllerType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountUnificationAccountControllerType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerType); diff --git a/generated/stripe_shared/src/address.rs b/generated/stripe_shared/src/address.rs index 9aaf337bf..ea73593d8 100644 --- a/generated/stripe_shared/src/address.rs +++ b/generated/stripe_shared/src/address.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Address { /// City, district, suburb, town, or village. pub city: Option<String>, @@ -13,3 +15,116 @@ pub struct Address { /// State, county, province, or region. pub state: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct AddressBuilder { + city: Option<Option<String>>, + country: Option<Option<String>>, + line1: Option<Option<String>>, + line2: Option<Option<String>>, + postal_code: Option<Option<String>>, + state: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Address { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Address>, + builder: AddressBuilder, + } + + impl Visitor for Place<Address> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AddressBuilder::deser_default() })) + } + } + + impl MapBuilder for AddressBuilder { + type Out = Address; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "city" => Deserialize::begin(&mut self.city), + "country" => Deserialize::begin(&mut self.country), + "line1" => Deserialize::begin(&mut self.line1), + "line2" => Deserialize::begin(&mut self.line2), + "postal_code" => Deserialize::begin(&mut self.postal_code), + "state" => Deserialize::begin(&mut self.state), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + city: Deserialize::default(), + country: Deserialize::default(), + line1: Deserialize::default(), + line2: Deserialize::default(), + postal_code: Deserialize::default(), + state: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let city = self.city.take()?; + let country = self.country.take()?; + let line1 = self.line1.take()?; + let line2 = self.line2.take()?; + let postal_code = self.postal_code.take()?; + let state = self.state.take()?; + + Some(Self::Out { city, country, line1, line2, postal_code, state }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Address { + type Builder = AddressBuilder; + } + + impl FromValueOpt for Address { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AddressBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "city" => b.city = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "line1" => b.line1 = Some(FromValueOpt::from_value(v)?), + "line2" => b.line2 = Some(FromValueOpt::from_value(v)?), + "postal_code" => b.postal_code = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/api_errors.rs b/generated/stripe_shared/src/api_errors.rs index 9cbf161e2..51b992dba 100644 --- a/generated/stripe_shared/src/api_errors.rs +++ b/generated/stripe_shared/src/api_errors.rs @@ -1,45 +1,183 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ApiErrors { /// For card errors, the ID of the failed charge. - #[serde(skip_serializing_if = "Option::is_none")] pub charge: Option<String>, /// For some errors that could be handled programmatically, a short string indicating the [error code](https://stripe.com/docs/error-codes) reported. - #[serde(skip_serializing_if = "Option::is_none")] pub code: Option<ApiErrorsCode>, /// For card errors resulting from a card issuer decline, a short string indicating the [card issuer's reason for the decline](https://stripe.com/docs/declines#issuer-declines) if they provide one. - #[serde(skip_serializing_if = "Option::is_none")] pub decline_code: Option<String>, /// A URL to more information about the [error code](https://stripe.com/docs/error-codes) reported. - #[serde(skip_serializing_if = "Option::is_none")] pub doc_url: Option<String>, /// A human-readable message providing more details about the error. /// For card errors, these messages can be shown to your users. - #[serde(skip_serializing_if = "Option::is_none")] pub message: Option<String>, /// If the error is parameter-specific, the parameter related to the error. /// For example, you can use this to display a message near the correct form field. - #[serde(skip_serializing_if = "Option::is_none")] pub param: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_intent: Option<stripe_shared::PaymentIntent>, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_method: Option<stripe_shared::PaymentMethod>, /// If the error is specific to the type of payment method, the payment method type that had a problem. /// This field is only populated for invoice-related errors. - #[serde(skip_serializing_if = "Option::is_none")] pub payment_method_type: Option<String>, /// A URL to the request log entry in your dashboard. - #[serde(skip_serializing_if = "Option::is_none")] pub request_log_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub setup_intent: Option<stripe_shared::SetupIntent>, - #[serde(skip_serializing_if = "Option::is_none")] pub source: Option<stripe_shared::PaymentSource>, /// The type of error returned. /// One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: ApiErrorsType, } +#[cfg(feature = "min-ser")] +pub struct ApiErrorsBuilder { + charge: Option<Option<String>>, + code: Option<Option<ApiErrorsCode>>, + decline_code: Option<Option<String>>, + doc_url: Option<Option<String>>, + message: Option<Option<String>>, + param: Option<Option<String>>, + payment_intent: Option<Option<stripe_shared::PaymentIntent>>, + payment_method: Option<Option<stripe_shared::PaymentMethod>>, + payment_method_type: Option<Option<String>>, + request_log_url: Option<Option<String>>, + setup_intent: Option<Option<stripe_shared::SetupIntent>>, + source: Option<Option<stripe_shared::PaymentSource>>, + type_: Option<ApiErrorsType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ApiErrors { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ApiErrors>, + builder: ApiErrorsBuilder, + } + + impl Visitor for Place<ApiErrors> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ApiErrorsBuilder::deser_default() })) + } + } + + impl MapBuilder for ApiErrorsBuilder { + type Out = ApiErrors; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "charge" => Deserialize::begin(&mut self.charge), + "code" => Deserialize::begin(&mut self.code), + "decline_code" => Deserialize::begin(&mut self.decline_code), + "doc_url" => Deserialize::begin(&mut self.doc_url), + "message" => Deserialize::begin(&mut self.message), + "param" => Deserialize::begin(&mut self.param), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "payment_method" => Deserialize::begin(&mut self.payment_method), + "payment_method_type" => Deserialize::begin(&mut self.payment_method_type), + "request_log_url" => Deserialize::begin(&mut self.request_log_url), + "setup_intent" => Deserialize::begin(&mut self.setup_intent), + "source" => Deserialize::begin(&mut self.source), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + charge: Deserialize::default(), + code: Deserialize::default(), + decline_code: Deserialize::default(), + doc_url: Deserialize::default(), + message: Deserialize::default(), + param: Deserialize::default(), + payment_intent: Deserialize::default(), + payment_method: Deserialize::default(), + payment_method_type: Deserialize::default(), + request_log_url: Deserialize::default(), + setup_intent: Deserialize::default(), + source: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let charge = self.charge.take()?; + let code = self.code.take()?; + let decline_code = self.decline_code.take()?; + let doc_url = self.doc_url.take()?; + let message = self.message.take()?; + let param = self.param.take()?; + let payment_intent = self.payment_intent.take()?; + let payment_method = self.payment_method.take()?; + let payment_method_type = self.payment_method_type.take()?; + let request_log_url = self.request_log_url.take()?; + let setup_intent = self.setup_intent.take()?; + let source = self.source.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { charge, code, decline_code, doc_url, message, param, payment_intent, payment_method, payment_method_type, request_log_url, setup_intent, source, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ApiErrors { + type Builder = ApiErrorsBuilder; + } + + impl FromValueOpt for ApiErrors { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ApiErrorsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "decline_code" => b.decline_code = Some(FromValueOpt::from_value(v)?), + "doc_url" => b.doc_url = Some(FromValueOpt::from_value(v)?), + "message" => b.message = Some(FromValueOpt::from_value(v)?), + "param" => b.param = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "payment_method" => b.payment_method = Some(FromValueOpt::from_value(v)?), + "payment_method_type" => b.payment_method_type = Some(FromValueOpt::from_value(v)?), + "request_log_url" => b.request_log_url = Some(FromValueOpt::from_value(v)?), + "setup_intent" => b.setup_intent = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// For some errors that could be handled programmatically, a short string indicating the [error code](https://stripe.com/docs/error-codes) reported. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -86,12 +224,9 @@ pub enum ApiErrorsCode { CouponExpired, CustomerMaxPaymentMethods, CustomerMaxSubscriptions, - CustomerTaxLocationInvalid, DebitNotAuthorized, EmailInvalid, ExpiredCard, - FinancialConnectionsAccountInactive, - FinancialConnectionsNoSuccessfulTransactionRefresh, IdempotencyKeyInUse, IncorrectAddress, IncorrectCvc, @@ -216,9 +351,7 @@ impl ApiErrorsCode { match self { AccountClosed => "account_closed", AccountCountryInvalidAddress => "account_country_invalid_address", - AccountErrorCountryChangeRequiresAdditionalSteps => { - "account_error_country_change_requires_additional_steps" - } + AccountErrorCountryChangeRequiresAdditionalSteps => "account_error_country_change_requires_additional_steps", AccountInformationMismatch => "account_information_mismatch", AccountInvalid => "account_invalid", AccountNumberInvalid => "account_number_invalid", @@ -258,14 +391,9 @@ impl ApiErrorsCode { CouponExpired => "coupon_expired", CustomerMaxPaymentMethods => "customer_max_payment_methods", CustomerMaxSubscriptions => "customer_max_subscriptions", - CustomerTaxLocationInvalid => "customer_tax_location_invalid", DebitNotAuthorized => "debit_not_authorized", EmailInvalid => "email_invalid", ExpiredCard => "expired_card", - FinancialConnectionsAccountInactive => "financial_connections_account_inactive", - FinancialConnectionsNoSuccessfulTransactionRefresh => { - "financial_connections_no_successful_transaction_refresh" - } IdempotencyKeyInUse => "idempotency_key_in_use", IncorrectAddress => "incorrect_address", IncorrectCvc => "incorrect_cvc", @@ -312,41 +440,25 @@ impl ApiErrorsCode { PaymentIntentAuthenticationFailure => "payment_intent_authentication_failure", PaymentIntentIncompatiblePaymentMethod => "payment_intent_incompatible_payment_method", PaymentIntentInvalidParameter => "payment_intent_invalid_parameter", - PaymentIntentKonbiniRejectedConfirmationNumber => { - "payment_intent_konbini_rejected_confirmation_number" - } + PaymentIntentKonbiniRejectedConfirmationNumber => "payment_intent_konbini_rejected_confirmation_number", PaymentIntentMandateInvalid => "payment_intent_mandate_invalid", PaymentIntentPaymentAttemptExpired => "payment_intent_payment_attempt_expired", PaymentIntentPaymentAttemptFailed => "payment_intent_payment_attempt_failed", PaymentIntentUnexpectedState => "payment_intent_unexpected_state", - PaymentMethodBankAccountAlreadyVerified => { - "payment_method_bank_account_already_verified" - } + PaymentMethodBankAccountAlreadyVerified => "payment_method_bank_account_already_verified", PaymentMethodBankAccountBlocked => "payment_method_bank_account_blocked", - PaymentMethodBillingDetailsAddressMissing => { - "payment_method_billing_details_address_missing" - } + PaymentMethodBillingDetailsAddressMissing => "payment_method_billing_details_address_missing", PaymentMethodConfigurationFailures => "payment_method_configuration_failures", PaymentMethodCurrencyMismatch => "payment_method_currency_mismatch", PaymentMethodCustomerDecline => "payment_method_customer_decline", PaymentMethodInvalidParameter => "payment_method_invalid_parameter", PaymentMethodInvalidParameterTestmode => "payment_method_invalid_parameter_testmode", PaymentMethodMicrodepositFailed => "payment_method_microdeposit_failed", - PaymentMethodMicrodepositVerificationAmountsInvalid => { - "payment_method_microdeposit_verification_amounts_invalid" - } - PaymentMethodMicrodepositVerificationAmountsMismatch => { - "payment_method_microdeposit_verification_amounts_mismatch" - } - PaymentMethodMicrodepositVerificationAttemptsExceeded => { - "payment_method_microdeposit_verification_attempts_exceeded" - } - PaymentMethodMicrodepositVerificationDescriptorCodeMismatch => { - "payment_method_microdeposit_verification_descriptor_code_mismatch" - } - PaymentMethodMicrodepositVerificationTimeout => { - "payment_method_microdeposit_verification_timeout" - } + PaymentMethodMicrodepositVerificationAmountsInvalid => "payment_method_microdeposit_verification_amounts_invalid", + PaymentMethodMicrodepositVerificationAmountsMismatch => "payment_method_microdeposit_verification_amounts_mismatch", + PaymentMethodMicrodepositVerificationAttemptsExceeded => "payment_method_microdeposit_verification_attempts_exceeded", + PaymentMethodMicrodepositVerificationDescriptorCodeMismatch => "payment_method_microdeposit_verification_descriptor_code_mismatch", + PaymentMethodMicrodepositVerificationTimeout => "payment_method_microdeposit_verification_timeout", PaymentMethodNotAvailable => "payment_method_not_available", PaymentMethodProviderDecline => "payment_method_provider_decline", PaymentMethodProviderTimeout => "payment_method_provider_timeout", @@ -394,9 +506,7 @@ impl ApiErrorsCode { TokenAlreadyUsed => "token_already_used", TokenCardNetworkInvalid => "token_card_network_invalid", TokenInUse => "token_in_use", - TransferSourceBalanceParametersMismatch => { - "transfer_source_balance_parameters_mismatch" - } + TransferSourceBalanceParametersMismatch => "transfer_source_balance_parameters_mismatch", TransfersNotAllowed => "transfers_not_allowed", UrlInvalid => "url_invalid", Unknown => "unknown", @@ -411,9 +521,7 @@ impl std::str::FromStr for ApiErrorsCode { match s { "account_closed" => Ok(AccountClosed), "account_country_invalid_address" => Ok(AccountCountryInvalidAddress), - "account_error_country_change_requires_additional_steps" => { - Ok(AccountErrorCountryChangeRequiresAdditionalSteps) - } + "account_error_country_change_requires_additional_steps" => Ok(AccountErrorCountryChangeRequiresAdditionalSteps), "account_information_mismatch" => Ok(AccountInformationMismatch), "account_invalid" => Ok(AccountInvalid), "account_number_invalid" => Ok(AccountNumberInvalid), @@ -453,14 +561,9 @@ impl std::str::FromStr for ApiErrorsCode { "coupon_expired" => Ok(CouponExpired), "customer_max_payment_methods" => Ok(CustomerMaxPaymentMethods), "customer_max_subscriptions" => Ok(CustomerMaxSubscriptions), - "customer_tax_location_invalid" => Ok(CustomerTaxLocationInvalid), "debit_not_authorized" => Ok(DebitNotAuthorized), "email_invalid" => Ok(EmailInvalid), "expired_card" => Ok(ExpiredCard), - "financial_connections_account_inactive" => Ok(FinancialConnectionsAccountInactive), - "financial_connections_no_successful_transaction_refresh" => { - Ok(FinancialConnectionsNoSuccessfulTransactionRefresh) - } "idempotency_key_in_use" => Ok(IdempotencyKeyInUse), "incorrect_address" => Ok(IncorrectAddress), "incorrect_cvc" => Ok(IncorrectCvc), @@ -505,47 +608,27 @@ impl std::str::FromStr for ApiErrorsCode { "parameters_exclusive" => Ok(ParametersExclusive), "payment_intent_action_required" => Ok(PaymentIntentActionRequired), "payment_intent_authentication_failure" => Ok(PaymentIntentAuthenticationFailure), - "payment_intent_incompatible_payment_method" => { - Ok(PaymentIntentIncompatiblePaymentMethod) - } + "payment_intent_incompatible_payment_method" => Ok(PaymentIntentIncompatiblePaymentMethod), "payment_intent_invalid_parameter" => Ok(PaymentIntentInvalidParameter), - "payment_intent_konbini_rejected_confirmation_number" => { - Ok(PaymentIntentKonbiniRejectedConfirmationNumber) - } + "payment_intent_konbini_rejected_confirmation_number" => Ok(PaymentIntentKonbiniRejectedConfirmationNumber), "payment_intent_mandate_invalid" => Ok(PaymentIntentMandateInvalid), "payment_intent_payment_attempt_expired" => Ok(PaymentIntentPaymentAttemptExpired), "payment_intent_payment_attempt_failed" => Ok(PaymentIntentPaymentAttemptFailed), "payment_intent_unexpected_state" => Ok(PaymentIntentUnexpectedState), - "payment_method_bank_account_already_verified" => { - Ok(PaymentMethodBankAccountAlreadyVerified) - } + "payment_method_bank_account_already_verified" => Ok(PaymentMethodBankAccountAlreadyVerified), "payment_method_bank_account_blocked" => Ok(PaymentMethodBankAccountBlocked), - "payment_method_billing_details_address_missing" => { - Ok(PaymentMethodBillingDetailsAddressMissing) - } + "payment_method_billing_details_address_missing" => Ok(PaymentMethodBillingDetailsAddressMissing), "payment_method_configuration_failures" => Ok(PaymentMethodConfigurationFailures), "payment_method_currency_mismatch" => Ok(PaymentMethodCurrencyMismatch), "payment_method_customer_decline" => Ok(PaymentMethodCustomerDecline), "payment_method_invalid_parameter" => Ok(PaymentMethodInvalidParameter), - "payment_method_invalid_parameter_testmode" => { - Ok(PaymentMethodInvalidParameterTestmode) - } + "payment_method_invalid_parameter_testmode" => Ok(PaymentMethodInvalidParameterTestmode), "payment_method_microdeposit_failed" => Ok(PaymentMethodMicrodepositFailed), - "payment_method_microdeposit_verification_amounts_invalid" => { - Ok(PaymentMethodMicrodepositVerificationAmountsInvalid) - } - "payment_method_microdeposit_verification_amounts_mismatch" => { - Ok(PaymentMethodMicrodepositVerificationAmountsMismatch) - } - "payment_method_microdeposit_verification_attempts_exceeded" => { - Ok(PaymentMethodMicrodepositVerificationAttemptsExceeded) - } - "payment_method_microdeposit_verification_descriptor_code_mismatch" => { - Ok(PaymentMethodMicrodepositVerificationDescriptorCodeMismatch) - } - "payment_method_microdeposit_verification_timeout" => { - Ok(PaymentMethodMicrodepositVerificationTimeout) - } + "payment_method_microdeposit_verification_amounts_invalid" => Ok(PaymentMethodMicrodepositVerificationAmountsInvalid), + "payment_method_microdeposit_verification_amounts_mismatch" => Ok(PaymentMethodMicrodepositVerificationAmountsMismatch), + "payment_method_microdeposit_verification_attempts_exceeded" => Ok(PaymentMethodMicrodepositVerificationAttemptsExceeded), + "payment_method_microdeposit_verification_descriptor_code_mismatch" => Ok(PaymentMethodMicrodepositVerificationDescriptorCodeMismatch), + "payment_method_microdeposit_verification_timeout" => Ok(PaymentMethodMicrodepositVerificationTimeout), "payment_method_not_available" => Ok(PaymentMethodNotAvailable), "payment_method_provider_decline" => Ok(PaymentMethodProviderDecline), "payment_method_provider_timeout" => Ok(PaymentMethodProviderTimeout), @@ -593,9 +676,7 @@ impl std::str::FromStr for ApiErrorsCode { "token_already_used" => Ok(TokenAlreadyUsed), "token_card_network_invalid" => Ok(TokenCardNetworkInvalid), "token_in_use" => Ok(TokenInUse), - "transfer_source_balance_parameters_mismatch" => { - Ok(TransferSourceBalanceParametersMismatch) - } + "transfer_source_balance_parameters_mismatch" => Ok(TransferSourceBalanceParametersMismatch), "transfers_not_allowed" => Ok(TransfersNotAllowed), "url_invalid" => Ok(UrlInvalid), _ => Err(()), @@ -625,9 +706,27 @@ impl<'de> serde::Deserialize<'de> for ApiErrorsCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(ApiErrorsCode::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ApiErrorsCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ApiErrorsCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApiErrorsCode::from_str(s).unwrap_or(ApiErrorsCode::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ApiErrorsCode); /// The type of error returned. /// One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -688,3 +787,21 @@ impl<'de> serde::Deserialize<'de> for ApiErrorsType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ApiErrorsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ApiErrorsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ApiErrorsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApiErrorsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ApiErrorsType); diff --git a/generated/stripe_shared/src/api_version.rs b/generated/stripe_shared/src/api_version.rs index 7dfe978ab..b97a1cc44 100644 --- a/generated/stripe_shared/src/api_version.rs +++ b/generated/stripe_shared/src/api_version.rs @@ -345,6 +345,24 @@ impl<'de> serde::Deserialize<'de> for ApiVersion { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(ApiVersion::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ApiVersion { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ApiVersion> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApiVersion::from_str(s).unwrap_or(ApiVersion::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ApiVersion); diff --git a/generated/stripe_shared/src/application.rs b/generated/stripe_shared/src/application.rs index 4f671ae0e..2e374bd92 100644 --- a/generated/stripe_shared/src/application.rs +++ b/generated/stripe_shared/src/application.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Application { /// Unique identifier for the object. pub id: stripe_shared::ApplicationId, /// The name of the application. pub name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct ApplicationBuilder { + id: Option<stripe_shared::ApplicationId>, + name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Application { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Application>, + builder: ApplicationBuilder, + } + + impl Visitor for Place<Application> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ApplicationBuilder::deser_default() })) + } + } + + impl MapBuilder for ApplicationBuilder { + type Out = Application; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "name" => Deserialize::begin(&mut self.name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let name = self.name.take()?; + + Some(Self::Out { id, name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Application { + type Builder = ApplicationBuilder; + } + + impl FromValueOpt for Application { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ApplicationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Application { type Id = stripe_shared::ApplicationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/application_fee.rs b/generated/stripe_shared/src/application_fee.rs index ebc801ef6..1f6b3743b 100644 --- a/generated/stripe_shared/src/application_fee.rs +++ b/generated/stripe_shared/src/application_fee.rs @@ -1,5 +1,7 @@ /// For more details see <<https://stripe.com/docs/api/application_fees/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ApplicationFee { /// ID of the Stripe account this fee was taken from. pub account: stripe_types::Expandable<stripe_shared::Account>, @@ -30,6 +32,154 @@ pub struct ApplicationFee { /// A list of refunds that have been applied to the fee. pub refunds: stripe_types::List<stripe_shared::ApplicationFeeRefund>, } +#[cfg(feature = "min-ser")] +pub struct ApplicationFeeBuilder { + account: Option<stripe_types::Expandable<stripe_shared::Account>>, + amount: Option<i64>, + amount_refunded: Option<i64>, + application: Option<stripe_types::Expandable<stripe_shared::Application>>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + charge: Option<stripe_types::Expandable<stripe_shared::Charge>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + id: Option<stripe_shared::ApplicationFeeId>, + livemode: Option<bool>, + originating_transaction: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + refunded: Option<bool>, + refunds: Option<stripe_types::List<stripe_shared::ApplicationFeeRefund>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ApplicationFee { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ApplicationFee>, + builder: ApplicationFeeBuilder, + } + + impl Visitor for Place<ApplicationFee> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ApplicationFeeBuilder::deser_default() })) + } + } + + impl MapBuilder for ApplicationFeeBuilder { + type Out = ApplicationFee; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "amount" => Deserialize::begin(&mut self.amount), + "amount_refunded" => Deserialize::begin(&mut self.amount_refunded), + "application" => Deserialize::begin(&mut self.application), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "charge" => Deserialize::begin(&mut self.charge), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "originating_transaction" => Deserialize::begin(&mut self.originating_transaction), + "refunded" => Deserialize::begin(&mut self.refunded), + "refunds" => Deserialize::begin(&mut self.refunds), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + amount: Deserialize::default(), + amount_refunded: Deserialize::default(), + application: Deserialize::default(), + balance_transaction: Deserialize::default(), + charge: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + originating_transaction: Deserialize::default(), + refunded: Deserialize::default(), + refunds: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let amount = self.amount.take()?; + let amount_refunded = self.amount_refunded.take()?; + let application = self.application.take()?; + let balance_transaction = self.balance_transaction.take()?; + let charge = self.charge.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let originating_transaction = self.originating_transaction.take()?; + let refunded = self.refunded.take()?; + let refunds = self.refunds.take()?; + + Some(Self::Out { account, amount, amount_refunded, application, balance_transaction, charge, created, currency, id, livemode, originating_transaction, refunded, refunds }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ApplicationFee { + type Builder = ApplicationFeeBuilder; + } + + impl FromValueOpt for ApplicationFee { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ApplicationFeeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_refunded" => b.amount_refunded = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "originating_transaction" => b.originating_transaction = Some(FromValueOpt::from_value(v)?), + "refunded" => b.refunded = Some(FromValueOpt::from_value(v)?), + "refunds" => b.refunds = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ApplicationFee { type Id = stripe_shared::ApplicationFeeId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/application_fee_refund.rs b/generated/stripe_shared/src/application_fee_refund.rs index d89e4260e..054fcf83f 100644 --- a/generated/stripe_shared/src/application_fee_refund.rs +++ b/generated/stripe_shared/src/application_fee_refund.rs @@ -5,7 +5,9 @@ /// Related guide: [Refunding application fees](https://stripe.com/docs/connect/destination-charges#refunding-app-fee). /// /// For more details see <<https://stripe.com/docs/api/fee_refunds/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ApplicationFeeRefund { /// Amount, in cents (or local equivalent). pub amount: i64, @@ -24,6 +26,124 @@ pub struct ApplicationFeeRefund { /// This can be useful for storing additional information about the object in a structured format. pub metadata: Option<std::collections::HashMap<String, String>>, } +#[cfg(feature = "min-ser")] +pub struct ApplicationFeeRefundBuilder { + amount: Option<i64>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + fee: Option<stripe_types::Expandable<stripe_shared::ApplicationFee>>, + id: Option<stripe_shared::ApplicationFeeRefundId>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ApplicationFeeRefund { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ApplicationFeeRefund>, + builder: ApplicationFeeRefundBuilder, + } + + impl Visitor for Place<ApplicationFeeRefund> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ApplicationFeeRefundBuilder::deser_default() })) + } + } + + impl MapBuilder for ApplicationFeeRefundBuilder { + type Out = ApplicationFeeRefund; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "fee" => Deserialize::begin(&mut self.fee), + "id" => Deserialize::begin(&mut self.id), + "metadata" => Deserialize::begin(&mut self.metadata), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + balance_transaction: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + fee: Deserialize::default(), + id: Deserialize::default(), + metadata: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let balance_transaction = self.balance_transaction.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let fee = self.fee.take()?; + let id = self.id.take()?; + let metadata = self.metadata.take()?; + + Some(Self::Out { amount, balance_transaction, created, currency, fee, id, metadata }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ApplicationFeeRefund { + type Builder = ApplicationFeeRefundBuilder; + } + + impl FromValueOpt for ApplicationFeeRefund { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ApplicationFeeRefundBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "fee" => b.fee = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ApplicationFeeRefund { type Id = stripe_shared::ApplicationFeeRefundId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/automatic_tax.rs b/generated/stripe_shared/src/automatic_tax.rs index 8afb53aba..6c70944e0 100644 --- a/generated/stripe_shared/src/automatic_tax.rs +++ b/generated/stripe_shared/src/automatic_tax.rs @@ -1,15 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct AutomaticTax { /// Whether Stripe automatically computes tax on this invoice. /// Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - pub liability: Option<stripe_shared::ConnectAccountReference>, /// The status of the most recent automated tax calculation for this invoice. pub status: Option<AutomaticTaxStatus>, } +#[cfg(feature = "min-ser")] +pub struct AutomaticTaxBuilder { + enabled: Option<bool>, + status: Option<Option<AutomaticTaxStatus>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<AutomaticTax>, + builder: AutomaticTaxBuilder, + } + + impl Visitor for Place<AutomaticTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: AutomaticTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for AutomaticTaxBuilder { + type Out = AutomaticTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + let status = self.status.take()?; + + Some(Self::Out { enabled, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AutomaticTax { + type Builder = AutomaticTaxBuilder; + } + + impl FromValueOpt for AutomaticTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AutomaticTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the most recent automated tax calculation for this invoice. #[derive(Copy, Clone, Eq, PartialEq)] pub enum AutomaticTaxStatus { @@ -63,7 +151,24 @@ impl<'de> serde::Deserialize<'de> for AutomaticTaxStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for AutomaticTaxStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for AutomaticTaxStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for AutomaticTaxStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<AutomaticTaxStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AutomaticTaxStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(AutomaticTaxStatus); diff --git a/generated/stripe_shared/src/balance_transaction.rs b/generated/stripe_shared/src/balance_transaction.rs index ad8b77726..8531cd75b 100644 --- a/generated/stripe_shared/src/balance_transaction.rs +++ b/generated/stripe_shared/src/balance_transaction.rs @@ -4,7 +4,9 @@ /// Related guide: [Balance transaction types](https://stripe.com/docs/reports/balance-transaction-types). /// /// For more details see <<https://stripe.com/docs/api/balance_transactions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BalanceTransaction { /// Gross amount of this transaction (in cents (or local equivalent)). /// A positive value represents funds charged to another party, and a negative value represents funds sent to another party. @@ -40,13 +42,166 @@ pub struct BalanceTransaction { pub source: Option<stripe_types::Expandable<stripe_shared::BalanceTransactionSource>>, /// The transaction's net funds status in the Stripe balance, which are either `available` or `pending`. pub status: String, - /// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. + /// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_inbound`, `obligation_outbound`, `obligation_reversal_inbound`, `obligation_reversal_outbound`, `obligation_payout`, `obligation_payout_failure`, `payment`, `payment_failure_refund`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. /// Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types). /// To classify transactions for accounting purposes, consider `reporting_category` instead. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: BalanceTransactionType, } -/// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `climate_order_purchase`, `climate_order_refund`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_outbound`, `obligation_reversal_inbound`, `payment`, `payment_failure_refund`, `payment_network_reserve_hold`, `payment_network_reserve_release`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. +#[cfg(feature = "min-ser")] +pub struct BalanceTransactionBuilder { + amount: Option<i64>, + available_on: Option<stripe_types::Timestamp>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + exchange_rate: Option<Option<f64>>, + fee: Option<i64>, + fee_details: Option<Vec<stripe_shared::Fee>>, + id: Option<stripe_shared::BalanceTransactionId>, + net: Option<i64>, + reporting_category: Option<String>, + source: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransactionSource>>>, + status: Option<String>, + type_: Option<BalanceTransactionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BalanceTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BalanceTransaction>, + builder: BalanceTransactionBuilder, + } + + impl Visitor for Place<BalanceTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BalanceTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for BalanceTransactionBuilder { + type Out = BalanceTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "available_on" => Deserialize::begin(&mut self.available_on), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "exchange_rate" => Deserialize::begin(&mut self.exchange_rate), + "fee" => Deserialize::begin(&mut self.fee), + "fee_details" => Deserialize::begin(&mut self.fee_details), + "id" => Deserialize::begin(&mut self.id), + "net" => Deserialize::begin(&mut self.net), + "reporting_category" => Deserialize::begin(&mut self.reporting_category), + "source" => Deserialize::begin(&mut self.source), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + available_on: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + exchange_rate: Deserialize::default(), + fee: Deserialize::default(), + fee_details: Deserialize::default(), + id: Deserialize::default(), + net: Deserialize::default(), + reporting_category: Deserialize::default(), + source: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let available_on = self.available_on.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let exchange_rate = self.exchange_rate.take()?; + let fee = self.fee.take()?; + let fee_details = self.fee_details.take()?; + let id = self.id.take()?; + let net = self.net.take()?; + let reporting_category = self.reporting_category.take()?; + let source = self.source.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { amount, available_on, created, currency, description, exchange_rate, fee, fee_details, id, net, reporting_category, source, status, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BalanceTransaction { + type Builder = BalanceTransactionBuilder; + } + + impl FromValueOpt for BalanceTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BalanceTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "available_on" => b.available_on = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "exchange_rate" => b.exchange_rate = Some(FromValueOpt::from_value(v)?), + "fee" => b.fee = Some(FromValueOpt::from_value(v)?), + "fee_details" => b.fee_details = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "net" => b.net = Some(FromValueOpt::from_value(v)?), + "reporting_category" => b.reporting_category = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// Transaction type: `adjustment`, `advance`, `advance_funding`, `anticipation_repayment`, `application_fee`, `application_fee_refund`, `charge`, `connect_collection_transfer`, `contribution`, `issuing_authorization_hold`, `issuing_authorization_release`, `issuing_dispute`, `issuing_transaction`, `obligation_inbound`, `obligation_outbound`, `obligation_reversal_inbound`, `obligation_reversal_outbound`, `obligation_payout`, `obligation_payout_failure`, `payment`, `payment_failure_refund`, `payment_refund`, `payment_reversal`, `payment_unreconciled`, `payout`, `payout_cancel`, `payout_failure`, `refund`, `refund_failure`, `reserve_transaction`, `reserved_funds`, `stripe_fee`, `stripe_fx_fee`, `tax_fee`, `topup`, `topup_reversal`, `transfer`, `transfer_cancel`, `transfer_failure`, or `transfer_refund`. /// Learn more about [balance transaction types and what they represent](https://stripe.com/docs/reports/balance-transaction-types). /// To classify transactions for accounting purposes, consider `reporting_category` instead. #[derive(Copy, Clone, Eq, PartialEq)] @@ -59,20 +214,20 @@ pub enum BalanceTransactionType { ApplicationFee, ApplicationFeeRefund, Charge, - ClimateOrderPurchase, - ClimateOrderRefund, ConnectCollectionTransfer, Contribution, IssuingAuthorizationHold, IssuingAuthorizationRelease, IssuingDispute, IssuingTransaction, + ObligationInbound, ObligationOutbound, + ObligationPayout, + ObligationPayoutFailure, ObligationReversalInbound, + ObligationReversalOutbound, Payment, PaymentFailureRefund, - PaymentNetworkReserveHold, - PaymentNetworkReserveRelease, PaymentRefund, PaymentReversal, PaymentUnreconciled, @@ -106,20 +261,20 @@ impl BalanceTransactionType { ApplicationFee => "application_fee", ApplicationFeeRefund => "application_fee_refund", Charge => "charge", - ClimateOrderPurchase => "climate_order_purchase", - ClimateOrderRefund => "climate_order_refund", ConnectCollectionTransfer => "connect_collection_transfer", Contribution => "contribution", IssuingAuthorizationHold => "issuing_authorization_hold", IssuingAuthorizationRelease => "issuing_authorization_release", IssuingDispute => "issuing_dispute", IssuingTransaction => "issuing_transaction", + ObligationInbound => "obligation_inbound", ObligationOutbound => "obligation_outbound", + ObligationPayout => "obligation_payout", + ObligationPayoutFailure => "obligation_payout_failure", ObligationReversalInbound => "obligation_reversal_inbound", + ObligationReversalOutbound => "obligation_reversal_outbound", Payment => "payment", PaymentFailureRefund => "payment_failure_refund", - PaymentNetworkReserveHold => "payment_network_reserve_hold", - PaymentNetworkReserveRelease => "payment_network_reserve_release", PaymentRefund => "payment_refund", PaymentReversal => "payment_reversal", PaymentUnreconciled => "payment_unreconciled", @@ -156,20 +311,20 @@ impl std::str::FromStr for BalanceTransactionType { "application_fee" => Ok(ApplicationFee), "application_fee_refund" => Ok(ApplicationFeeRefund), "charge" => Ok(Charge), - "climate_order_purchase" => Ok(ClimateOrderPurchase), - "climate_order_refund" => Ok(ClimateOrderRefund), "connect_collection_transfer" => Ok(ConnectCollectionTransfer), "contribution" => Ok(Contribution), "issuing_authorization_hold" => Ok(IssuingAuthorizationHold), "issuing_authorization_release" => Ok(IssuingAuthorizationRelease), "issuing_dispute" => Ok(IssuingDispute), "issuing_transaction" => Ok(IssuingTransaction), + "obligation_inbound" => Ok(ObligationInbound), "obligation_outbound" => Ok(ObligationOutbound), + "obligation_payout" => Ok(ObligationPayout), + "obligation_payout_failure" => Ok(ObligationPayoutFailure), "obligation_reversal_inbound" => Ok(ObligationReversalInbound), + "obligation_reversal_outbound" => Ok(ObligationReversalOutbound), "payment" => Ok(Payment), "payment_failure_refund" => Ok(PaymentFailureRefund), - "payment_network_reserve_hold" => Ok(PaymentNetworkReserveHold), - "payment_network_reserve_release" => Ok(PaymentNetworkReserveRelease), "payment_refund" => Ok(PaymentRefund), "payment_reversal" => Ok(PaymentReversal), "payment_unreconciled" => Ok(PaymentUnreconciled), @@ -216,9 +371,27 @@ impl<'de> serde::Deserialize<'de> for BalanceTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(BalanceTransactionType::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for BalanceTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<BalanceTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BalanceTransactionType::from_str(s).unwrap_or(BalanceTransactionType::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(BalanceTransactionType); impl stripe_types::Object for BalanceTransaction { type Id = stripe_shared::BalanceTransactionId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/balance_transaction_source.rs b/generated/stripe_shared/src/balance_transaction_source.rs index 5ca060b07..b33a79f20 100644 --- a/generated/stripe_shared/src/balance_transaction_source.rs +++ b/generated/stripe_shared/src/balance_transaction_source.rs @@ -1,42 +1,144 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum BalanceTransactionSource { - #[serde(rename = "application_fee")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "application_fee"))] ApplicationFee(stripe_shared::ApplicationFee), - #[serde(rename = "charge")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "charge"))] Charge(stripe_shared::Charge), - #[serde(rename = "connect_collection_transfer")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "connect_collection_transfer"))] ConnectCollectionTransfer(stripe_shared::ConnectCollectionTransfer), - #[serde(rename = "customer_cash_balance_transaction")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "customer_cash_balance_transaction"))] CustomerCashBalanceTransaction(stripe_shared::CustomerCashBalanceTransaction), - #[serde(rename = "dispute")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "dispute"))] Dispute(stripe_shared::Dispute), - #[serde(rename = "fee_refund")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "fee_refund"))] ApplicationFeeRefund(stripe_shared::ApplicationFeeRefund), - #[serde(rename = "issuing.authorization")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "issuing.authorization"))] IssuingAuthorization(stripe_shared::IssuingAuthorization), - #[serde(rename = "issuing.dispute")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "issuing.dispute"))] IssuingDispute(stripe_shared::IssuingDispute), - #[serde(rename = "issuing.transaction")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "issuing.transaction"))] IssuingTransaction(stripe_shared::IssuingTransaction), - #[serde(rename = "payout")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "payout"))] Payout(stripe_shared::Payout), - #[serde(rename = "platform_tax_fee")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "platform_tax_fee"))] PlatformTaxFee(stripe_shared::PlatformTaxFee), - #[serde(rename = "refund")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "refund"))] Refund(stripe_shared::Refund), - #[serde(rename = "reserve_transaction")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "reserve_transaction"))] ReserveTransaction(stripe_shared::ReserveTransaction), - #[serde(rename = "tax_deducted_at_source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "tax_deducted_at_source"))] TaxDeductedAtSource(stripe_shared::TaxDeductedAtSource), - #[serde(rename = "topup")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "topup"))] Topup(stripe_shared::Topup), - #[serde(rename = "transfer")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "transfer"))] Transfer(stripe_shared::Transfer), - #[serde(rename = "transfer_reversal")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "transfer_reversal"))] TransferReversal(stripe_shared::TransferReversal), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct BalanceTransactionSourceBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<BalanceTransactionSource>, + builder: BalanceTransactionSourceBuilder, + } + + impl Deserialize for BalanceTransactionSource { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<BalanceTransactionSource> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for BalanceTransactionSourceBuilder { + type Out = BalanceTransactionSource; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + BalanceTransactionSource::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for BalanceTransactionSource { + type Builder = BalanceTransactionSourceBuilder; + } + impl BalanceTransactionSource { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "application_fee" => Self::ApplicationFee(FromValueOpt::from_value(Value::Object(o))?), + "charge" => Self::Charge(FromValueOpt::from_value(Value::Object(o))?), + "connect_collection_transfer" => Self::ConnectCollectionTransfer(FromValueOpt::from_value(Value::Object(o))?), + "customer_cash_balance_transaction" => Self::CustomerCashBalanceTransaction(FromValueOpt::from_value(Value::Object(o))?), + "dispute" => Self::Dispute(FromValueOpt::from_value(Value::Object(o))?), + "fee_refund" => Self::ApplicationFeeRefund(FromValueOpt::from_value(Value::Object(o))?), + "issuing.authorization" => Self::IssuingAuthorization(FromValueOpt::from_value(Value::Object(o))?), + "issuing.dispute" => Self::IssuingDispute(FromValueOpt::from_value(Value::Object(o))?), + "issuing.transaction" => Self::IssuingTransaction(FromValueOpt::from_value(Value::Object(o))?), + "payout" => Self::Payout(FromValueOpt::from_value(Value::Object(o))?), + "platform_tax_fee" => Self::PlatformTaxFee(FromValueOpt::from_value(Value::Object(o))?), + "refund" => Self::Refund(FromValueOpt::from_value(Value::Object(o))?), + "reserve_transaction" => Self::ReserveTransaction(FromValueOpt::from_value(Value::Object(o))?), + "tax_deducted_at_source" => Self::TaxDeductedAtSource(FromValueOpt::from_value(Value::Object(o))?), + "topup" => Self::Topup(FromValueOpt::from_value(Value::Object(o))?), + "transfer" => Self::Transfer(FromValueOpt::from_value(Value::Object(o))?), + "transfer_reversal" => Self::TransferReversal(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for BalanceTransactionSource { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + impl stripe_types::Object for BalanceTransactionSource { type Id = smol_str::SmolStr; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/bank_account.rs b/generated/stripe_shared/src/bank_account.rs index 8aacedb5a..bed4497a0 100644 --- a/generated/stripe_shared/src/bank_account.rs +++ b/generated/stripe_shared/src/bank_account.rs @@ -5,10 +5,11 @@ /// They can be bank accounts or debit cards as well, and are documented in the links above. /// /// Related guide: [Bank debits and transfers](https://stripe.com/docs/payments/bank-debits-transfers) -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BankAccount { /// The ID of the account that the bank account is associated with. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option<stripe_types::Expandable<stripe_shared::Account>>, /// The name of the person or business that owns the bank account. pub account_holder_name: Option<String>, @@ -20,7 +21,6 @@ pub struct BankAccount { pub account_type: Option<String>, /// A set of available payout methods for this bank account. /// Only values from this set should be passed as the `method` when creating a payout. - #[serde(skip_serializing_if = "Option::is_none")] pub available_payout_methods: Option<Vec<BankAccountAvailablePayoutMethods>>, /// Name of the bank associated with the routing number (e.g., `WELLS FARGO`). pub bank_name: Option<String>, @@ -29,16 +29,13 @@ pub struct BankAccount { /// Three-letter [ISO code for the currency](https://stripe.com/docs/payouts) paid out to the bank account. pub currency: stripe_types::Currency, /// The ID of the customer that the bank account is associated with. - #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, /// Whether this bank account is the default external account for its currency. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for_currency: Option<bool>, /// Uniquely identifies this particular bank account. /// You can use this attribute to check whether two bank accounts are the same. pub fingerprint: Option<String>, /// Information about the [upcoming new requirements for the bank account](https://stripe.com/docs/connect/custom-accounts/future-requirements), including what information needs to be collected, and by when. - #[serde(skip_serializing_if = "Option::is_none")] pub future_requirements: Option<stripe_shared::ExternalAccountRequirements>, /// Unique identifier for the object. pub id: stripe_shared::BankAccountId, @@ -46,10 +43,8 @@ pub struct BankAccount { pub last4: String, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. - #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<std::collections::HashMap<String, String>>, /// Information about the requirements for the bank account, including what information needs to be collected. - #[serde(skip_serializing_if = "Option::is_none")] pub requirements: Option<stripe_shared::ExternalAccountRequirements>, /// The routing transit number for the bank account. pub routing_number: Option<String>, @@ -68,6 +63,198 @@ pub struct BankAccount { /// This means the other statuses don't apply. pub status: String, } +#[cfg(feature = "min-ser")] +pub struct BankAccountBuilder { + account: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + account_holder_name: Option<Option<String>>, + account_holder_type: Option<Option<String>>, + account_type: Option<Option<String>>, + available_payout_methods: Option<Option<Vec<BankAccountAvailablePayoutMethods>>>, + bank_name: Option<Option<String>>, + country: Option<String>, + currency: Option<stripe_types::Currency>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + default_for_currency: Option<Option<bool>>, + fingerprint: Option<Option<String>>, + future_requirements: Option<Option<stripe_shared::ExternalAccountRequirements>>, + id: Option<stripe_shared::BankAccountId>, + last4: Option<String>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + requirements: Option<Option<stripe_shared::ExternalAccountRequirements>>, + routing_number: Option<Option<String>>, + status: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BankAccount>, + builder: BankAccountBuilder, + } + + impl Visitor for Place<BankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for BankAccountBuilder { + type Out = BankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "account_holder_name" => Deserialize::begin(&mut self.account_holder_name), + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "account_type" => Deserialize::begin(&mut self.account_type), + "available_payout_methods" => Deserialize::begin(&mut self.available_payout_methods), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "country" => Deserialize::begin(&mut self.country), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "default_for_currency" => Deserialize::begin(&mut self.default_for_currency), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "future_requirements" => Deserialize::begin(&mut self.future_requirements), + "id" => Deserialize::begin(&mut self.id), + "last4" => Deserialize::begin(&mut self.last4), + "metadata" => Deserialize::begin(&mut self.metadata), + "requirements" => Deserialize::begin(&mut self.requirements), + "routing_number" => Deserialize::begin(&mut self.routing_number), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + account_holder_name: Deserialize::default(), + account_holder_type: Deserialize::default(), + account_type: Deserialize::default(), + available_payout_methods: Deserialize::default(), + bank_name: Deserialize::default(), + country: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + default_for_currency: Deserialize::default(), + fingerprint: Deserialize::default(), + future_requirements: Deserialize::default(), + id: Deserialize::default(), + last4: Deserialize::default(), + metadata: Deserialize::default(), + requirements: Deserialize::default(), + routing_number: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let account_holder_name = self.account_holder_name.take()?; + let account_holder_type = self.account_holder_type.take()?; + let account_type = self.account_type.take()?; + let available_payout_methods = self.available_payout_methods.take()?; + let bank_name = self.bank_name.take()?; + let country = self.country.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let default_for_currency = self.default_for_currency.take()?; + let fingerprint = self.fingerprint.take()?; + let future_requirements = self.future_requirements.take()?; + let id = self.id.take()?; + let last4 = self.last4.take()?; + let metadata = self.metadata.take()?; + let requirements = self.requirements.take()?; + let routing_number = self.routing_number.take()?; + let status = self.status.take()?; + + Some(Self::Out { + account, + account_holder_name, + account_holder_type, + account_type, + available_payout_methods, + bank_name, + country, + currency, + customer, + default_for_currency, + fingerprint, + future_requirements, + id, + last4, + metadata, + requirements, + routing_number, + status, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BankAccount { + type Builder = BankAccountBuilder; + } + + impl FromValueOpt for BankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "account_holder_name" => b.account_holder_name = Some(FromValueOpt::from_value(v)?), + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "available_payout_methods" => b.available_payout_methods = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "default_for_currency" => b.default_for_currency = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "future_requirements" => b.future_requirements = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "requirements" => b.requirements = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A set of available payout methods for this bank account. /// Only values from this set should be passed as the `method` when creating a payout. #[derive(Copy, Clone, Eq, PartialEq)] @@ -119,11 +306,27 @@ impl<'de> serde::Deserialize<'de> for BankAccountAvailablePayoutMethods { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for BankAccountAvailablePayoutMethods") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for BankAccountAvailablePayoutMethods")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for BankAccountAvailablePayoutMethods { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<BankAccountAvailablePayoutMethods> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BankAccountAvailablePayoutMethods::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(BankAccountAvailablePayoutMethods); impl stripe_types::Object for BankAccount { type Id = stripe_shared::BankAccountId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/billing_details.rs b/generated/stripe_shared/src/billing_details.rs index 39da030a3..b60665a05 100644 --- a/generated/stripe_shared/src/billing_details.rs +++ b/generated/stripe_shared/src/billing_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct BillingDetails { /// Billing address. pub address: Option<stripe_shared::Address>, @@ -9,3 +11,101 @@ pub struct BillingDetails { /// Billing phone number (including extension). pub phone: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct BillingDetailsBuilder { + address: Option<Option<stripe_shared::Address>>, + email: Option<Option<String>>, + name: Option<Option<String>>, + phone: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BillingDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<BillingDetails>, + builder: BillingDetailsBuilder, + } + + impl Visitor for Place<BillingDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: BillingDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for BillingDetailsBuilder { + type Out = BillingDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + "phone" => Deserialize::begin(&mut self.phone), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address: Deserialize::default(), email: Deserialize::default(), name: Deserialize::default(), phone: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + let phone = self.phone.take()?; + + Some(Self::Out { address, email, name, phone }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for BillingDetails { + type Builder = BillingDetailsBuilder; + } + + impl FromValueOpt for BillingDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BillingDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/cancellation_details.rs b/generated/stripe_shared/src/cancellation_details.rs index 977140f99..c221d7e76 100644 --- a/generated/stripe_shared/src/cancellation_details.rs +++ b/generated/stripe_shared/src/cancellation_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CancellationDetails { /// Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user. pub comment: Option<String>, @@ -7,6 +9,100 @@ pub struct CancellationDetails { /// Why this subscription was canceled. pub reason: Option<CancellationDetailsReason>, } +#[cfg(feature = "min-ser")] +pub struct CancellationDetailsBuilder { + comment: Option<Option<String>>, + feedback: Option<Option<CancellationDetailsFeedback>>, + reason: Option<Option<CancellationDetailsReason>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CancellationDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CancellationDetails>, + builder: CancellationDetailsBuilder, + } + + impl Visitor for Place<CancellationDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CancellationDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for CancellationDetailsBuilder { + type Out = CancellationDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "comment" => Deserialize::begin(&mut self.comment), + "feedback" => Deserialize::begin(&mut self.feedback), + "reason" => Deserialize::begin(&mut self.reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { comment: Deserialize::default(), feedback: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let comment = self.comment.take()?; + let feedback = self.feedback.take()?; + let reason = self.reason.take()?; + + Some(Self::Out { comment, feedback, reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CancellationDetails { + type Builder = CancellationDetailsBuilder; + } + + impl FromValueOpt for CancellationDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CancellationDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "comment" => b.comment = Some(FromValueOpt::from_value(v)?), + "feedback" => b.feedback = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CancellationDetailsFeedback { @@ -75,10 +171,27 @@ impl<'de> serde::Deserialize<'de> for CancellationDetailsFeedback { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CancellationDetailsFeedback")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CancellationDetailsFeedback")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CancellationDetailsFeedback { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CancellationDetailsFeedback> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CancellationDetailsFeedback::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CancellationDetailsFeedback); /// Why this subscription was canceled. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CancellationDetailsReason { @@ -132,7 +245,24 @@ impl<'de> serde::Deserialize<'de> for CancellationDetailsReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CancellationDetailsReason")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CancellationDetailsReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CancellationDetailsReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CancellationDetailsReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CancellationDetailsReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CancellationDetailsReason); diff --git a/generated/stripe_shared/src/capability.rs b/generated/stripe_shared/src/capability.rs index 4876b8912..9d0bcdf7d 100644 --- a/generated/stripe_shared/src/capability.rs +++ b/generated/stripe_shared/src/capability.rs @@ -3,11 +3,12 @@ /// Related guide: [Account capabilities](https://stripe.com/docs/connect/account-capabilities) /// /// For more details see <<https://stripe.com/docs/api/capabilities/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Capability { /// The account for which the capability enables functionality. pub account: stripe_types::Expandable<stripe_shared::Account>, - #[serde(skip_serializing_if = "Option::is_none")] pub future_requirements: Option<stripe_shared::AccountCapabilityFutureRequirements>, /// The identifier for the capability. pub id: stripe_shared::CapabilityId, @@ -15,11 +16,128 @@ pub struct Capability { pub requested: bool, /// Time at which the capability was requested. Measured in seconds since the Unix epoch. pub requested_at: Option<stripe_types::Timestamp>, - #[serde(skip_serializing_if = "Option::is_none")] pub requirements: Option<stripe_shared::AccountCapabilityRequirements>, /// The status of the capability. Can be `active`, `inactive`, `pending`, or `unrequested`. pub status: CapabilityStatus, } +#[cfg(feature = "min-ser")] +pub struct CapabilityBuilder { + account: Option<stripe_types::Expandable<stripe_shared::Account>>, + future_requirements: Option<Option<stripe_shared::AccountCapabilityFutureRequirements>>, + id: Option<stripe_shared::CapabilityId>, + requested: Option<bool>, + requested_at: Option<Option<stripe_types::Timestamp>>, + requirements: Option<Option<stripe_shared::AccountCapabilityRequirements>>, + status: Option<CapabilityStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Capability { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Capability>, + builder: CapabilityBuilder, + } + + impl Visitor for Place<Capability> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CapabilityBuilder::deser_default() })) + } + } + + impl MapBuilder for CapabilityBuilder { + type Out = Capability; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "future_requirements" => Deserialize::begin(&mut self.future_requirements), + "id" => Deserialize::begin(&mut self.id), + "requested" => Deserialize::begin(&mut self.requested), + "requested_at" => Deserialize::begin(&mut self.requested_at), + "requirements" => Deserialize::begin(&mut self.requirements), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + future_requirements: Deserialize::default(), + id: Deserialize::default(), + requested: Deserialize::default(), + requested_at: Deserialize::default(), + requirements: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let future_requirements = self.future_requirements.take()?; + let id = self.id.take()?; + let requested = self.requested.take()?; + let requested_at = self.requested_at.take()?; + let requirements = self.requirements.take()?; + let status = self.status.take()?; + + Some(Self::Out { account, future_requirements, id, requested, requested_at, requirements, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Capability { + type Builder = CapabilityBuilder; + } + + impl FromValueOpt for Capability { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CapabilityBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "future_requirements" => b.future_requirements = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "requested" => b.requested = Some(FromValueOpt::from_value(v)?), + "requested_at" => b.requested_at = Some(FromValueOpt::from_value(v)?), + "requirements" => b.requirements = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the capability. Can be `active`, `inactive`, `pending`, or `unrequested`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CapabilityStatus { @@ -79,10 +197,27 @@ impl<'de> serde::Deserialize<'de> for CapabilityStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CapabilityStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CapabilityStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CapabilityStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CapabilityStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CapabilityStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CapabilityStatus); impl stripe_types::Object for Capability { type Id = stripe_shared::CapabilityId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/card.rs b/generated/stripe_shared/src/card.rs index 1200b690d..4f2cf209d 100644 --- a/generated/stripe_shared/src/card.rs +++ b/generated/stripe_shared/src/card.rs @@ -5,11 +5,12 @@ /// Related guide: [Card payments with Sources](https://stripe.com/docs/sources/cards) /// /// For more details see <<https://stripe.com/docs/api/cards/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Card { /// The account this card belongs to. /// This attribute will not be in the card object if the card belongs to a customer or recipient instead. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option<stripe_types::Expandable<stripe_shared::Account>>, /// City/District/Suburb/Town/Village. pub address_city: Option<String>, @@ -29,7 +30,6 @@ pub struct Card { pub address_zip_check: Option<String>, /// A set of available payout methods for this card. /// Only values from this set should be passed as the `method` when creating a payout. - #[serde(skip_serializing_if = "Option::is_none")] pub available_payout_methods: Option<Vec<CardAvailablePayoutMethods>>, /// Card brand. /// Can be `American Express`, `Diners Club`, `Discover`, `Eftpos Australia`, `JCB`, `MasterCard`, `UnionPay`, `Visa`, or `Unknown`. @@ -40,11 +40,9 @@ pub struct Card { /// Three-letter [ISO code for currency](https://stripe.com/docs/payouts). /// Only applicable on accounts (not customers or recipients). /// The card can be used as a transfer destination for funds in this currency. - #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<stripe_types::Currency>, /// The customer that this card belongs to. /// This attribute will not be in the card object if the card belongs to an account or recipient instead. - #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, /// If a CVC was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`. /// A result of unchecked indicates that CVC was provided but hasn't been checked yet. @@ -52,11 +50,9 @@ pub struct Card { /// For more details, see [Check if a card is valid without a charge](https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge). pub cvc_check: Option<String>, /// Whether this card is the default external account for its currency. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for_currency: Option<bool>, /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// (For tokenized numbers only.) The last four digits of the device account number. pub dynamic_last4: Option<String>, @@ -69,7 +65,6 @@ pub struct Card { /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number. /// /// *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*. - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`. pub funding: String, @@ -77,11 +72,9 @@ pub struct Card { pub id: stripe_shared::CardId, /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, /// The last four digits of the card. pub last4: String, @@ -92,12 +85,275 @@ pub struct Card { pub name: Option<String>, /// For external accounts that are cards, possible values are `new` and `errored`. /// If a payout fails, the status is set to `errored` and [scheduled payouts](https://stripe.com/docs/payouts#payout-schedule) are stopped until account details are updated. - #[serde(skip_serializing_if = "Option::is_none")] pub status: Option<String>, /// If the card number is tokenized, this is the method that was used. /// Can be `android_pay` (includes Google Pay), `apple_pay`, `masterpass`, `visa_checkout`, or null. pub tokenization_method: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CardBuilder { + account: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + address_city: Option<Option<String>>, + address_country: Option<Option<String>>, + address_line1: Option<Option<String>>, + address_line1_check: Option<Option<String>>, + address_line2: Option<Option<String>>, + address_state: Option<Option<String>>, + address_zip: Option<Option<String>>, + address_zip_check: Option<Option<String>>, + available_payout_methods: Option<Option<Vec<CardAvailablePayoutMethods>>>, + brand: Option<String>, + country: Option<Option<String>>, + currency: Option<Option<stripe_types::Currency>>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + cvc_check: Option<Option<String>>, + default_for_currency: Option<Option<bool>>, + description: Option<Option<String>>, + dynamic_last4: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + fingerprint: Option<Option<String>>, + funding: Option<String>, + id: Option<stripe_shared::CardId>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<String>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + name: Option<Option<String>>, + status: Option<Option<String>>, + tokenization_method: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Card { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Card>, + builder: CardBuilder, + } + + impl Visitor for Place<Card> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CardBuilder::deser_default() })) + } + } + + impl MapBuilder for CardBuilder { + type Out = Card; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "address_city" => Deserialize::begin(&mut self.address_city), + "address_country" => Deserialize::begin(&mut self.address_country), + "address_line1" => Deserialize::begin(&mut self.address_line1), + "address_line1_check" => Deserialize::begin(&mut self.address_line1_check), + "address_line2" => Deserialize::begin(&mut self.address_line2), + "address_state" => Deserialize::begin(&mut self.address_state), + "address_zip" => Deserialize::begin(&mut self.address_zip), + "address_zip_check" => Deserialize::begin(&mut self.address_zip_check), + "available_payout_methods" => Deserialize::begin(&mut self.available_payout_methods), + "brand" => Deserialize::begin(&mut self.brand), + "country" => Deserialize::begin(&mut self.country), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "cvc_check" => Deserialize::begin(&mut self.cvc_check), + "default_for_currency" => Deserialize::begin(&mut self.default_for_currency), + "description" => Deserialize::begin(&mut self.description), + "dynamic_last4" => Deserialize::begin(&mut self.dynamic_last4), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "id" => Deserialize::begin(&mut self.id), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "metadata" => Deserialize::begin(&mut self.metadata), + "name" => Deserialize::begin(&mut self.name), + "status" => Deserialize::begin(&mut self.status), + "tokenization_method" => Deserialize::begin(&mut self.tokenization_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + address_city: Deserialize::default(), + address_country: Deserialize::default(), + address_line1: Deserialize::default(), + address_line1_check: Deserialize::default(), + address_line2: Deserialize::default(), + address_state: Deserialize::default(), + address_zip: Deserialize::default(), + address_zip_check: Deserialize::default(), + available_payout_methods: Deserialize::default(), + brand: Deserialize::default(), + country: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + cvc_check: Deserialize::default(), + default_for_currency: Deserialize::default(), + description: Deserialize::default(), + dynamic_last4: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + id: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + metadata: Deserialize::default(), + name: Deserialize::default(), + status: Deserialize::default(), + tokenization_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let address_city = self.address_city.take()?; + let address_country = self.address_country.take()?; + let address_line1 = self.address_line1.take()?; + let address_line1_check = self.address_line1_check.take()?; + let address_line2 = self.address_line2.take()?; + let address_state = self.address_state.take()?; + let address_zip = self.address_zip.take()?; + let address_zip_check = self.address_zip_check.take()?; + let available_payout_methods = self.available_payout_methods.take()?; + let brand = self.brand.take()?; + let country = self.country.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let cvc_check = self.cvc_check.take()?; + let default_for_currency = self.default_for_currency.take()?; + let description = self.description.take()?; + let dynamic_last4 = self.dynamic_last4.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let id = self.id.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let metadata = self.metadata.take()?; + let name = self.name.take()?; + let status = self.status.take()?; + let tokenization_method = self.tokenization_method.take()?; + + Some(Self::Out { + account, + address_city, + address_country, + address_line1, + address_line1_check, + address_line2, + address_state, + address_zip, + address_zip_check, + available_payout_methods, + brand, + country, + currency, + customer, + cvc_check, + default_for_currency, + description, + dynamic_last4, + exp_month, + exp_year, + fingerprint, + funding, + id, + iin, + issuer, + last4, + metadata, + name, + status, + tokenization_method, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Card { + type Builder = CardBuilder; + } + + impl FromValueOpt for Card { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "address_city" => b.address_city = Some(FromValueOpt::from_value(v)?), + "address_country" => b.address_country = Some(FromValueOpt::from_value(v)?), + "address_line1" => b.address_line1 = Some(FromValueOpt::from_value(v)?), + "address_line1_check" => b.address_line1_check = Some(FromValueOpt::from_value(v)?), + "address_line2" => b.address_line2 = Some(FromValueOpt::from_value(v)?), + "address_state" => b.address_state = Some(FromValueOpt::from_value(v)?), + "address_zip" => b.address_zip = Some(FromValueOpt::from_value(v)?), + "address_zip_check" => b.address_zip_check = Some(FromValueOpt::from_value(v)?), + "available_payout_methods" => b.available_payout_methods = Some(FromValueOpt::from_value(v)?), + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "cvc_check" => b.cvc_check = Some(FromValueOpt::from_value(v)?), + "default_for_currency" => b.default_for_currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "dynamic_last4" => b.dynamic_last4 = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "tokenization_method" => b.tokenization_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A set of available payout methods for this card. /// Only values from this set should be passed as the `method` when creating a payout. #[derive(Copy, Clone, Eq, PartialEq)] @@ -149,10 +405,27 @@ impl<'de> serde::Deserialize<'de> for CardAvailablePayoutMethods { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CardAvailablePayoutMethods")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CardAvailablePayoutMethods")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CardAvailablePayoutMethods { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CardAvailablePayoutMethods> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CardAvailablePayoutMethods::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CardAvailablePayoutMethods); impl stripe_types::Object for Card { type Id = stripe_shared::CardId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/card_issuing_account_terms_of_service.rs b/generated/stripe_shared/src/card_issuing_account_terms_of_service.rs index de88385d1..88d9284ce 100644 --- a/generated/stripe_shared/src/card_issuing_account_terms_of_service.rs +++ b/generated/stripe_shared/src/card_issuing_account_terms_of_service.rs @@ -1,10 +1,105 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CardIssuingAccountTermsOfService { /// The Unix timestamp marking when the account representative accepted the service agreement. pub date: Option<stripe_types::Timestamp>, /// The IP address from which the account representative accepted the service agreement. pub ip: Option<String>, /// The user agent of the browser from which the account representative accepted the service agreement. - #[serde(skip_serializing_if = "Option::is_none")] pub user_agent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CardIssuingAccountTermsOfServiceBuilder { + date: Option<Option<stripe_types::Timestamp>>, + ip: Option<Option<String>>, + user_agent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CardIssuingAccountTermsOfService { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CardIssuingAccountTermsOfService>, + builder: CardIssuingAccountTermsOfServiceBuilder, + } + + impl Visitor for Place<CardIssuingAccountTermsOfService> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CardIssuingAccountTermsOfServiceBuilder::deser_default() })) + } + } + + impl MapBuilder for CardIssuingAccountTermsOfServiceBuilder { + type Out = CardIssuingAccountTermsOfService; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "date" => Deserialize::begin(&mut self.date), + "ip" => Deserialize::begin(&mut self.ip), + "user_agent" => Deserialize::begin(&mut self.user_agent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { date: Deserialize::default(), ip: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let date = self.date.take()?; + let ip = self.ip.take()?; + let user_agent = self.user_agent.take()?; + + Some(Self::Out { date, ip, user_agent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CardIssuingAccountTermsOfService { + type Builder = CardIssuingAccountTermsOfServiceBuilder; + } + + impl FromValueOpt for CardIssuingAccountTermsOfService { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CardIssuingAccountTermsOfServiceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "date" => b.date = Some(FromValueOpt::from_value(v)?), + "ip" => b.ip = Some(FromValueOpt::from_value(v)?), + "user_agent" => b.user_agent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/card_mandate_payment_method_details.rs b/generated/stripe_shared/src/card_mandate_payment_method_details.rs index 715b901ed..375bcf998 100644 --- a/generated/stripe_shared/src/card_mandate_payment_method_details.rs +++ b/generated/stripe_shared/src/card_mandate_payment_method_details.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CardMandatePaymentMethodDetails {} +#[cfg(feature = "min-ser")] +pub struct CardMandatePaymentMethodDetailsBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CardMandatePaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CardMandatePaymentMethodDetails>, + builder: CardMandatePaymentMethodDetailsBuilder, + } + + impl Visitor for Place<CardMandatePaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CardMandatePaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for CardMandatePaymentMethodDetailsBuilder { + type Out = CardMandatePaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CardMandatePaymentMethodDetails { + type Builder = CardMandatePaymentMethodDetailsBuilder; + } + + impl FromValueOpt for CardMandatePaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CardMandatePaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/cash_balance.rs b/generated/stripe_shared/src/cash_balance.rs index 90d8e489b..19a8e552c 100644 --- a/generated/stripe_shared/src/cash_balance.rs +++ b/generated/stripe_shared/src/cash_balance.rs @@ -3,7 +3,9 @@ /// These funds can be used for payment and can eventually be paid out to your bank account. /// /// For more details see <<https://stripe.com/docs/api/cash_balance/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CashBalance { /// A hash of all cash balances available to this customer. /// You cannot delete a customer with any cash balances, even if the balance is 0. @@ -15,3 +17,101 @@ pub struct CashBalance { pub livemode: bool, pub settings: stripe_shared::CustomerBalanceCustomerBalanceSettings, } +#[cfg(feature = "min-ser")] +pub struct CashBalanceBuilder { + available: Option<Option<std::collections::HashMap<String, i64>>>, + customer: Option<String>, + livemode: Option<bool>, + settings: Option<stripe_shared::CustomerBalanceCustomerBalanceSettings>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CashBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CashBalance>, + builder: CashBalanceBuilder, + } + + impl Visitor for Place<CashBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CashBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for CashBalanceBuilder { + type Out = CashBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available" => Deserialize::begin(&mut self.available), + "customer" => Deserialize::begin(&mut self.customer), + "livemode" => Deserialize::begin(&mut self.livemode), + "settings" => Deserialize::begin(&mut self.settings), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default(), customer: Deserialize::default(), livemode: Deserialize::default(), settings: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available = self.available.take()?; + let customer = self.customer.take()?; + let livemode = self.livemode.take()?; + let settings = self.settings.take()?; + + Some(Self::Out { available, customer, livemode, settings }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CashBalance { + type Builder = CashBalanceBuilder; + } + + impl FromValueOpt for CashBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CashBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available" => b.available = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "settings" => b.settings = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/charge.rs b/generated/stripe_shared/src/charge.rs index d4bc526f1..901f19831 100644 --- a/generated/stripe_shared/src/charge.rs +++ b/generated/stripe_shared/src/charge.rs @@ -4,7 +4,9 @@ /// Some legacy payment flows create Charges directly, which is not recommended for new integrations. /// /// For more details see <<https://stripe.com/docs/api/charges/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Charge { /// Amount intended to be collected by this payment. /// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). @@ -24,7 +26,6 @@ pub struct Charge { /// [See the Connect documentation](https://stripe.com/docs/connect/direct-charges#collecting-fees) for details. pub application_fee_amount: Option<i64>, /// Authorization code on the charge. - #[serde(skip_serializing_if = "Option::is_none")] pub authorization_code: Option<String>, /// ID of the balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes). pub balance_transaction: Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, @@ -46,8 +47,7 @@ pub struct Charge { /// Whether the charge has been disputed. pub disputed: bool, /// ID of the balance transaction that describes the reversal of the balance on your account due to payment failure. - pub failure_balance_transaction: - Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, + pub failure_balance_transaction: Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, /// Error code explaining reason for charge failure if available (see [the errors section](https://stripe.com/docs/error-codes) for a list of codes). pub failure_code: Option<String>, /// Message to user further explaining reason for charge failure if available. @@ -58,7 +58,6 @@ pub struct Charge { pub id: stripe_shared::ChargeId, /// ID of the invoice this charge is for if one exists. pub invoice: Option<stripe_types::Expandable<stripe_shared::Invoice>>, - #[serde(skip_serializing_if = "Option::is_none")] pub level3: Option<stripe_shared::Level3>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, @@ -79,7 +78,6 @@ pub struct Charge { pub payment_method: Option<String>, /// Details about the payment method at the time of the transaction. pub payment_method_details: Option<stripe_shared::PaymentMethodDetails>, - #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option<stripe_shared::RadarRadarOptions>, /// This is the email address that the receipt for this charge was sent to. pub receipt_email: Option<String>, @@ -118,7 +116,6 @@ pub struct Charge { /// The status of the payment is either `succeeded`, `pending`, or `failed`. pub status: ChargeStatus, /// ID of the transfer to the `destination` account (only applicable if the charge was created using the `destination` parameter). - #[serde(skip_serializing_if = "Option::is_none")] pub transfer: Option<stripe_types::Expandable<stripe_shared::Transfer>>, /// An optional dictionary including the account to automatically transfer to as part of a destination charge. /// [See the Connect documentation](https://stripe.com/docs/connect/destination-charges) for details. @@ -127,6 +124,372 @@ pub struct Charge { /// See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details. pub transfer_group: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct ChargeBuilder { + amount: Option<i64>, + amount_captured: Option<i64>, + amount_refunded: Option<i64>, + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + application_fee: Option<Option<stripe_types::Expandable<stripe_shared::ApplicationFee>>>, + application_fee_amount: Option<Option<i64>>, + authorization_code: Option<Option<String>>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + billing_details: Option<stripe_shared::BillingDetails>, + calculated_statement_descriptor: Option<Option<String>>, + captured: Option<bool>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + description: Option<Option<String>>, + disputed: Option<bool>, + failure_balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + failure_code: Option<Option<String>>, + failure_message: Option<Option<String>>, + fraud_details: Option<Option<stripe_shared::ChargeFraudDetails>>, + id: Option<stripe_shared::ChargeId>, + invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + level3: Option<Option<stripe_shared::Level3>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + outcome: Option<Option<stripe_shared::ChargeOutcome>>, + paid: Option<bool>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, + payment_method: Option<Option<String>>, + payment_method_details: Option<Option<stripe_shared::PaymentMethodDetails>>, + radar_options: Option<Option<stripe_shared::RadarRadarOptions>>, + receipt_email: Option<Option<String>>, + receipt_number: Option<Option<String>>, + receipt_url: Option<Option<String>>, + refunded: Option<bool>, + refunds: Option<Option<stripe_types::List<stripe_shared::Refund>>>, + review: Option<Option<stripe_types::Expandable<stripe_shared::Review>>>, + shipping: Option<Option<stripe_shared::Shipping>>, + source: Option<Option<stripe_shared::PaymentSource>>, + source_transfer: Option<Option<stripe_types::Expandable<stripe_shared::Transfer>>>, + statement_descriptor: Option<Option<String>>, + statement_descriptor_suffix: Option<Option<String>>, + status: Option<ChargeStatus>, + transfer: Option<Option<stripe_types::Expandable<stripe_shared::Transfer>>>, + transfer_data: Option<Option<stripe_shared::ChargeTransferData>>, + transfer_group: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Charge { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Charge>, + builder: ChargeBuilder, + } + + impl Visitor for Place<Charge> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ChargeBuilder::deser_default() })) + } + } + + impl MapBuilder for ChargeBuilder { + type Out = Charge; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_captured" => Deserialize::begin(&mut self.amount_captured), + "amount_refunded" => Deserialize::begin(&mut self.amount_refunded), + "application" => Deserialize::begin(&mut self.application), + "application_fee" => Deserialize::begin(&mut self.application_fee), + "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount), + "authorization_code" => Deserialize::begin(&mut self.authorization_code), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "billing_details" => Deserialize::begin(&mut self.billing_details), + "calculated_statement_descriptor" => Deserialize::begin(&mut self.calculated_statement_descriptor), + "captured" => Deserialize::begin(&mut self.captured), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "description" => Deserialize::begin(&mut self.description), + "disputed" => Deserialize::begin(&mut self.disputed), + "failure_balance_transaction" => Deserialize::begin(&mut self.failure_balance_transaction), + "failure_code" => Deserialize::begin(&mut self.failure_code), + "failure_message" => Deserialize::begin(&mut self.failure_message), + "fraud_details" => Deserialize::begin(&mut self.fraud_details), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "level3" => Deserialize::begin(&mut self.level3), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "outcome" => Deserialize::begin(&mut self.outcome), + "paid" => Deserialize::begin(&mut self.paid), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "payment_method" => Deserialize::begin(&mut self.payment_method), + "payment_method_details" => Deserialize::begin(&mut self.payment_method_details), + "radar_options" => Deserialize::begin(&mut self.radar_options), + "receipt_email" => Deserialize::begin(&mut self.receipt_email), + "receipt_number" => Deserialize::begin(&mut self.receipt_number), + "receipt_url" => Deserialize::begin(&mut self.receipt_url), + "refunded" => Deserialize::begin(&mut self.refunded), + "refunds" => Deserialize::begin(&mut self.refunds), + "review" => Deserialize::begin(&mut self.review), + "shipping" => Deserialize::begin(&mut self.shipping), + "source" => Deserialize::begin(&mut self.source), + "source_transfer" => Deserialize::begin(&mut self.source_transfer), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "statement_descriptor_suffix" => Deserialize::begin(&mut self.statement_descriptor_suffix), + "status" => Deserialize::begin(&mut self.status), + "transfer" => Deserialize::begin(&mut self.transfer), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + "transfer_group" => Deserialize::begin(&mut self.transfer_group), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_captured: Deserialize::default(), + amount_refunded: Deserialize::default(), + application: Deserialize::default(), + application_fee: Deserialize::default(), + application_fee_amount: Deserialize::default(), + authorization_code: Deserialize::default(), + balance_transaction: Deserialize::default(), + billing_details: Deserialize::default(), + calculated_statement_descriptor: Deserialize::default(), + captured: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + description: Deserialize::default(), + disputed: Deserialize::default(), + failure_balance_transaction: Deserialize::default(), + failure_code: Deserialize::default(), + failure_message: Deserialize::default(), + fraud_details: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + level3: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + on_behalf_of: Deserialize::default(), + outcome: Deserialize::default(), + paid: Deserialize::default(), + payment_intent: Deserialize::default(), + payment_method: Deserialize::default(), + payment_method_details: Deserialize::default(), + radar_options: Deserialize::default(), + receipt_email: Deserialize::default(), + receipt_number: Deserialize::default(), + receipt_url: Deserialize::default(), + refunded: Deserialize::default(), + refunds: Deserialize::default(), + review: Deserialize::default(), + shipping: Deserialize::default(), + source: Deserialize::default(), + source_transfer: Deserialize::default(), + statement_descriptor: Deserialize::default(), + statement_descriptor_suffix: Deserialize::default(), + status: Deserialize::default(), + transfer: Deserialize::default(), + transfer_data: Deserialize::default(), + transfer_group: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_captured = self.amount_captured.take()?; + let amount_refunded = self.amount_refunded.take()?; + let application = self.application.take()?; + let application_fee = self.application_fee.take()?; + let application_fee_amount = self.application_fee_amount.take()?; + let authorization_code = self.authorization_code.take()?; + let balance_transaction = self.balance_transaction.take()?; + let billing_details = self.billing_details.take()?; + let calculated_statement_descriptor = self.calculated_statement_descriptor.take()?; + let captured = self.captured.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let description = self.description.take()?; + let disputed = self.disputed.take()?; + let failure_balance_transaction = self.failure_balance_transaction.take()?; + let failure_code = self.failure_code.take()?; + let failure_message = self.failure_message.take()?; + let fraud_details = self.fraud_details.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let level3 = self.level3.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let outcome = self.outcome.take()?; + let paid = self.paid.take()?; + let payment_intent = self.payment_intent.take()?; + let payment_method = self.payment_method.take()?; + let payment_method_details = self.payment_method_details.take()?; + let radar_options = self.radar_options.take()?; + let receipt_email = self.receipt_email.take()?; + let receipt_number = self.receipt_number.take()?; + let receipt_url = self.receipt_url.take()?; + let refunded = self.refunded.take()?; + let refunds = self.refunds.take()?; + let review = self.review.take()?; + let shipping = self.shipping.take()?; + let source = self.source.take()?; + let source_transfer = self.source_transfer.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let statement_descriptor_suffix = self.statement_descriptor_suffix.take()?; + let status = self.status.take()?; + let transfer = self.transfer.take()?; + let transfer_data = self.transfer_data.take()?; + let transfer_group = self.transfer_group.take()?; + + Some(Self::Out { + amount, + amount_captured, + amount_refunded, + application, + application_fee, + application_fee_amount, + authorization_code, + balance_transaction, + billing_details, + calculated_statement_descriptor, + captured, + created, + currency, + customer, + description, + disputed, + failure_balance_transaction, + failure_code, + failure_message, + fraud_details, + id, + invoice, + level3, + livemode, + metadata, + on_behalf_of, + outcome, + paid, + payment_intent, + payment_method, + payment_method_details, + radar_options, + receipt_email, + receipt_number, + receipt_url, + refunded, + refunds, + review, + shipping, + source, + source_transfer, + statement_descriptor, + statement_descriptor_suffix, + status, + transfer, + transfer_data, + transfer_group, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Charge { + type Builder = ChargeBuilder; + } + + impl FromValueOpt for Charge { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ChargeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_captured" => b.amount_captured = Some(FromValueOpt::from_value(v)?), + "amount_refunded" => b.amount_refunded = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "application_fee" => b.application_fee = Some(FromValueOpt::from_value(v)?), + "application_fee_amount" => b.application_fee_amount = Some(FromValueOpt::from_value(v)?), + "authorization_code" => b.authorization_code = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "billing_details" => b.billing_details = Some(FromValueOpt::from_value(v)?), + "calculated_statement_descriptor" => b.calculated_statement_descriptor = Some(FromValueOpt::from_value(v)?), + "captured" => b.captured = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "disputed" => b.disputed = Some(FromValueOpt::from_value(v)?), + "failure_balance_transaction" => b.failure_balance_transaction = Some(FromValueOpt::from_value(v)?), + "failure_code" => b.failure_code = Some(FromValueOpt::from_value(v)?), + "failure_message" => b.failure_message = Some(FromValueOpt::from_value(v)?), + "fraud_details" => b.fraud_details = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "level3" => b.level3 = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "outcome" => b.outcome = Some(FromValueOpt::from_value(v)?), + "paid" => b.paid = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "payment_method" => b.payment_method = Some(FromValueOpt::from_value(v)?), + "payment_method_details" => b.payment_method_details = Some(FromValueOpt::from_value(v)?), + "radar_options" => b.radar_options = Some(FromValueOpt::from_value(v)?), + "receipt_email" => b.receipt_email = Some(FromValueOpt::from_value(v)?), + "receipt_number" => b.receipt_number = Some(FromValueOpt::from_value(v)?), + "receipt_url" => b.receipt_url = Some(FromValueOpt::from_value(v)?), + "refunded" => b.refunded = Some(FromValueOpt::from_value(v)?), + "refunds" => b.refunds = Some(FromValueOpt::from_value(v)?), + "review" => b.review = Some(FromValueOpt::from_value(v)?), + "shipping" => b.shipping = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "source_transfer" => b.source_transfer = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_suffix" => b.statement_descriptor_suffix = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "transfer" => b.transfer = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + "transfer_group" => b.transfer_group = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the payment is either `succeeded`, `pending`, or `failed`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ChargeStatus { @@ -183,6 +546,24 @@ impl<'de> serde::Deserialize<'de> for ChargeStatus { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ChargeStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ChargeStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ChargeStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ChargeStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ChargeStatus); impl stripe_types::Object for Charge { type Id = stripe_shared::ChargeId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/charge_fraud_details.rs b/generated/stripe_shared/src/charge_fraud_details.rs index e1de5731d..215937ec0 100644 --- a/generated/stripe_shared/src/charge_fraud_details.rs +++ b/generated/stripe_shared/src/charge_fraud_details.rs @@ -1,9 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ChargeFraudDetails { /// Assessments from Stripe. If set, the value is `fraudulent`. - #[serde(skip_serializing_if = "Option::is_none")] pub stripe_report: Option<String>, /// Assessments reported by you. If set, possible values of are `safe` and `fraudulent`. - #[serde(skip_serializing_if = "Option::is_none")] pub user_report: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct ChargeFraudDetailsBuilder { + stripe_report: Option<Option<String>>, + user_report: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ChargeFraudDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ChargeFraudDetails>, + builder: ChargeFraudDetailsBuilder, + } + + impl Visitor for Place<ChargeFraudDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ChargeFraudDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for ChargeFraudDetailsBuilder { + type Out = ChargeFraudDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "stripe_report" => Deserialize::begin(&mut self.stripe_report), + "user_report" => Deserialize::begin(&mut self.user_report), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { stripe_report: Deserialize::default(), user_report: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let stripe_report = self.stripe_report.take()?; + let user_report = self.user_report.take()?; + + Some(Self::Out { stripe_report, user_report }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ChargeFraudDetails { + type Builder = ChargeFraudDetailsBuilder; + } + + impl FromValueOpt for ChargeFraudDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ChargeFraudDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "stripe_report" => b.stripe_report = Some(FromValueOpt::from_value(v)?), + "user_report" => b.user_report = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/charge_outcome.rs b/generated/stripe_shared/src/charge_outcome.rs index d5840d096..0dbfbd055 100644 --- a/generated/stripe_shared/src/charge_outcome.rs +++ b/generated/stripe_shared/src/charge_outcome.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ChargeOutcome { /// Possible values are `approved_by_network`, `declined_by_network`, `not_sent_to_network`, and `reversed_after_approval`. /// The value `reversed_after_approval` indicates the payment was [blocked by Stripe](https://stripe.com/docs/declines#blocked-payments) after bank authorization, and may temporarily appear as "pending" on a cardholder's statement. @@ -14,21 +16,136 @@ pub struct ChargeOutcome { /// For non-card payments, and card-based payments predating the public assignment of risk levels, this field will have the value `not_assessed`. /// In the event of an error in the evaluation, this field will have the value `unknown`. /// This field is only available with Radar. - #[serde(skip_serializing_if = "Option::is_none")] pub risk_level: Option<String>, /// Stripe Radar's evaluation of the riskiness of the payment. /// Possible values for evaluated payments are between 0 and 100. /// For non-card payments, card-based payments predating the public assignment of risk scores, or in the event of an error during evaluation, this field will not be present. /// This field is only available with Radar for Fraud Teams. - #[serde(skip_serializing_if = "Option::is_none")] pub risk_score: Option<i64>, /// The ID of the Radar rule that matched the payment, if applicable. - #[serde(skip_serializing_if = "Option::is_none")] pub rule: Option<stripe_types::Expandable<stripe_shared::Rule>>, /// A human-readable description of the outcome type and reason, designed for you (the recipient of the payment), not your customer. pub seller_message: Option<String>, /// Possible values are `authorized`, `manual_review`, `issuer_declined`, `blocked`, and `invalid`. /// See [understanding declines](https://stripe.com/docs/declines) and [Radar reviews](https://stripe.com/docs/radar/reviews) for details. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, } +#[cfg(feature = "min-ser")] +pub struct ChargeOutcomeBuilder { + network_status: Option<Option<String>>, + reason: Option<Option<String>>, + risk_level: Option<Option<String>>, + risk_score: Option<Option<i64>>, + rule: Option<Option<stripe_types::Expandable<stripe_shared::Rule>>>, + seller_message: Option<Option<String>>, + type_: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ChargeOutcome { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ChargeOutcome>, + builder: ChargeOutcomeBuilder, + } + + impl Visitor for Place<ChargeOutcome> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ChargeOutcomeBuilder::deser_default() })) + } + } + + impl MapBuilder for ChargeOutcomeBuilder { + type Out = ChargeOutcome; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "network_status" => Deserialize::begin(&mut self.network_status), + "reason" => Deserialize::begin(&mut self.reason), + "risk_level" => Deserialize::begin(&mut self.risk_level), + "risk_score" => Deserialize::begin(&mut self.risk_score), + "rule" => Deserialize::begin(&mut self.rule), + "seller_message" => Deserialize::begin(&mut self.seller_message), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + network_status: Deserialize::default(), + reason: Deserialize::default(), + risk_level: Deserialize::default(), + risk_score: Deserialize::default(), + rule: Deserialize::default(), + seller_message: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let network_status = self.network_status.take()?; + let reason = self.reason.take()?; + let risk_level = self.risk_level.take()?; + let risk_score = self.risk_score.take()?; + let rule = self.rule.take()?; + let seller_message = self.seller_message.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { network_status, reason, risk_level, risk_score, rule, seller_message, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ChargeOutcome { + type Builder = ChargeOutcomeBuilder; + } + + impl FromValueOpt for ChargeOutcome { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ChargeOutcomeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "network_status" => b.network_status = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "risk_level" => b.risk_level = Some(FromValueOpt::from_value(v)?), + "risk_score" => b.risk_score = Some(FromValueOpt::from_value(v)?), + "rule" => b.rule = Some(FromValueOpt::from_value(v)?), + "seller_message" => b.seller_message = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/charge_transfer_data.rs b/generated/stripe_shared/src/charge_transfer_data.rs index 32f702920..3f751b149 100644 --- a/generated/stripe_shared/src/charge_transfer_data.rs +++ b/generated/stripe_shared/src/charge_transfer_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ChargeTransferData { /// The amount transferred to the destination account, if specified. /// By default, the entire charge amount is transferred to the destination account. @@ -6,3 +8,93 @@ pub struct ChargeTransferData { /// ID of an existing, connected Stripe account to transfer funds to if `transfer_data` was specified in the charge request. pub destination: stripe_types::Expandable<stripe_shared::Account>, } +#[cfg(feature = "min-ser")] +pub struct ChargeTransferDataBuilder { + amount: Option<Option<i64>>, + destination: Option<stripe_types::Expandable<stripe_shared::Account>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ChargeTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ChargeTransferData>, + builder: ChargeTransferDataBuilder, + } + + impl Visitor for Place<ChargeTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ChargeTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for ChargeTransferDataBuilder { + type Out = ChargeTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "destination" => Deserialize::begin(&mut self.destination), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let destination = self.destination.take()?; + + Some(Self::Out { amount, destination }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ChargeTransferData { + type Builder = ChargeTransferDataBuilder; + } + + impl FromValueOpt for ChargeTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ChargeTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/checkout_session_item.rs b/generated/stripe_shared/src/checkout_session_item.rs index 164d7965a..85f3dda9c 100644 --- a/generated/stripe_shared/src/checkout_session_item.rs +++ b/generated/stripe_shared/src/checkout_session_item.rs @@ -1,5 +1,7 @@ /// A line item. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CheckoutSessionItem { /// Total discount amount applied. If no discounts were applied, defaults to 0. pub amount_discount: i64, @@ -17,7 +19,6 @@ pub struct CheckoutSessionItem { /// Defaults to product name. pub description: String, /// The discounts applied to the line item. - #[serde(skip_serializing_if = "Option::is_none")] pub discounts: Option<Vec<stripe_shared::LineItemsDiscountAmount>>, /// Unique identifier for the object. pub id: stripe_shared::CheckoutSessionItemId, @@ -26,9 +27,146 @@ pub struct CheckoutSessionItem { /// The quantity of products being purchased. pub quantity: Option<u64>, /// The taxes applied to the line item. - #[serde(skip_serializing_if = "Option::is_none")] pub taxes: Option<Vec<stripe_shared::LineItemsTaxAmount>>, } +#[cfg(feature = "min-ser")] +pub struct CheckoutSessionItemBuilder { + amount_discount: Option<i64>, + amount_subtotal: Option<i64>, + amount_tax: Option<i64>, + amount_total: Option<i64>, + currency: Option<stripe_types::Currency>, + description: Option<String>, + discounts: Option<Option<Vec<stripe_shared::LineItemsDiscountAmount>>>, + id: Option<stripe_shared::CheckoutSessionItemId>, + price: Option<Option<stripe_shared::Price>>, + quantity: Option<Option<u64>>, + taxes: Option<Option<Vec<stripe_shared::LineItemsTaxAmount>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutSessionItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CheckoutSessionItem>, + builder: CheckoutSessionItemBuilder, + } + + impl Visitor for Place<CheckoutSessionItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CheckoutSessionItemBuilder::deser_default() })) + } + } + + impl MapBuilder for CheckoutSessionItemBuilder { + type Out = CheckoutSessionItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_discount" => Deserialize::begin(&mut self.amount_discount), + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "discounts" => Deserialize::begin(&mut self.discounts), + "id" => Deserialize::begin(&mut self.id), + "price" => Deserialize::begin(&mut self.price), + "quantity" => Deserialize::begin(&mut self.quantity), + "taxes" => Deserialize::begin(&mut self.taxes), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_discount: Deserialize::default(), + amount_subtotal: Deserialize::default(), + amount_tax: Deserialize::default(), + amount_total: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + discounts: Deserialize::default(), + id: Deserialize::default(), + price: Deserialize::default(), + quantity: Deserialize::default(), + taxes: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_discount = self.amount_discount.take()?; + let amount_subtotal = self.amount_subtotal.take()?; + let amount_tax = self.amount_tax.take()?; + let amount_total = self.amount_total.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let discounts = self.discounts.take()?; + let id = self.id.take()?; + let price = self.price.take()?; + let quantity = self.quantity.take()?; + let taxes = self.taxes.take()?; + + Some(Self::Out { amount_discount, amount_subtotal, amount_tax, amount_total, currency, description, discounts, id, price, quantity, taxes }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutSessionItem { + type Builder = CheckoutSessionItemBuilder; + } + + impl FromValueOpt for CheckoutSessionItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutSessionItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_discount" => b.amount_discount = Some(FromValueOpt::from_value(v)?), + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "price" => b.price = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "taxes" => b.taxes = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for CheckoutSessionItem { type Id = stripe_shared::CheckoutSessionItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/connect_account_reference.rs b/generated/stripe_shared/src/connect_account_reference.rs deleted file mode 100644 index 672d07b2c..000000000 --- a/generated/stripe_shared/src/connect_account_reference.rs +++ /dev/null @@ -1,63 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ConnectAccountReference { - /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<stripe_types::Expandable<stripe_shared::Account>>, - /// Type of the account referenced. - #[serde(rename = "type")] - pub type_: ConnectAccountReferenceType, -} -/// Type of the account referenced. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ConnectAccountReferenceType { - Account, - Self_, -} -impl ConnectAccountReferenceType { - pub fn as_str(self) -> &'static str { - use ConnectAccountReferenceType::*; - match self { - Account => "account", - Self_ => "self", - } - } -} - -impl std::str::FromStr for ConnectAccountReferenceType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ConnectAccountReferenceType::*; - match s { - "account" => Ok(Account), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for ConnectAccountReferenceType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ConnectAccountReferenceType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ConnectAccountReferenceType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for ConnectAccountReferenceType { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ConnectAccountReferenceType")) - } -} diff --git a/generated/stripe_shared/src/connect_collection_transfer.rs b/generated/stripe_shared/src/connect_collection_transfer.rs index 9aafd6e1b..20a2a5aad 100644 --- a/generated/stripe_shared/src/connect_collection_transfer.rs +++ b/generated/stripe_shared/src/connect_collection_transfer.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ConnectCollectionTransfer { /// Amount transferred, in cents (or local equivalent). pub amount: i64, @@ -12,6 +14,108 @@ pub struct ConnectCollectionTransfer { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, } +#[cfg(feature = "min-ser")] +pub struct ConnectCollectionTransferBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, + destination: Option<stripe_types::Expandable<stripe_shared::Account>>, + id: Option<stripe_shared::ConnectCollectionTransferId>, + livemode: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectCollectionTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ConnectCollectionTransfer>, + builder: ConnectCollectionTransferBuilder, + } + + impl Visitor for Place<ConnectCollectionTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ConnectCollectionTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for ConnectCollectionTransferBuilder { + type Out = ConnectCollectionTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "destination" => Deserialize::begin(&mut self.destination), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default(), destination: Deserialize::default(), id: Deserialize::default(), livemode: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let destination = self.destination.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + + Some(Self::Out { amount, currency, destination, id, livemode }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ConnectCollectionTransfer { + type Builder = ConnectCollectionTransferBuilder; + } + + impl FromValueOpt for ConnectCollectionTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectCollectionTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ConnectCollectionTransfer { type Id = stripe_shared::ConnectCollectionTransferId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/coupon.rs b/generated/stripe_shared/src/coupon.rs index bde2892a3..bda028252 100644 --- a/generated/stripe_shared/src/coupon.rs +++ b/generated/stripe_shared/src/coupon.rs @@ -5,11 +5,12 @@ /// Coupons do not work with conventional one-off [charges](https://stripe.com/docs/api#create_charge) or [payment intents](https://stripe.com/docs/api/payment_intents). /// /// For more details see <<https://stripe.com/docs/api/coupons/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Coupon { /// Amount (in the `currency` specified) that will be taken off the subtotal of any invoices for this customer. pub amount_off: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub applies_to: Option<stripe_shared::CouponAppliesTo>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -17,10 +18,7 @@ pub struct Coupon { pub currency: Option<stripe_types::Currency>, /// Coupons defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). - #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - std::collections::HashMap<stripe_types::Currency, stripe_shared::CouponCurrencyOption>, - >, + pub currency_options: Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::CouponCurrencyOption>>, /// One of `forever`, `once`, and `repeating`. /// Describes how long a customer who applies this coupon will get the discount. pub duration: stripe_shared::CouponDuration, @@ -48,6 +46,186 @@ pub struct Coupon { /// Taking account of the above properties, whether this coupon can still be applied to a customer. pub valid: bool, } +#[cfg(feature = "min-ser")] +pub struct CouponBuilder { + amount_off: Option<Option<i64>>, + applies_to: Option<Option<stripe_shared::CouponAppliesTo>>, + created: Option<stripe_types::Timestamp>, + currency: Option<Option<stripe_types::Currency>>, + currency_options: Option<Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::CouponCurrencyOption>>>, + duration: Option<stripe_shared::CouponDuration>, + duration_in_months: Option<Option<i64>>, + id: Option<stripe_shared::CouponId>, + livemode: Option<bool>, + max_redemptions: Option<Option<i64>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + name: Option<Option<String>>, + percent_off: Option<Option<f64>>, + redeem_by: Option<Option<stripe_types::Timestamp>>, + times_redeemed: Option<i64>, + valid: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Coupon { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Coupon>, + builder: CouponBuilder, + } + + impl Visitor for Place<Coupon> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CouponBuilder::deser_default() })) + } + } + + impl MapBuilder for CouponBuilder { + type Out = Coupon; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_off" => Deserialize::begin(&mut self.amount_off), + "applies_to" => Deserialize::begin(&mut self.applies_to), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "currency_options" => Deserialize::begin(&mut self.currency_options), + "duration" => Deserialize::begin(&mut self.duration), + "duration_in_months" => Deserialize::begin(&mut self.duration_in_months), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "max_redemptions" => Deserialize::begin(&mut self.max_redemptions), + "metadata" => Deserialize::begin(&mut self.metadata), + "name" => Deserialize::begin(&mut self.name), + "percent_off" => Deserialize::begin(&mut self.percent_off), + "redeem_by" => Deserialize::begin(&mut self.redeem_by), + "times_redeemed" => Deserialize::begin(&mut self.times_redeemed), + "valid" => Deserialize::begin(&mut self.valid), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_off: Deserialize::default(), + applies_to: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + currency_options: Deserialize::default(), + duration: Deserialize::default(), + duration_in_months: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + max_redemptions: Deserialize::default(), + metadata: Deserialize::default(), + name: Deserialize::default(), + percent_off: Deserialize::default(), + redeem_by: Deserialize::default(), + times_redeemed: Deserialize::default(), + valid: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_off = self.amount_off.take()?; + let applies_to = self.applies_to.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let currency_options = self.currency_options.take()?; + let duration = self.duration.take()?; + let duration_in_months = self.duration_in_months.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let max_redemptions = self.max_redemptions.take()?; + let metadata = self.metadata.take()?; + let name = self.name.take()?; + let percent_off = self.percent_off.take()?; + let redeem_by = self.redeem_by.take()?; + let times_redeemed = self.times_redeemed.take()?; + let valid = self.valid.take()?; + + Some(Self::Out { + amount_off, + applies_to, + created, + currency, + currency_options, + duration, + duration_in_months, + id, + livemode, + max_redemptions, + metadata, + name, + percent_off, + redeem_by, + times_redeemed, + valid, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Coupon { + type Builder = CouponBuilder; + } + + impl FromValueOpt for Coupon { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CouponBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_off" => b.amount_off = Some(FromValueOpt::from_value(v)?), + "applies_to" => b.applies_to = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "currency_options" => b.currency_options = Some(FromValueOpt::from_value(v)?), + "duration" => b.duration = Some(FromValueOpt::from_value(v)?), + "duration_in_months" => b.duration_in_months = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "max_redemptions" => b.max_redemptions = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "percent_off" => b.percent_off = Some(FromValueOpt::from_value(v)?), + "redeem_by" => b.redeem_by = Some(FromValueOpt::from_value(v)?), + "times_redeemed" => b.times_redeemed = Some(FromValueOpt::from_value(v)?), + "valid" => b.valid = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Coupon { type Id = stripe_shared::CouponId; fn id(&self) -> &Self::Id { @@ -110,3 +288,21 @@ impl<'de> serde::Deserialize<'de> for CouponDuration { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CouponDuration")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CouponDuration { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CouponDuration> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CouponDuration::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CouponDuration); diff --git a/generated/stripe_shared/src/coupon_applies_to.rs b/generated/stripe_shared/src/coupon_applies_to.rs index ca45f409b..25b15a657 100644 --- a/generated/stripe_shared/src/coupon_applies_to.rs +++ b/generated/stripe_shared/src/coupon_applies_to.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CouponAppliesTo { /// A list of product IDs this coupon applies to pub products: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct CouponAppliesToBuilder { + products: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CouponAppliesTo { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CouponAppliesTo>, + builder: CouponAppliesToBuilder, + } + + impl Visitor for Place<CouponAppliesTo> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CouponAppliesToBuilder::deser_default() })) + } + } + + impl MapBuilder for CouponAppliesToBuilder { + type Out = CouponAppliesTo; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "products" => Deserialize::begin(&mut self.products), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { products: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let products = self.products.take()?; + + Some(Self::Out { products }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CouponAppliesTo { + type Builder = CouponAppliesToBuilder; + } + + impl FromValueOpt for CouponAppliesTo { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CouponAppliesToBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "products" => b.products = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/coupon_currency_option.rs b/generated/stripe_shared/src/coupon_currency_option.rs index 4e1881dbc..3c50b04e5 100644 --- a/generated/stripe_shared/src/coupon_currency_option.rs +++ b/generated/stripe_shared/src/coupon_currency_option.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CouponCurrencyOption { /// Amount (in the `currency` specified) that will be taken off the subtotal of any invoices for this customer. pub amount_off: i64, } +#[cfg(feature = "min-ser")] +pub struct CouponCurrencyOptionBuilder { + amount_off: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CouponCurrencyOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CouponCurrencyOption>, + builder: CouponCurrencyOptionBuilder, + } + + impl Visitor for Place<CouponCurrencyOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CouponCurrencyOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for CouponCurrencyOptionBuilder { + type Out = CouponCurrencyOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_off" => Deserialize::begin(&mut self.amount_off), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_off: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_off = self.amount_off.take()?; + + Some(Self::Out { amount_off }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CouponCurrencyOption { + type Builder = CouponCurrencyOptionBuilder; + } + + impl FromValueOpt for CouponCurrencyOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CouponCurrencyOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_off" => b.amount_off = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/credit_note.rs b/generated/stripe_shared/src/credit_note.rs index a24ccb78f..64bcecf13 100644 --- a/generated/stripe_shared/src/credit_note.rs +++ b/generated/stripe_shared/src/credit_note.rs @@ -3,7 +3,9 @@ /// Related guide: [Credit notes](https://stripe.com/docs/billing/invoices/credit-notes) /// /// For more details see <<https://stripe.com/docs/api/credit_notes/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CreditNote { /// The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax. pub amount: i64, @@ -17,8 +19,7 @@ pub struct CreditNote { /// ID of the customer. pub customer: stripe_types::Expandable<stripe_shared::Customer>, /// Customer balance transaction related to this credit note. - pub customer_balance_transaction: - Option<stripe_types::Expandable<stripe_shared::CustomerBalanceTransaction>>, + pub customer_balance_transaction: Option<stripe_types::Expandable<stripe_shared::CustomerBalanceTransaction>>, /// The integer amount in cents (or local equivalent) representing the total amount of discount that was credited. pub discount_amount: i64, /// The aggregate amounts calculated per discount for all line items. @@ -68,11 +69,269 @@ pub struct CreditNote { /// Type of this credit note, one of `pre_payment` or `post_payment`. /// A `pre_payment` credit note means it was issued when the invoice was open. /// A `post_payment` credit note means it was issued when the invoice was paid. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreditNoteType, /// The time that the credit note was voided. pub voided_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct CreditNoteBuilder { + amount: Option<i64>, + amount_shipping: Option<i64>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, + customer_balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::CustomerBalanceTransaction>>>, + discount_amount: Option<i64>, + discount_amounts: Option<Vec<stripe_shared::DiscountsResourceDiscountAmount>>, + effective_at: Option<Option<stripe_types::Timestamp>>, + id: Option<stripe_shared::CreditNoteId>, + invoice: Option<stripe_types::Expandable<stripe_shared::Invoice>>, + lines: Option<stripe_types::List<stripe_shared::CreditNoteLineItem>>, + livemode: Option<bool>, + memo: Option<Option<String>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + number: Option<String>, + out_of_band_amount: Option<Option<i64>>, + pdf: Option<String>, + reason: Option<Option<stripe_shared::CreditNoteReason>>, + refund: Option<Option<stripe_types::Expandable<stripe_shared::Refund>>>, + shipping_cost: Option<Option<stripe_shared::InvoicesShippingCost>>, + status: Option<CreditNoteStatus>, + subtotal: Option<i64>, + subtotal_excluding_tax: Option<Option<i64>>, + tax_amounts: Option<Vec<stripe_shared::CreditNoteTaxAmount>>, + total: Option<i64>, + total_excluding_tax: Option<Option<i64>>, + type_: Option<CreditNoteType>, + voided_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CreditNote { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CreditNote>, + builder: CreditNoteBuilder, + } + + impl Visitor for Place<CreditNote> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CreditNoteBuilder::deser_default() })) + } + } + + impl MapBuilder for CreditNoteBuilder { + type Out = CreditNote; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_shipping" => Deserialize::begin(&mut self.amount_shipping), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "customer_balance_transaction" => Deserialize::begin(&mut self.customer_balance_transaction), + "discount_amount" => Deserialize::begin(&mut self.discount_amount), + "discount_amounts" => Deserialize::begin(&mut self.discount_amounts), + "effective_at" => Deserialize::begin(&mut self.effective_at), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "lines" => Deserialize::begin(&mut self.lines), + "livemode" => Deserialize::begin(&mut self.livemode), + "memo" => Deserialize::begin(&mut self.memo), + "metadata" => Deserialize::begin(&mut self.metadata), + "number" => Deserialize::begin(&mut self.number), + "out_of_band_amount" => Deserialize::begin(&mut self.out_of_band_amount), + "pdf" => Deserialize::begin(&mut self.pdf), + "reason" => Deserialize::begin(&mut self.reason), + "refund" => Deserialize::begin(&mut self.refund), + "shipping_cost" => Deserialize::begin(&mut self.shipping_cost), + "status" => Deserialize::begin(&mut self.status), + "subtotal" => Deserialize::begin(&mut self.subtotal), + "subtotal_excluding_tax" => Deserialize::begin(&mut self.subtotal_excluding_tax), + "tax_amounts" => Deserialize::begin(&mut self.tax_amounts), + "total" => Deserialize::begin(&mut self.total), + "total_excluding_tax" => Deserialize::begin(&mut self.total_excluding_tax), + "type" => Deserialize::begin(&mut self.type_), + "voided_at" => Deserialize::begin(&mut self.voided_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_shipping: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + customer_balance_transaction: Deserialize::default(), + discount_amount: Deserialize::default(), + discount_amounts: Deserialize::default(), + effective_at: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + lines: Deserialize::default(), + livemode: Deserialize::default(), + memo: Deserialize::default(), + metadata: Deserialize::default(), + number: Deserialize::default(), + out_of_band_amount: Deserialize::default(), + pdf: Deserialize::default(), + reason: Deserialize::default(), + refund: Deserialize::default(), + shipping_cost: Deserialize::default(), + status: Deserialize::default(), + subtotal: Deserialize::default(), + subtotal_excluding_tax: Deserialize::default(), + tax_amounts: Deserialize::default(), + total: Deserialize::default(), + total_excluding_tax: Deserialize::default(), + type_: Deserialize::default(), + voided_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_shipping = self.amount_shipping.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let customer_balance_transaction = self.customer_balance_transaction.take()?; + let discount_amount = self.discount_amount.take()?; + let discount_amounts = self.discount_amounts.take()?; + let effective_at = self.effective_at.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let lines = self.lines.take()?; + let livemode = self.livemode.take()?; + let memo = self.memo.take()?; + let metadata = self.metadata.take()?; + let number = self.number.take()?; + let out_of_band_amount = self.out_of_band_amount.take()?; + let pdf = self.pdf.take()?; + let reason = self.reason.take()?; + let refund = self.refund.take()?; + let shipping_cost = self.shipping_cost.take()?; + let status = self.status.take()?; + let subtotal = self.subtotal.take()?; + let subtotal_excluding_tax = self.subtotal_excluding_tax.take()?; + let tax_amounts = self.tax_amounts.take()?; + let total = self.total.take()?; + let total_excluding_tax = self.total_excluding_tax.take()?; + let type_ = self.type_.take()?; + let voided_at = self.voided_at.take()?; + + Some(Self::Out { + amount, + amount_shipping, + created, + currency, + customer, + customer_balance_transaction, + discount_amount, + discount_amounts, + effective_at, + id, + invoice, + lines, + livemode, + memo, + metadata, + number, + out_of_band_amount, + pdf, + reason, + refund, + shipping_cost, + status, + subtotal, + subtotal_excluding_tax, + tax_amounts, + total, + total_excluding_tax, + type_, + voided_at, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CreditNote { + type Builder = CreditNoteBuilder; + } + + impl FromValueOpt for CreditNote { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CreditNoteBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_shipping" => b.amount_shipping = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "customer_balance_transaction" => b.customer_balance_transaction = Some(FromValueOpt::from_value(v)?), + "discount_amount" => b.discount_amount = Some(FromValueOpt::from_value(v)?), + "discount_amounts" => b.discount_amounts = Some(FromValueOpt::from_value(v)?), + "effective_at" => b.effective_at = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "lines" => b.lines = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "memo" => b.memo = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "number" => b.number = Some(FromValueOpt::from_value(v)?), + "out_of_band_amount" => b.out_of_band_amount = Some(FromValueOpt::from_value(v)?), + "pdf" => b.pdf = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "refund" => b.refund = Some(FromValueOpt::from_value(v)?), + "shipping_cost" => b.shipping_cost = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "subtotal" => b.subtotal = Some(FromValueOpt::from_value(v)?), + "subtotal_excluding_tax" => b.subtotal_excluding_tax = Some(FromValueOpt::from_value(v)?), + "tax_amounts" => b.tax_amounts = Some(FromValueOpt::from_value(v)?), + "total" => b.total = Some(FromValueOpt::from_value(v)?), + "total_excluding_tax" => b.total_excluding_tax = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "voided_at" => b.voided_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Status of this credit note, one of `issued` or `void`. /// Learn more about [voiding credit notes](https://stripe.com/docs/billing/invoices/credit-notes#voiding). #[derive(Copy, Clone, Eq, PartialEq)] @@ -124,10 +383,27 @@ impl<'de> serde::Deserialize<'de> for CreditNoteStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CreditNoteStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CreditNoteStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CreditNoteStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CreditNoteStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CreditNoteStatus); /// Type of this credit note, one of `pre_payment` or `post_payment`. /// A `pre_payment` credit note means it was issued when the invoice was open. /// A `post_payment` credit note means it was issued when the invoice was paid. @@ -183,6 +459,24 @@ impl<'de> serde::Deserialize<'de> for CreditNoteType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CreditNoteType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CreditNoteType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CreditNoteType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CreditNoteType); impl stripe_types::Object for CreditNote { type Id = stripe_shared::CreditNoteId; fn id(&self) -> &Self::Id { @@ -245,7 +539,24 @@ impl<'de> serde::Deserialize<'de> for CreditNoteReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CreditNoteReason")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CreditNoteReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CreditNoteReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CreditNoteReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CreditNoteReason); diff --git a/generated/stripe_shared/src/credit_note_line_item.rs b/generated/stripe_shared/src/credit_note_line_item.rs index b35f9e106..79efa23e3 100644 --- a/generated/stripe_shared/src/credit_note_line_item.rs +++ b/generated/stripe_shared/src/credit_note_line_item.rs @@ -1,7 +1,9 @@ /// The credit note line item object /// /// For more details see <<https://stripe.com/docs/api/credit_notes/line_item>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CreditNoteLineItem { /// The integer amount in cents (or local equivalent) representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts. pub amount: i64, @@ -16,7 +18,6 @@ pub struct CreditNoteLineItem { /// Unique identifier for the object. pub id: stripe_shared::CreditNoteLineItemId, /// ID of the invoice line item being credited - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_line_item: Option<String>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, @@ -28,7 +29,7 @@ pub struct CreditNoteLineItem { pub tax_rates: Vec<stripe_shared::TaxRate>, /// The type of the credit note line item, one of `invoice_line_item` or `custom_line_item`. /// When the type is `invoice_line_item` there is an additional `invoice_line_item` property on the resource the value of which is the id of the credited line item on the invoice. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreditNoteLineItemType, /// The cost of each unit of product being credited. pub unit_amount: Option<i64>, @@ -37,6 +38,180 @@ pub struct CreditNoteLineItem { /// The amount in cents (or local equivalent) representing the unit amount being credited for this line item, excluding all tax and discounts. pub unit_amount_excluding_tax: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CreditNoteLineItemBuilder { + amount: Option<i64>, + amount_excluding_tax: Option<Option<i64>>, + description: Option<Option<String>>, + discount_amount: Option<i64>, + discount_amounts: Option<Vec<stripe_shared::DiscountsResourceDiscountAmount>>, + id: Option<stripe_shared::CreditNoteLineItemId>, + invoice_line_item: Option<Option<String>>, + livemode: Option<bool>, + quantity: Option<Option<u64>>, + tax_amounts: Option<Vec<stripe_shared::CreditNoteTaxAmount>>, + tax_rates: Option<Vec<stripe_shared::TaxRate>>, + type_: Option<CreditNoteLineItemType>, + unit_amount: Option<Option<i64>>, + unit_amount_decimal: Option<Option<String>>, + unit_amount_excluding_tax: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CreditNoteLineItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CreditNoteLineItem>, + builder: CreditNoteLineItemBuilder, + } + + impl Visitor for Place<CreditNoteLineItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CreditNoteLineItemBuilder::deser_default() })) + } + } + + impl MapBuilder for CreditNoteLineItemBuilder { + type Out = CreditNoteLineItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_excluding_tax" => Deserialize::begin(&mut self.amount_excluding_tax), + "description" => Deserialize::begin(&mut self.description), + "discount_amount" => Deserialize::begin(&mut self.discount_amount), + "discount_amounts" => Deserialize::begin(&mut self.discount_amounts), + "id" => Deserialize::begin(&mut self.id), + "invoice_line_item" => Deserialize::begin(&mut self.invoice_line_item), + "livemode" => Deserialize::begin(&mut self.livemode), + "quantity" => Deserialize::begin(&mut self.quantity), + "tax_amounts" => Deserialize::begin(&mut self.tax_amounts), + "tax_rates" => Deserialize::begin(&mut self.tax_rates), + "type" => Deserialize::begin(&mut self.type_), + "unit_amount" => Deserialize::begin(&mut self.unit_amount), + "unit_amount_decimal" => Deserialize::begin(&mut self.unit_amount_decimal), + "unit_amount_excluding_tax" => Deserialize::begin(&mut self.unit_amount_excluding_tax), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_excluding_tax: Deserialize::default(), + description: Deserialize::default(), + discount_amount: Deserialize::default(), + discount_amounts: Deserialize::default(), + id: Deserialize::default(), + invoice_line_item: Deserialize::default(), + livemode: Deserialize::default(), + quantity: Deserialize::default(), + tax_amounts: Deserialize::default(), + tax_rates: Deserialize::default(), + type_: Deserialize::default(), + unit_amount: Deserialize::default(), + unit_amount_decimal: Deserialize::default(), + unit_amount_excluding_tax: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_excluding_tax = self.amount_excluding_tax.take()?; + let description = self.description.take()?; + let discount_amount = self.discount_amount.take()?; + let discount_amounts = self.discount_amounts.take()?; + let id = self.id.take()?; + let invoice_line_item = self.invoice_line_item.take()?; + let livemode = self.livemode.take()?; + let quantity = self.quantity.take()?; + let tax_amounts = self.tax_amounts.take()?; + let tax_rates = self.tax_rates.take()?; + let type_ = self.type_.take()?; + let unit_amount = self.unit_amount.take()?; + let unit_amount_decimal = self.unit_amount_decimal.take()?; + let unit_amount_excluding_tax = self.unit_amount_excluding_tax.take()?; + + Some(Self::Out { + amount, + amount_excluding_tax, + description, + discount_amount, + discount_amounts, + id, + invoice_line_item, + livemode, + quantity, + tax_amounts, + tax_rates, + type_, + unit_amount, + unit_amount_decimal, + unit_amount_excluding_tax, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CreditNoteLineItem { + type Builder = CreditNoteLineItemBuilder; + } + + impl FromValueOpt for CreditNoteLineItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CreditNoteLineItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_excluding_tax" => b.amount_excluding_tax = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discount_amount" => b.discount_amount = Some(FromValueOpt::from_value(v)?), + "discount_amounts" => b.discount_amounts = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice_line_item" => b.invoice_line_item = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "tax_amounts" => b.tax_amounts = Some(FromValueOpt::from_value(v)?), + "tax_rates" => b.tax_rates = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "unit_amount" => b.unit_amount = Some(FromValueOpt::from_value(v)?), + "unit_amount_decimal" => b.unit_amount_decimal = Some(FromValueOpt::from_value(v)?), + "unit_amount_excluding_tax" => b.unit_amount_excluding_tax = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the credit note line item, one of `invoice_line_item` or `custom_line_item`. /// When the type is `invoice_line_item` there is an additional `invoice_line_item` property on the resource the value of which is the id of the credited line item on the invoice. #[derive(Copy, Clone, Eq, PartialEq)] @@ -88,10 +263,27 @@ impl<'de> serde::Deserialize<'de> for CreditNoteLineItemType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CreditNoteLineItemType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CreditNoteLineItemType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CreditNoteLineItemType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CreditNoteLineItemType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteLineItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CreditNoteLineItemType); impl stripe_types::Object for CreditNoteLineItem { type Id = stripe_shared::CreditNoteLineItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/credit_note_tax_amount.rs b/generated/stripe_shared/src/credit_note_tax_amount.rs index 6a78ae397..567bb033e 100644 --- a/generated/stripe_shared/src/credit_note_tax_amount.rs +++ b/generated/stripe_shared/src/credit_note_tax_amount.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CreditNoteTaxAmount { /// The amount, in cents (or local equivalent), of the tax. pub amount: i64, @@ -12,6 +14,114 @@ pub struct CreditNoteTaxAmount { /// The amount on which tax is calculated, in cents (or local equivalent). pub taxable_amount: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct CreditNoteTaxAmountBuilder { + amount: Option<i64>, + inclusive: Option<bool>, + tax_rate: Option<stripe_types::Expandable<stripe_shared::TaxRate>>, + taxability_reason: Option<Option<CreditNoteTaxAmountTaxabilityReason>>, + taxable_amount: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CreditNoteTaxAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CreditNoteTaxAmount>, + builder: CreditNoteTaxAmountBuilder, + } + + impl Visitor for Place<CreditNoteTaxAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CreditNoteTaxAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for CreditNoteTaxAmountBuilder { + type Out = CreditNoteTaxAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "inclusive" => Deserialize::begin(&mut self.inclusive), + "tax_rate" => Deserialize::begin(&mut self.tax_rate), + "taxability_reason" => Deserialize::begin(&mut self.taxability_reason), + "taxable_amount" => Deserialize::begin(&mut self.taxable_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + inclusive: Deserialize::default(), + tax_rate: Deserialize::default(), + taxability_reason: Deserialize::default(), + taxable_amount: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let inclusive = self.inclusive.take()?; + let tax_rate = self.tax_rate.take()?; + let taxability_reason = self.taxability_reason.take()?; + let taxable_amount = self.taxable_amount.take()?; + + Some(Self::Out { amount, inclusive, tax_rate, taxability_reason, taxable_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CreditNoteTaxAmount { + type Builder = CreditNoteTaxAmountBuilder; + } + + impl FromValueOpt for CreditNoteTaxAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CreditNoteTaxAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "inclusive" => b.inclusive = Some(FromValueOpt::from_value(v)?), + "tax_rate" => b.tax_rate = Some(FromValueOpt::from_value(v)?), + "taxability_reason" => b.taxability_reason = Some(FromValueOpt::from_value(v)?), + "taxable_amount" => b.taxable_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reasoning behind this tax, for example, if the product is tax exempt. /// The possible values for this field may be extended as new tax rules are supported. #[derive(Copy, Clone, Eq, PartialEq)] @@ -106,6 +216,24 @@ impl<'de> serde::Deserialize<'de> for CreditNoteTaxAmountTaxabilityReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(CreditNoteTaxAmountTaxabilityReason::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CreditNoteTaxAmountTaxabilityReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CreditNoteTaxAmountTaxabilityReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteTaxAmountTaxabilityReason::from_str(s).unwrap_or(CreditNoteTaxAmountTaxabilityReason::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CreditNoteTaxAmountTaxabilityReason); diff --git a/generated/stripe_shared/src/currency_option.rs b/generated/stripe_shared/src/currency_option.rs index cee2cd55b..50b0e39dc 100644 --- a/generated/stripe_shared/src/currency_option.rs +++ b/generated/stripe_shared/src/currency_option.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CurrencyOption { /// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. pub custom_unit_amount: Option<stripe_shared::CustomUnitAmount>, @@ -10,7 +12,6 @@ pub struct CurrencyOption { /// Each element represents a pricing tier. /// This parameter requires `billing_scheme` to be set to `tiered`. /// See also the documentation for `billing_scheme`. - #[serde(skip_serializing_if = "Option::is_none")] pub tiers: Option<Vec<stripe_shared::PriceTier>>, /// The unit amount in cents (or local equivalent) to be charged, represented as a whole integer if possible. /// Only set if `billing_scheme=per_unit`. @@ -19,6 +20,114 @@ pub struct CurrencyOption { /// Only set if `billing_scheme=per_unit`. pub unit_amount_decimal: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CurrencyOptionBuilder { + custom_unit_amount: Option<Option<stripe_shared::CustomUnitAmount>>, + tax_behavior: Option<Option<CurrencyOptionTaxBehavior>>, + tiers: Option<Option<Vec<stripe_shared::PriceTier>>>, + unit_amount: Option<Option<i64>>, + unit_amount_decimal: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CurrencyOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CurrencyOption>, + builder: CurrencyOptionBuilder, + } + + impl Visitor for Place<CurrencyOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CurrencyOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for CurrencyOptionBuilder { + type Out = CurrencyOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom_unit_amount" => Deserialize::begin(&mut self.custom_unit_amount), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tiers" => Deserialize::begin(&mut self.tiers), + "unit_amount" => Deserialize::begin(&mut self.unit_amount), + "unit_amount_decimal" => Deserialize::begin(&mut self.unit_amount_decimal), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + custom_unit_amount: Deserialize::default(), + tax_behavior: Deserialize::default(), + tiers: Deserialize::default(), + unit_amount: Deserialize::default(), + unit_amount_decimal: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom_unit_amount = self.custom_unit_amount.take()?; + let tax_behavior = self.tax_behavior.take()?; + let tiers = self.tiers.take()?; + let unit_amount = self.unit_amount.take()?; + let unit_amount_decimal = self.unit_amount_decimal.take()?; + + Some(Self::Out { custom_unit_amount, tax_behavior, tiers, unit_amount, unit_amount_decimal }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CurrencyOption { + type Builder = CurrencyOptionBuilder; + } + + impl FromValueOpt for CurrencyOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CurrencyOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom_unit_amount" => b.custom_unit_amount = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tiers" => b.tiers = Some(FromValueOpt::from_value(v)?), + "unit_amount" => b.unit_amount = Some(FromValueOpt::from_value(v)?), + "unit_amount_decimal" => b.unit_amount_decimal = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. @@ -75,7 +184,24 @@ impl<'de> serde::Deserialize<'de> for CurrencyOptionTaxBehavior { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CurrencyOptionTaxBehavior")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CurrencyOptionTaxBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CurrencyOptionTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CurrencyOptionTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CurrencyOptionTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CurrencyOptionTaxBehavior); diff --git a/generated/stripe_shared/src/custom_unit_amount.rs b/generated/stripe_shared/src/custom_unit_amount.rs index 6fd2c00df..5c739b605 100644 --- a/generated/stripe_shared/src/custom_unit_amount.rs +++ b/generated/stripe_shared/src/custom_unit_amount.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomUnitAmount { /// The maximum unit amount the customer can specify for this item. pub maximum: Option<i64>, @@ -8,3 +10,97 @@ pub struct CustomUnitAmount { /// The starting unit amount which can be updated by the customer. pub preset: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct CustomUnitAmountBuilder { + maximum: Option<Option<i64>>, + minimum: Option<Option<i64>>, + preset: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomUnitAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomUnitAmount>, + builder: CustomUnitAmountBuilder, + } + + impl Visitor for Place<CustomUnitAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomUnitAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomUnitAmountBuilder { + type Out = CustomUnitAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "maximum" => Deserialize::begin(&mut self.maximum), + "minimum" => Deserialize::begin(&mut self.minimum), + "preset" => Deserialize::begin(&mut self.preset), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum: Deserialize::default(), minimum: Deserialize::default(), preset: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let maximum = self.maximum.take()?; + let minimum = self.minimum.take()?; + let preset = self.preset.take()?; + + Some(Self::Out { maximum, minimum, preset }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomUnitAmount { + type Builder = CustomUnitAmountBuilder; + } + + impl FromValueOpt for CustomUnitAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomUnitAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "maximum" => b.maximum = Some(FromValueOpt::from_value(v)?), + "minimum" => b.minimum = Some(FromValueOpt::from_value(v)?), + "preset" => b.preset = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer.rs b/generated/stripe_shared/src/customer.rs index df33c84e2..7afc3d55d 100644 --- a/generated/stripe_shared/src/customer.rs +++ b/generated/stripe_shared/src/customer.rs @@ -4,10 +4,11 @@ /// Related guide: [Save a card during payment](https://stripe.com/docs/payments/save-during-payment) /// /// For more details see <<https://stripe.com/docs/api/customers/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Customer { /// The customer's address. - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<stripe_shared::Address>, /// The current balance, if any, that's stored on the customer. /// If negative, the customer has credit to apply to their next invoice. @@ -15,17 +16,14 @@ pub struct Customer { /// The balance only considers amounts that Stripe hasn't successfully applied to any invoice. /// It doesn't reflect unpaid invoices. /// This balance is only taken into account after invoices finalize. - #[serde(skip_serializing_if = "Option::is_none")] pub balance: Option<i64>, /// The current funds being held by Stripe on behalf of the customer. /// You can apply these funds towards payment intents when the source is "cash_balance". /// The `settings[reconciliation_mode]` field describes if these funds apply to these payment intents manually or automatically. - #[serde(skip_serializing_if = "Option::is_none")] pub cash_balance: Option<stripe_shared::CashBalance>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) the customer can be charged in for recurring billing purposes. - #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<stripe_types::Currency>, /// ID of the default payment source for the customer. /// @@ -39,12 +37,10 @@ pub struct Customer { /// /// If you care whether the customer has paid their most recent subscription invoice, use `subscription.status` instead. /// Paying or marking uncollectible any customer invoice regardless of whether it is the latest invoice for a subscription will always set this field to `false`. - #[serde(skip_serializing_if = "Option::is_none")] pub delinquent: Option<bool>, /// An arbitrary string attached to the object. Often useful for displaying to users. pub description: Option<String>, /// Describes the current discount active on the customer, if there is one. - #[serde(skip_serializing_if = "Option::is_none")] pub discount: Option<stripe_shared::Discount>, /// The customer's email address. pub email: Option<String>, @@ -56,52 +52,284 @@ pub struct Customer { /// These balances don't apply to unpaid invoices. /// They solely track amounts that Stripe hasn't successfully applied to any invoice. /// Stripe only applies a balance in a specific currency to an invoice after that invoice (which is in the same currency) finalizes. - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_credit_balance: Option<std::collections::HashMap<String, i64>>, /// The prefix for the customer used to generate unique invoice numbers. - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_prefix: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_settings: Option<stripe_shared::InvoiceSettingCustomerSetting>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. - #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<std::collections::HashMap<String, String>>, /// The customer's full name or business name. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, /// The suffix of the customer's next invoice number (for example, 0001). - #[serde(skip_serializing_if = "Option::is_none")] pub next_invoice_sequence: Option<i64>, /// The customer's phone number. - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option<String>, /// The customer's preferred locales (languages), ordered by preference. - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_locales: Option<Vec<String>>, /// Mailing and shipping address for the customer. Appears on invoices emailed to this customer. pub shipping: Option<stripe_shared::Shipping>, /// The customer's payment sources, if any. - #[serde(skip_serializing_if = "Option::is_none")] pub sources: Option<stripe_types::List<stripe_shared::PaymentSource>>, /// The customer's current subscriptions, if any. - #[serde(skip_serializing_if = "Option::is_none")] pub subscriptions: Option<stripe_types::List<stripe_shared::Subscription>>, - #[serde(skip_serializing_if = "Option::is_none")] pub tax: Option<stripe_shared::CustomerTax>, /// Describes the customer's tax exemption status, which is `none`, `exempt`, or `reverse`. /// When set to `reverse`, invoice and receipt PDFs include the following text: **"Reverse charge"**. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_exempt: Option<stripe_shared::CustomerTaxExempt>, /// The customer's tax IDs. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_ids: Option<stripe_types::List<stripe_shared::TaxId>>, /// ID of the test clock that this customer belongs to. - #[serde(skip_serializing_if = "Option::is_none")] pub test_clock: Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBuilder { + address: Option<Option<stripe_shared::Address>>, + balance: Option<Option<i64>>, + cash_balance: Option<Option<stripe_shared::CashBalance>>, + created: Option<stripe_types::Timestamp>, + currency: Option<Option<stripe_types::Currency>>, + default_source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>, + delinquent: Option<Option<bool>>, + description: Option<Option<String>>, + discount: Option<Option<stripe_shared::Discount>>, + email: Option<Option<String>>, + id: Option<stripe_shared::CustomerId>, + invoice_credit_balance: Option<Option<std::collections::HashMap<String, i64>>>, + invoice_prefix: Option<Option<String>>, + invoice_settings: Option<Option<stripe_shared::InvoiceSettingCustomerSetting>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + name: Option<Option<String>>, + next_invoice_sequence: Option<Option<i64>>, + phone: Option<Option<String>>, + preferred_locales: Option<Option<Vec<String>>>, + shipping: Option<Option<stripe_shared::Shipping>>, + sources: Option<Option<stripe_types::List<stripe_shared::PaymentSource>>>, + subscriptions: Option<Option<stripe_types::List<stripe_shared::Subscription>>>, + tax: Option<Option<stripe_shared::CustomerTax>>, + tax_exempt: Option<Option<stripe_shared::CustomerTaxExempt>>, + tax_ids: Option<Option<stripe_types::List<stripe_shared::TaxId>>>, + test_clock: Option<Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Customer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Customer>, + builder: CustomerBuilder, + } + + impl Visitor for Place<Customer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBuilder { + type Out = Customer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "balance" => Deserialize::begin(&mut self.balance), + "cash_balance" => Deserialize::begin(&mut self.cash_balance), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "default_source" => Deserialize::begin(&mut self.default_source), + "delinquent" => Deserialize::begin(&mut self.delinquent), + "description" => Deserialize::begin(&mut self.description), + "discount" => Deserialize::begin(&mut self.discount), + "email" => Deserialize::begin(&mut self.email), + "id" => Deserialize::begin(&mut self.id), + "invoice_credit_balance" => Deserialize::begin(&mut self.invoice_credit_balance), + "invoice_prefix" => Deserialize::begin(&mut self.invoice_prefix), + "invoice_settings" => Deserialize::begin(&mut self.invoice_settings), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "name" => Deserialize::begin(&mut self.name), + "next_invoice_sequence" => Deserialize::begin(&mut self.next_invoice_sequence), + "phone" => Deserialize::begin(&mut self.phone), + "preferred_locales" => Deserialize::begin(&mut self.preferred_locales), + "shipping" => Deserialize::begin(&mut self.shipping), + "sources" => Deserialize::begin(&mut self.sources), + "subscriptions" => Deserialize::begin(&mut self.subscriptions), + "tax" => Deserialize::begin(&mut self.tax), + "tax_exempt" => Deserialize::begin(&mut self.tax_exempt), + "tax_ids" => Deserialize::begin(&mut self.tax_ids), + "test_clock" => Deserialize::begin(&mut self.test_clock), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + balance: Deserialize::default(), + cash_balance: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + default_source: Deserialize::default(), + delinquent: Deserialize::default(), + description: Deserialize::default(), + discount: Deserialize::default(), + email: Deserialize::default(), + id: Deserialize::default(), + invoice_credit_balance: Deserialize::default(), + invoice_prefix: Deserialize::default(), + invoice_settings: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + name: Deserialize::default(), + next_invoice_sequence: Deserialize::default(), + phone: Deserialize::default(), + preferred_locales: Deserialize::default(), + shipping: Deserialize::default(), + sources: Deserialize::default(), + subscriptions: Deserialize::default(), + tax: Deserialize::default(), + tax_exempt: Deserialize::default(), + tax_ids: Deserialize::default(), + test_clock: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let balance = self.balance.take()?; + let cash_balance = self.cash_balance.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let default_source = self.default_source.take()?; + let delinquent = self.delinquent.take()?; + let description = self.description.take()?; + let discount = self.discount.take()?; + let email = self.email.take()?; + let id = self.id.take()?; + let invoice_credit_balance = self.invoice_credit_balance.take()?; + let invoice_prefix = self.invoice_prefix.take()?; + let invoice_settings = self.invoice_settings.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let name = self.name.take()?; + let next_invoice_sequence = self.next_invoice_sequence.take()?; + let phone = self.phone.take()?; + let preferred_locales = self.preferred_locales.take()?; + let shipping = self.shipping.take()?; + let sources = self.sources.take()?; + let subscriptions = self.subscriptions.take()?; + let tax = self.tax.take()?; + let tax_exempt = self.tax_exempt.take()?; + let tax_ids = self.tax_ids.take()?; + let test_clock = self.test_clock.take()?; + + Some(Self::Out { + address, + balance, + cash_balance, + created, + currency, + default_source, + delinquent, + description, + discount, + email, + id, + invoice_credit_balance, + invoice_prefix, + invoice_settings, + livemode, + metadata, + name, + next_invoice_sequence, + phone, + preferred_locales, + shipping, + sources, + subscriptions, + tax, + tax_exempt, + tax_ids, + test_clock, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Customer { + type Builder = CustomerBuilder; + } + + impl FromValueOpt for Customer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "balance" => b.balance = Some(FromValueOpt::from_value(v)?), + "cash_balance" => b.cash_balance = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "default_source" => b.default_source = Some(FromValueOpt::from_value(v)?), + "delinquent" => b.delinquent = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discount" => b.discount = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice_credit_balance" => b.invoice_credit_balance = Some(FromValueOpt::from_value(v)?), + "invoice_prefix" => b.invoice_prefix = Some(FromValueOpt::from_value(v)?), + "invoice_settings" => b.invoice_settings = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "next_invoice_sequence" => b.next_invoice_sequence = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + "preferred_locales" => b.preferred_locales = Some(FromValueOpt::from_value(v)?), + "shipping" => b.shipping = Some(FromValueOpt::from_value(v)?), + "sources" => b.sources = Some(FromValueOpt::from_value(v)?), + "subscriptions" => b.subscriptions = Some(FromValueOpt::from_value(v)?), + "tax" => b.tax = Some(FromValueOpt::from_value(v)?), + "tax_exempt" => b.tax_exempt = Some(FromValueOpt::from_value(v)?), + "tax_ids" => b.tax_ids = Some(FromValueOpt::from_value(v)?), + "test_clock" => b.test_clock = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Customer { type Id = stripe_shared::CustomerId; fn id(&self) -> &Self::Id { @@ -161,7 +389,24 @@ impl<'de> serde::Deserialize<'de> for CustomerTaxExempt { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CustomerTaxExempt")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerTaxExempt")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerTaxExempt { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerTaxExempt> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerTaxExempt::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerTaxExempt); diff --git a/generated/stripe_shared/src/customer_acceptance.rs b/generated/stripe_shared/src/customer_acceptance.rs index 237725fe6..7e34e0691 100644 --- a/generated/stripe_shared/src/customer_acceptance.rs +++ b/generated/stripe_shared/src/customer_acceptance.rs @@ -1,15 +1,113 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerAcceptance { /// The time that the customer accepts the mandate. pub accepted_at: Option<stripe_types::Timestamp>, - #[serde(skip_serializing_if = "Option::is_none")] pub offline: Option<stripe_shared::OfflineAcceptance>, - #[serde(skip_serializing_if = "Option::is_none")] pub online: Option<stripe_shared::OnlineAcceptance>, /// The mandate includes the type of customer acceptance information, such as: `online` or `offline`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CustomerAcceptanceType, } +#[cfg(feature = "min-ser")] +pub struct CustomerAcceptanceBuilder { + accepted_at: Option<Option<stripe_types::Timestamp>>, + offline: Option<Option<stripe_shared::OfflineAcceptance>>, + online: Option<Option<stripe_shared::OnlineAcceptance>>, + type_: Option<CustomerAcceptanceType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerAcceptance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerAcceptance>, + builder: CustomerAcceptanceBuilder, + } + + impl Visitor for Place<CustomerAcceptance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerAcceptanceBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerAcceptanceBuilder { + type Out = CustomerAcceptance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "accepted_at" => Deserialize::begin(&mut self.accepted_at), + "offline" => Deserialize::begin(&mut self.offline), + "online" => Deserialize::begin(&mut self.online), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { accepted_at: Deserialize::default(), offline: Deserialize::default(), online: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let accepted_at = self.accepted_at.take()?; + let offline = self.offline.take()?; + let online = self.online.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { accepted_at, offline, online, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerAcceptance { + type Builder = CustomerAcceptanceBuilder; + } + + impl FromValueOpt for CustomerAcceptance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerAcceptanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "accepted_at" => b.accepted_at = Some(FromValueOpt::from_value(v)?), + "offline" => b.offline = Some(FromValueOpt::from_value(v)?), + "online" => b.online = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The mandate includes the type of customer acceptance information, such as: `online` or `offline`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CustomerAcceptanceType { @@ -60,7 +158,24 @@ impl<'de> serde::Deserialize<'de> for CustomerAcceptanceType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CustomerAcceptanceType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerAcceptanceType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerAcceptanceType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerAcceptanceType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerAcceptanceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerAcceptanceType); diff --git a/generated/stripe_shared/src/customer_balance_customer_balance_settings.rs b/generated/stripe_shared/src/customer_balance_customer_balance_settings.rs index c8cbe74d6..d7b3e6ae8 100644 --- a/generated/stripe_shared/src/customer_balance_customer_balance_settings.rs +++ b/generated/stripe_shared/src/customer_balance_customer_balance_settings.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceCustomerBalanceSettings { /// The configuration for how funds that land in the customer cash balance are reconciled. pub reconciliation_mode: CustomerBalanceCustomerBalanceSettingsReconciliationMode, /// A flag to indicate if reconciliation mode returned is the user's default or is specific to this customer cash balance. pub using_merchant_default: bool, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceCustomerBalanceSettingsBuilder { + reconciliation_mode: Option<CustomerBalanceCustomerBalanceSettingsReconciliationMode>, + using_merchant_default: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceCustomerBalanceSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceCustomerBalanceSettings>, + builder: CustomerBalanceCustomerBalanceSettingsBuilder, + } + + impl Visitor for Place<CustomerBalanceCustomerBalanceSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceCustomerBalanceSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceCustomerBalanceSettingsBuilder { + type Out = CustomerBalanceCustomerBalanceSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reconciliation_mode" => Deserialize::begin(&mut self.reconciliation_mode), + "using_merchant_default" => Deserialize::begin(&mut self.using_merchant_default), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reconciliation_mode: Deserialize::default(), using_merchant_default: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reconciliation_mode = self.reconciliation_mode.take()?; + let using_merchant_default = self.using_merchant_default.take()?; + + Some(Self::Out { reconciliation_mode, using_merchant_default }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceCustomerBalanceSettings { + type Builder = CustomerBalanceCustomerBalanceSettingsBuilder; + } + + impl FromValueOpt for CustomerBalanceCustomerBalanceSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceCustomerBalanceSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reconciliation_mode" => b.reconciliation_mode = Some(FromValueOpt::from_value(v)?), + "using_merchant_default" => b.using_merchant_default = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The configuration for how funds that land in the customer cash balance are reconciled. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CustomerBalanceCustomerBalanceSettingsReconciliationMode { @@ -55,10 +147,24 @@ impl<'de> serde::Deserialize<'de> for CustomerBalanceCustomerBalanceSettingsReco fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for CustomerBalanceCustomerBalanceSettingsReconciliationMode", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerBalanceCustomerBalanceSettingsReconciliationMode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerBalanceCustomerBalanceSettingsReconciliationMode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerBalanceCustomerBalanceSettingsReconciliationMode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerBalanceCustomerBalanceSettingsReconciliationMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerBalanceCustomerBalanceSettingsReconciliationMode); diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_adjusted_for_overdraft.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_adjusted_for_overdraft.rs index 5cda40951..aec6603df 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_adjusted_for_overdraft.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_adjusted_for_overdraft.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft { /// The [Balance Transaction](https://stripe.com/docs/api/balance_transactions/object) that corresponds to funds taken out of your Stripe balance. pub balance_transaction: stripe_types::Expandable<stripe_shared::BalanceTransaction>, /// The [Cash Balance Transaction](https://stripe.com/docs/api/cash_balance_transactions/object) that brought the customer balance negative, triggering the clawback of funds. pub linked_transaction: stripe_types::Expandable<stripe_shared::CustomerCashBalanceTransaction>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder { + balance_transaction: Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, + linked_transaction: Option<stripe_types::Expandable<stripe_shared::CustomerCashBalanceTransaction>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "linked_transaction" => Deserialize::begin(&mut self.linked_transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { balance_transaction: Deserialize::default(), linked_transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let balance_transaction = self.balance_transaction.take()?; + let linked_transaction = self.linked_transaction.take()?; + + Some(Self::Out { balance_transaction, linked_transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "linked_transaction" => b.linked_transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_applied_to_payment_transaction.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_applied_to_payment_transaction.rs index 9f055d1c4..5e678b76a 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_applied_to_payment_transaction.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_applied_to_payment_transaction.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction { /// The [Payment Intent](https://stripe.com/docs/api/payment_intents/object) that funds were applied to. pub payment_intent: stripe_types::Expandable<stripe_shared::PaymentIntent>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder { + payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payment_intent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let payment_intent = self.payment_intent.take()?; + + Some(Self::Out { payment_intent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction.rs index 99460779b..cac6e446f 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction.rs @@ -1,5 +1,92 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction { -pub bank_transfer: stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer, - + pub bank_transfer: stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer, +} +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder { + bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_transfer" => Deserialize::begin(&mut self.bank_transfer), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transfer: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_transfer = self.bank_transfer.take()?; + + Some(Self::Out { bank_transfer }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_transfer" => b.bank_transfer = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer.rs index 75c20a452..bb6e6b882 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer.rs @@ -1,35 +1,142 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer { -#[serde(skip_serializing_if = "Option::is_none")] -pub eu_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer>, -#[serde(skip_serializing_if = "Option::is_none")] -pub gb_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer>, -#[serde(skip_serializing_if = "Option::is_none")] -pub jp_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer>, + pub eu_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer>, + pub gb_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer>, + pub jp_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer>, /// The user-supplied reference field on the bank transfer. -pub reference: Option<String>, - /// The funding method type used to fund the customer balance. + pub reference: Option<String>, + /// The funding method type used to fund the customer balance. /// Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. -#[serde(rename = "type")] -pub type_: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType, -#[serde(skip_serializing_if = "Option::is_none")] -pub us_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer>, - + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType, + pub us_bank_transfer: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer>, +} +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder { + eu_bank_transfer: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer>>, + gb_bank_transfer: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer>>, + jp_bank_transfer: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer>>, + reference: Option<Option<String>>, + type_: Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType>, + us_bank_transfer: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer>>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "eu_bank_transfer" => Deserialize::begin(&mut self.eu_bank_transfer), + "gb_bank_transfer" => Deserialize::begin(&mut self.gb_bank_transfer), + "jp_bank_transfer" => Deserialize::begin(&mut self.jp_bank_transfer), + "reference" => Deserialize::begin(&mut self.reference), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_transfer" => Deserialize::begin(&mut self.us_bank_transfer), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + eu_bank_transfer: Deserialize::default(), + gb_bank_transfer: Deserialize::default(), + jp_bank_transfer: Deserialize::default(), + reference: Deserialize::default(), + type_: Deserialize::default(), + us_bank_transfer: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let eu_bank_transfer = self.eu_bank_transfer.take()?; + let gb_bank_transfer = self.gb_bank_transfer.take()?; + let jp_bank_transfer = self.jp_bank_transfer.take()?; + let reference = self.reference.take()?; + let type_ = self.type_.take()?; + let us_bank_transfer = self.us_bank_transfer.take()?; + + Some(Self::Out { eu_bank_transfer, gb_bank_transfer, jp_bank_transfer, reference, type_, us_bank_transfer }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "eu_bank_transfer" => b.eu_bank_transfer = Some(FromValueOpt::from_value(v)?), + "gb_bank_transfer" => b.gb_bank_transfer = Some(FromValueOpt::from_value(v)?), + "jp_bank_transfer" => b.jp_bank_transfer = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_transfer" => b.us_bank_transfer = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The funding method type used to fund the customer balance. /// Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType -{ +pub enum CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType { EuBankTransfer, GbBankTransfer, JpBankTransfer, MxBankTransfer, UsBankTransfer, } -impl - CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType -{ +impl CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType { pub fn as_str(self) -> &'static str { use CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType::*; match self { @@ -47,13 +154,12 @@ impl std::str::FromStr for CustomerBalanceResourceCashBalanceTransactionResource fn from_str(s: &str) -> Result<Self, Self::Err> { use CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType::*; match s { - "eu_bank_transfer" => Ok(EuBankTransfer), -"gb_bank_transfer" => Ok(GbBankTransfer), -"jp_bank_transfer" => Ok(JpBankTransfer), -"mx_bank_transfer" => Ok(MxBankTransfer), -"us_bank_transfer" => Ok(UsBankTransfer), -_ => Err(()) - + "eu_bank_transfer" => Ok(EuBankTransfer), + "gb_bank_transfer" => Ok(GbBankTransfer), + "jp_bank_transfer" => Ok(JpBankTransfer), + "mx_bank_transfer" => Ok(MxBankTransfer), + "us_bank_transfer" => Ok(UsBankTransfer), + _ => Err(()), } } } @@ -69,7 +175,10 @@ impl std::fmt::Debug for CustomerBalanceResourceCashBalanceTransactionResourceFu } } impl serde::Serialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } @@ -80,3 +189,21 @@ impl<'de> serde::Deserialize<'de> for CustomerBalanceResourceCashBalanceTransact Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType); diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_eu_bank_transfer.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_eu_bank_transfer.rs index 47a2dd437..dad2eb83e 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_eu_bank_transfer.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_eu_bank_transfer.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer -{ +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer { /// The BIC of the bank of the sender of the funding. pub bic: Option<String>, /// The last 4 digits of the IBAN of the sender of the funding. @@ -8,3 +9,100 @@ pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactio /// The full name of the sender, as supplied by the sending bank. pub sender_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder { + bic: Option<Option<String>>, + iban_last4: Option<Option<String>>, + sender_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bic" => Deserialize::begin(&mut self.bic), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "sender_name" => Deserialize::begin(&mut self.sender_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bic: Deserialize::default(), iban_last4: Deserialize::default(), sender_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bic = self.bic.take()?; + let iban_last4 = self.iban_last4.take()?; + let sender_name = self.sender_name.take()?; + + Some(Self::Out { bic, iban_last4, sender_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "sender_name" => b.sender_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_gb_bank_transfer.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_gb_bank_transfer.rs index 8ecb631c8..2431ffc3b 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_gb_bank_transfer.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_gb_bank_transfer.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer -{ +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer { /// The last 4 digits of the account number of the sender of the funding. pub account_number_last4: Option<String>, /// The full name of the sender, as supplied by the sending bank. @@ -8,3 +9,100 @@ pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactio /// The sort code of the bank of the sender of the funding pub sort_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder { + account_number_last4: Option<Option<String>>, + sender_name: Option<Option<String>>, + sort_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_number_last4" => Deserialize::begin(&mut self.account_number_last4), + "sender_name" => Deserialize::begin(&mut self.sender_name), + "sort_code" => Deserialize::begin(&mut self.sort_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_number_last4: Deserialize::default(), sender_name: Deserialize::default(), sort_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_number_last4 = self.account_number_last4.take()?; + let sender_name = self.sender_name.take()?; + let sort_code = self.sort_code.take()?; + + Some(Self::Out { account_number_last4, sender_name, sort_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_number_last4" => b.account_number_last4 = Some(FromValueOpt::from_value(v)?), + "sender_name" => b.sender_name = Some(FromValueOpt::from_value(v)?), + "sort_code" => b.sort_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_jp_bank_transfer.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_jp_bank_transfer.rs index 694874cb8..d31ffb5fa 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_jp_bank_transfer.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_jp_bank_transfer.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer -{ +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer { /// The name of the bank of the sender of the funding. pub sender_bank: Option<String>, /// The name of the bank branch of the sender of the funding. @@ -8,3 +9,100 @@ pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactio /// The full name of the sender, as supplied by the sending bank. pub sender_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder { + sender_bank: Option<Option<String>>, + sender_branch: Option<Option<String>>, + sender_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "sender_bank" => Deserialize::begin(&mut self.sender_bank), + "sender_branch" => Deserialize::begin(&mut self.sender_branch), + "sender_name" => Deserialize::begin(&mut self.sender_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { sender_bank: Deserialize::default(), sender_branch: Deserialize::default(), sender_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let sender_bank = self.sender_bank.take()?; + let sender_branch = self.sender_branch.take()?; + let sender_name = self.sender_name.take()?; + + Some(Self::Out { sender_bank, sender_branch, sender_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "sender_bank" => b.sender_bank = Some(FromValueOpt::from_value(v)?), + "sender_branch" => b.sender_branch = Some(FromValueOpt::from_value(v)?), + "sender_name" => b.sender_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_us_bank_transfer.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_us_bank_transfer.rs index f675d01a1..5dea3c889 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_us_bank_transfer.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_funded_transaction_resource_bank_transfer_resource_us_bank_transfer.rs @@ -1,16 +1,108 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer { /// The banking network used for this funding. -#[serde(skip_serializing_if = "Option::is_none")] -pub network: Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork>, + pub network: Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork>, /// The full name of the sender, as supplied by the sending bank. -pub sender_name: Option<String>, - + pub sender_name: Option<String>, +} +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder { + network: Option<Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork>>, + sender_name: Option<Option<String>>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "network" => Deserialize::begin(&mut self.network), + "sender_name" => Deserialize::begin(&mut self.sender_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { network: Deserialize::default(), sender_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let network = self.network.take()?; + let sender_name = self.sender_name.take()?; + + Some(Self::Out { network, sender_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "sender_name" => b.sender_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The banking network used for this funding. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork -{ +pub enum CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork { Ach, DomesticWireUs, Swift, @@ -19,10 +111,9 @@ impl CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResou pub fn as_str(self) -> &'static str { use CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork::*; match self { -Ach => "ach", -DomesticWireUs => "domestic_wire_us", -Swift => "swift", - + Ach => "ach", + DomesticWireUs => "domestic_wire_us", + Swift => "swift", } } } @@ -32,11 +123,10 @@ impl std::str::FromStr for CustomerBalanceResourceCashBalanceTransactionResource fn from_str(s: &str) -> Result<Self, Self::Err> { use CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork::*; match s { - "ach" => Ok(Ach), -"domestic_wire_us" => Ok(DomesticWireUs), -"swift" => Ok(Swift), -_ => Err(()) - + "ach" => Ok(Ach), + "domestic_wire_us" => Ok(DomesticWireUs), + "swift" => Ok(Swift), + _ => Err(()), } } } @@ -52,7 +142,10 @@ impl std::fmt::Debug for CustomerBalanceResourceCashBalanceTransactionResourceFu } } impl serde::Serialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } @@ -60,6 +153,25 @@ impl<'de> serde::Deserialize<'de> for CustomerBalanceResourceCashBalanceTransact fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork")) + Self::from_str(&s) + .map_err(|_| serde::de::Error::custom("Unknown value for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork); diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_refunded_from_payment_transaction.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_refunded_from_payment_transaction.rs index 2c96cf7b8..5ea4b8318 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_refunded_from_payment_transaction.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_refunded_from_payment_transaction.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction { /// The [Refund](https://stripe.com/docs/api/refunds/object) that moved these funds into the customer's cash balance. pub refund: stripe_types::Expandable<stripe_shared::Refund>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder { + refund: Option<stripe_types::Expandable<stripe_shared::Refund>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "refund" => Deserialize::begin(&mut self.refund), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { refund: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let refund = self.refund.take()?; + + Some(Self::Out { refund }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "refund" => b.refund = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_transferred_to_balance.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_transferred_to_balance.rs deleted file mode 100644 index e18d761cb..000000000 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_transferred_to_balance.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance { - /// The [Balance Transaction](https://stripe.com/docs/api/balance_transactions/object) that corresponds to funds transferred to your Stripe balance. - pub balance_transaction: stripe_types::Expandable<stripe_shared::BalanceTransaction>, -} diff --git a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction.rs b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction.rs index 8d188aa97..daa59bfde 100644 --- a/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction.rs +++ b/generated/stripe_shared/src/customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction { /// The [Payment Intent](https://stripe.com/docs/api/payment_intents/object) that funds were unapplied from. pub payment_intent: stripe_types::Expandable<stripe_shared::PaymentIntent>, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder { + payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction>, + builder: CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder, + } + + impl Visitor for Place<CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payment_intent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let payment_intent = self.payment_intent.take()?; + + Some(Self::Out { payment_intent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction { + type Builder = CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/customer_balance_transaction.rs b/generated/stripe_shared/src/customer_balance_transaction.rs index c7be37a23..40d3ab107 100644 --- a/generated/stripe_shared/src/customer_balance_transaction.rs +++ b/generated/stripe_shared/src/customer_balance_transaction.rs @@ -6,7 +6,9 @@ /// Related guide: [Customer balance](https://stripe.com/docs/billing/customer/balance) /// /// For more details see <<https://stripe.com/docs/api/customer_balance_transactions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerBalanceTransaction { /// The amount of the transaction. /// A negative value is a credit for the customer's balance, and a positive value is a debit to the customer's `balance`. @@ -37,9 +39,152 @@ pub struct CustomerBalanceTransaction { pub metadata: Option<std::collections::HashMap<String, String>>, /// Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, or `unapplied_from_invoice`. /// See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CustomerBalanceTransactionType, } +#[cfg(feature = "min-ser")] +pub struct CustomerBalanceTransactionBuilder { + amount: Option<i64>, + created: Option<stripe_types::Timestamp>, + credit_note: Option<Option<stripe_types::Expandable<stripe_shared::CreditNote>>>, + currency: Option<stripe_types::Currency>, + customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, + description: Option<Option<String>>, + ending_balance: Option<i64>, + id: Option<stripe_shared::CustomerBalanceTransactionId>, + invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + type_: Option<CustomerBalanceTransactionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerBalanceTransaction>, + builder: CustomerBalanceTransactionBuilder, + } + + impl Visitor for Place<CustomerBalanceTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerBalanceTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerBalanceTransactionBuilder { + type Out = CustomerBalanceTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "created" => Deserialize::begin(&mut self.created), + "credit_note" => Deserialize::begin(&mut self.credit_note), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "description" => Deserialize::begin(&mut self.description), + "ending_balance" => Deserialize::begin(&mut self.ending_balance), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + created: Deserialize::default(), + credit_note: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + description: Deserialize::default(), + ending_balance: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let created = self.created.take()?; + let credit_note = self.credit_note.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let description = self.description.take()?; + let ending_balance = self.ending_balance.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { amount, created, credit_note, currency, customer, description, ending_balance, id, invoice, livemode, metadata, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceTransaction { + type Builder = CustomerBalanceTransactionBuilder; + } + + impl FromValueOpt for CustomerBalanceTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "credit_note" => b.credit_note = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "ending_balance" => b.ending_balance = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Transaction type: `adjustment`, `applied_to_invoice`, `credit_note`, `initial`, `invoice_overpaid`, `invoice_too_large`, `invoice_too_small`, `unspent_receiver_credit`, or `unapplied_from_invoice`. /// See the [Customer Balance page](https://stripe.com/docs/billing/customer/balance#types) to learn more about transaction types. #[derive(Copy, Clone, Eq, PartialEq)] @@ -115,11 +260,27 @@ impl<'de> serde::Deserialize<'de> for CustomerBalanceTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for CustomerBalanceTransactionType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerBalanceTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerBalanceTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerBalanceTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerBalanceTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerBalanceTransactionType); impl stripe_types::Object for CustomerBalanceTransaction { type Id = stripe_shared::CustomerBalanceTransactionId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/customer_cash_balance_transaction.rs b/generated/stripe_shared/src/customer_cash_balance_transaction.rs index e65cf7add..efc3f90cf 100644 --- a/generated/stripe_shared/src/customer_cash_balance_transaction.rs +++ b/generated/stripe_shared/src/customer_cash_balance_transaction.rs @@ -6,44 +6,200 @@ /// to payments, and refunds to the customer. /// /// For more details see <<https://stripe.com/docs/api/cash_balance_transactions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerCashBalanceTransaction { -#[serde(skip_serializing_if = "Option::is_none")] -pub adjusted_for_overdraft: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft>, -#[serde(skip_serializing_if = "Option::is_none")] -pub applied_to_payment: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction>, + pub adjusted_for_overdraft: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft>, + pub applied_to_payment: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction>, /// Time at which the object was created. Measured in seconds since the Unix epoch. -pub created: stripe_types::Timestamp, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + pub created: stripe_types::Timestamp, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// Must be a [supported currency](https://stripe.com/docs/currencies). -pub currency: stripe_types::Currency, + pub currency: stripe_types::Currency, /// The customer whose available cash balance changed as a result of this transaction. -pub customer: stripe_types::Expandable<stripe_shared::Customer>, - /// The total available cash balance for the specified currency after this transaction was applied. + pub customer: stripe_types::Expandable<stripe_shared::Customer>, + /// The total available cash balance for the specified currency after this transaction was applied. /// Represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). -pub ending_balance: i64, -#[serde(skip_serializing_if = "Option::is_none")] -pub funded: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction>, + pub ending_balance: i64, + pub funded: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction>, /// Unique identifier for the object. -pub id: stripe_shared::CustomerCashBalanceTransactionId, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. -pub livemode: bool, - /// The amount by which the cash balance changed, represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). + pub id: stripe_shared::CustomerCashBalanceTransactionId, + /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + pub livemode: bool, + /// The amount by which the cash balance changed, represented in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// A positive value represents funds being added to the cash balance, a negative value represents funds being removed from the cash balance. -pub net_amount: i64, -#[serde(skip_serializing_if = "Option::is_none")] -pub refunded_from_payment: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction>, -#[serde(skip_serializing_if = "Option::is_none")] -pub transferred_to_balance: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance>, - /// The type of the cash balance transaction. + pub net_amount: i64, + pub refunded_from_payment: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction>, + /// The type of the cash balance transaction. /// New types may be added in future. /// See [Customer Balance](https://stripe.com/docs/payments/customer-balance#types) to learn more about these types. -#[serde(rename = "type")] -pub type_: CustomerCashBalanceTransactionType, -#[serde(skip_serializing_if = "Option::is_none")] -pub unapplied_from_payment: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction>, - + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: CustomerCashBalanceTransactionType, + pub unapplied_from_payment: Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction>, +} +#[cfg(feature = "min-ser")] +pub struct CustomerCashBalanceTransactionBuilder { + adjusted_for_overdraft: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft>>, + applied_to_payment: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, + ending_balance: Option<i64>, + funded: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction>>, + id: Option<stripe_shared::CustomerCashBalanceTransactionId>, + livemode: Option<bool>, + net_amount: Option<i64>, + refunded_from_payment: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction>>, + type_: Option<CustomerCashBalanceTransactionType>, + unapplied_from_payment: Option<Option<stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction>>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerCashBalanceTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerCashBalanceTransaction>, + builder: CustomerCashBalanceTransactionBuilder, + } + + impl Visitor for Place<CustomerCashBalanceTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerCashBalanceTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerCashBalanceTransactionBuilder { + type Out = CustomerCashBalanceTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "adjusted_for_overdraft" => Deserialize::begin(&mut self.adjusted_for_overdraft), + "applied_to_payment" => Deserialize::begin(&mut self.applied_to_payment), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "ending_balance" => Deserialize::begin(&mut self.ending_balance), + "funded" => Deserialize::begin(&mut self.funded), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "net_amount" => Deserialize::begin(&mut self.net_amount), + "refunded_from_payment" => Deserialize::begin(&mut self.refunded_from_payment), + "type" => Deserialize::begin(&mut self.type_), + "unapplied_from_payment" => Deserialize::begin(&mut self.unapplied_from_payment), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + adjusted_for_overdraft: Deserialize::default(), + applied_to_payment: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + ending_balance: Deserialize::default(), + funded: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + net_amount: Deserialize::default(), + refunded_from_payment: Deserialize::default(), + type_: Deserialize::default(), + unapplied_from_payment: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let adjusted_for_overdraft = self.adjusted_for_overdraft.take()?; + let applied_to_payment = self.applied_to_payment.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let ending_balance = self.ending_balance.take()?; + let funded = self.funded.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let net_amount = self.net_amount.take()?; + let refunded_from_payment = self.refunded_from_payment.take()?; + let type_ = self.type_.take()?; + let unapplied_from_payment = self.unapplied_from_payment.take()?; + + Some(Self::Out { + adjusted_for_overdraft, + applied_to_payment, + created, + currency, + customer, + ending_balance, + funded, + id, + livemode, + net_amount, + refunded_from_payment, + type_, + unapplied_from_payment, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerCashBalanceTransaction { + type Builder = CustomerCashBalanceTransactionBuilder; + } + + impl FromValueOpt for CustomerCashBalanceTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerCashBalanceTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "adjusted_for_overdraft" => b.adjusted_for_overdraft = Some(FromValueOpt::from_value(v)?), + "applied_to_payment" => b.applied_to_payment = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "ending_balance" => b.ending_balance = Some(FromValueOpt::from_value(v)?), + "funded" => b.funded = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "net_amount" => b.net_amount = Some(FromValueOpt::from_value(v)?), + "refunded_from_payment" => b.refunded_from_payment = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "unapplied_from_payment" => b.unapplied_from_payment = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the cash balance transaction. /// New types may be added in future. /// See [Customer Balance](https://stripe.com/docs/payments/customer-balance#types) to learn more about these types. @@ -117,11 +273,27 @@ impl<'de> serde::Deserialize<'de> for CustomerCashBalanceTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for CustomerCashBalanceTransactionType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerCashBalanceTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerCashBalanceTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerCashBalanceTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerCashBalanceTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerCashBalanceTransactionType); impl stripe_types::Object for CustomerCashBalanceTransaction { type Id = stripe_shared::CustomerCashBalanceTransactionId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/customer_tax.rs b/generated/stripe_shared/src/customer_tax.rs index a4698f5dd..040973b3c 100644 --- a/generated/stripe_shared/src/customer_tax.rs +++ b/generated/stripe_shared/src/customer_tax.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerTax { /// Surfaces if automatic tax computation is possible given the current customer location information. pub automatic_tax: CustomerTaxAutomaticTax, @@ -7,6 +9,100 @@ pub struct CustomerTax { /// The customer's location as identified by Stripe Tax. pub location: Option<stripe_shared::CustomerTaxLocation>, } +#[cfg(feature = "min-ser")] +pub struct CustomerTaxBuilder { + automatic_tax: Option<CustomerTaxAutomaticTax>, + ip_address: Option<Option<String>>, + location: Option<Option<stripe_shared::CustomerTaxLocation>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerTax>, + builder: CustomerTaxBuilder, + } + + impl Visitor for Place<CustomerTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerTaxBuilder { + type Out = CustomerTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "ip_address" => Deserialize::begin(&mut self.ip_address), + "location" => Deserialize::begin(&mut self.location), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { automatic_tax: Deserialize::default(), ip_address: Deserialize::default(), location: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let automatic_tax = self.automatic_tax.take()?; + let ip_address = self.ip_address.take()?; + let location = self.location.take()?; + + Some(Self::Out { automatic_tax, ip_address, location }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerTax { + type Builder = CustomerTaxBuilder; + } + + impl FromValueOpt for CustomerTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "ip_address" => b.ip_address = Some(FromValueOpt::from_value(v)?), + "location" => b.location = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Surfaces if automatic tax computation is possible given the current customer location information. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CustomerTaxAutomaticTax { @@ -63,7 +159,24 @@ impl<'de> serde::Deserialize<'de> for CustomerTaxAutomaticTax { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CustomerTaxAutomaticTax")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerTaxAutomaticTax")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerTaxAutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerTaxAutomaticTax> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerTaxAutomaticTax::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerTaxAutomaticTax); diff --git a/generated/stripe_shared/src/customer_tax_location.rs b/generated/stripe_shared/src/customer_tax_location.rs index b99613984..21350ed27 100644 --- a/generated/stripe_shared/src/customer_tax_location.rs +++ b/generated/stripe_shared/src/customer_tax_location.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct CustomerTaxLocation { /// The customer's country as identified by Stripe Tax. pub country: String, @@ -7,6 +9,100 @@ pub struct CustomerTaxLocation { /// The customer's state, county, province, or region as identified by Stripe Tax. pub state: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct CustomerTaxLocationBuilder { + country: Option<String>, + source: Option<CustomerTaxLocationSource>, + state: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerTaxLocation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<CustomerTaxLocation>, + builder: CustomerTaxLocationBuilder, + } + + impl Visitor for Place<CustomerTaxLocation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: CustomerTaxLocationBuilder::deser_default() })) + } + } + + impl MapBuilder for CustomerTaxLocationBuilder { + type Out = CustomerTaxLocation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + "source" => Deserialize::begin(&mut self.source), + "state" => Deserialize::begin(&mut self.state), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default(), source: Deserialize::default(), state: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + let source = self.source.take()?; + let state = self.state.take()?; + + Some(Self::Out { country, source, state }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerTaxLocation { + type Builder = CustomerTaxLocationBuilder; + } + + impl FromValueOpt for CustomerTaxLocation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerTaxLocationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The data source used to infer the customer's location. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CustomerTaxLocationSource { @@ -63,7 +159,24 @@ impl<'de> serde::Deserialize<'de> for CustomerTaxLocationSource { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for CustomerTaxLocationSource")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for CustomerTaxLocationSource")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for CustomerTaxLocationSource { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<CustomerTaxLocationSource> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerTaxLocationSource::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(CustomerTaxLocationSource); diff --git a/generated/stripe_shared/src/deleted_account.rs b/generated/stripe_shared/src/deleted_account.rs index 7f3c8435a..42b18a0d4 100644 --- a/generated/stripe_shared/src/deleted_account.rs +++ b/generated/stripe_shared/src/deleted_account.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedAccount { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::AccountId, } +#[cfg(feature = "min-ser")] +pub struct DeletedAccountBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::AccountId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedAccount>, + builder: DeletedAccountBuilder, + } + + impl Visitor for Place<DeletedAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedAccountBuilder { + type Out = DeletedAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedAccount { + type Builder = DeletedAccountBuilder; + } + + impl FromValueOpt for DeletedAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedAccount { type Id = stripe_shared::AccountId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_bank_account.rs b/generated/stripe_shared/src/deleted_bank_account.rs index 2c8093965..bcb9033b1 100644 --- a/generated/stripe_shared/src/deleted_bank_account.rs +++ b/generated/stripe_shared/src/deleted_bank_account.rs @@ -1,13 +1,109 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedBankAccount { /// Three-letter [ISO code for the currency](https://stripe.com/docs/payouts) paid out to the bank account. - #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<stripe_types::Currency>, /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::BankAccountId, } +#[cfg(feature = "min-ser")] +pub struct DeletedBankAccountBuilder { + currency: Option<Option<stripe_types::Currency>>, + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::BankAccountId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedBankAccount>, + builder: DeletedBankAccountBuilder, + } + + impl Visitor for Place<DeletedBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedBankAccountBuilder { + type Out = DeletedBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "currency" => Deserialize::begin(&mut self.currency), + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { currency: Deserialize::default(), deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let currency = self.currency.take()?; + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { currency, deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedBankAccount { + type Builder = DeletedBankAccountBuilder; + } + + impl FromValueOpt for DeletedBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedBankAccount { type Id = stripe_shared::BankAccountId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_card.rs b/generated/stripe_shared/src/deleted_card.rs index e430a17aa..23b6c795e 100644 --- a/generated/stripe_shared/src/deleted_card.rs +++ b/generated/stripe_shared/src/deleted_card.rs @@ -1,13 +1,109 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedCard { /// Three-letter [ISO code for the currency](https://stripe.com/docs/payouts) paid out to the bank account. - #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option<stripe_types::Currency>, /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::CardId, } +#[cfg(feature = "min-ser")] +pub struct DeletedCardBuilder { + currency: Option<Option<stripe_types::Currency>>, + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::CardId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedCard>, + builder: DeletedCardBuilder, + } + + impl Visitor for Place<DeletedCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedCardBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedCardBuilder { + type Out = DeletedCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "currency" => Deserialize::begin(&mut self.currency), + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { currency: Deserialize::default(), deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let currency = self.currency.take()?; + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { currency, deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedCard { + type Builder = DeletedCardBuilder; + } + + impl FromValueOpt for DeletedCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedCard { type Id = stripe_shared::CardId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_coupon.rs b/generated/stripe_shared/src/deleted_coupon.rs index f179913b1..80114fda7 100644 --- a/generated/stripe_shared/src/deleted_coupon.rs +++ b/generated/stripe_shared/src/deleted_coupon.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedCoupon { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::CouponId, } +#[cfg(feature = "min-ser")] +pub struct DeletedCouponBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::CouponId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedCoupon { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedCoupon>, + builder: DeletedCouponBuilder, + } + + impl Visitor for Place<DeletedCoupon> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedCouponBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedCouponBuilder { + type Out = DeletedCoupon; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedCoupon { + type Builder = DeletedCouponBuilder; + } + + impl FromValueOpt for DeletedCoupon { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedCouponBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedCoupon { type Id = stripe_shared::CouponId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_customer.rs b/generated/stripe_shared/src/deleted_customer.rs index 96058aab1..eb94f217f 100644 --- a/generated/stripe_shared/src/deleted_customer.rs +++ b/generated/stripe_shared/src/deleted_customer.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedCustomer { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::CustomerId, } +#[cfg(feature = "min-ser")] +pub struct DeletedCustomerBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::CustomerId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedCustomer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedCustomer>, + builder: DeletedCustomerBuilder, + } + + impl Visitor for Place<DeletedCustomer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedCustomerBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedCustomerBuilder { + type Out = DeletedCustomer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedCustomer { + type Builder = DeletedCustomerBuilder; + } + + impl FromValueOpt for DeletedCustomer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedCustomerBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedCustomer { type Id = stripe_shared::CustomerId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_discount.rs b/generated/stripe_shared/src/deleted_discount.rs index a3027a163..f6e70ef2d 100644 --- a/generated/stripe_shared/src/deleted_discount.rs +++ b/generated/stripe_shared/src/deleted_discount.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedDiscount { /// The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode. /// Will not be present for subscription mode. @@ -7,6 +9,7 @@ pub struct DeletedDiscount { /// The ID of the customer associated with this discount. pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// The ID of the discount object. /// Discounts cannot be fetched by ID. @@ -23,6 +26,139 @@ pub struct DeletedDiscount { /// The subscription that this coupon is applied to, if it is applied to a particular subscription. pub subscription: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct DeletedDiscountBuilder { + checkout_session: Option<Option<String>>, + coupon: Option<stripe_shared::Coupon>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::DiscountId>, + invoice: Option<Option<String>>, + invoice_item: Option<Option<String>>, + promotion_code: Option<Option<stripe_types::Expandable<stripe_shared::PromotionCode>>>, + start: Option<stripe_types::Timestamp>, + subscription: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedDiscount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedDiscount>, + builder: DeletedDiscountBuilder, + } + + impl Visitor for Place<DeletedDiscount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedDiscountBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedDiscountBuilder { + type Out = DeletedDiscount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "checkout_session" => Deserialize::begin(&mut self.checkout_session), + "coupon" => Deserialize::begin(&mut self.coupon), + "customer" => Deserialize::begin(&mut self.customer), + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "invoice_item" => Deserialize::begin(&mut self.invoice_item), + "promotion_code" => Deserialize::begin(&mut self.promotion_code), + "start" => Deserialize::begin(&mut self.start), + "subscription" => Deserialize::begin(&mut self.subscription), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + checkout_session: Deserialize::default(), + coupon: Deserialize::default(), + customer: Deserialize::default(), + deleted: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + invoice_item: Deserialize::default(), + promotion_code: Deserialize::default(), + start: Deserialize::default(), + subscription: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let checkout_session = self.checkout_session.take()?; + let coupon = self.coupon.take()?; + let customer = self.customer.take()?; + let deleted = self.deleted.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let invoice_item = self.invoice_item.take()?; + let promotion_code = self.promotion_code.take()?; + let start = self.start.take()?; + let subscription = self.subscription.take()?; + + Some(Self::Out { checkout_session, coupon, customer, deleted, id, invoice, invoice_item, promotion_code, start, subscription }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedDiscount { + type Builder = DeletedDiscountBuilder; + } + + impl FromValueOpt for DeletedDiscount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedDiscountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "checkout_session" => b.checkout_session = Some(FromValueOpt::from_value(v)?), + "coupon" => b.coupon = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "invoice_item" => b.invoice_item = Some(FromValueOpt::from_value(v)?), + "promotion_code" => b.promotion_code = Some(FromValueOpt::from_value(v)?), + "start" => b.start = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedDiscount { type Id = stripe_shared::DiscountId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_external_account.rs b/generated/stripe_shared/src/deleted_external_account.rs index a43f16905..9ff64c6ce 100644 --- a/generated/stripe_shared/src/deleted_external_account.rs +++ b/generated/stripe_shared/src/deleted_external_account.rs @@ -1,12 +1,99 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum DeletedExternalAccount { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] DeletedBankAccount(stripe_shared::DeletedBankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] DeletedCard(stripe_shared::DeletedCard), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct DeletedExternalAccountBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<DeletedExternalAccount>, + builder: DeletedExternalAccountBuilder, + } + + impl Deserialize for DeletedExternalAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<DeletedExternalAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for DeletedExternalAccountBuilder { + type Out = DeletedExternalAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + DeletedExternalAccount::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for DeletedExternalAccount { + type Builder = DeletedExternalAccountBuilder; + } + impl DeletedExternalAccount { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::DeletedBankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::DeletedCard(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for DeletedExternalAccount { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + impl stripe_types::Object for DeletedExternalAccount { type Id = smol_str::SmolStr; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_invoice.rs b/generated/stripe_shared/src/deleted_invoice.rs index c70fedb3e..eb57edfd6 100644 --- a/generated/stripe_shared/src/deleted_invoice.rs +++ b/generated/stripe_shared/src/deleted_invoice.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedInvoice { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::InvoiceId, } +#[cfg(feature = "min-ser")] +pub struct DeletedInvoiceBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::InvoiceId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedInvoice { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedInvoice>, + builder: DeletedInvoiceBuilder, + } + + impl Visitor for Place<DeletedInvoice> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedInvoiceBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedInvoiceBuilder { + type Out = DeletedInvoice; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedInvoice { + type Builder = DeletedInvoiceBuilder; + } + + impl FromValueOpt for DeletedInvoice { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedInvoiceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedInvoice { type Id = stripe_shared::InvoiceId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_invoiceitem.rs b/generated/stripe_shared/src/deleted_invoiceitem.rs index bcaf0face..a2696a2e0 100644 --- a/generated/stripe_shared/src/deleted_invoiceitem.rs +++ b/generated/stripe_shared/src/deleted_invoiceitem.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedInvoiceitem { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::InvoiceItemId, } +#[cfg(feature = "min-ser")] +pub struct DeletedInvoiceitemBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::InvoiceItemId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedInvoiceitem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedInvoiceitem>, + builder: DeletedInvoiceitemBuilder, + } + + impl Visitor for Place<DeletedInvoiceitem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedInvoiceitemBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedInvoiceitemBuilder { + type Out = DeletedInvoiceitem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedInvoiceitem { + type Builder = DeletedInvoiceitemBuilder; + } + + impl FromValueOpt for DeletedInvoiceitem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedInvoiceitemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedInvoiceitem { type Id = stripe_shared::InvoiceItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_payment_source.rs b/generated/stripe_shared/src/deleted_payment_source.rs index a7e02870f..8f6cd87aa 100644 --- a/generated/stripe_shared/src/deleted_payment_source.rs +++ b/generated/stripe_shared/src/deleted_payment_source.rs @@ -1,12 +1,99 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum DeletedPaymentSource { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] DeletedBankAccount(stripe_shared::DeletedBankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] DeletedCard(stripe_shared::DeletedCard), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct DeletedPaymentSourceBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<DeletedPaymentSource>, + builder: DeletedPaymentSourceBuilder, + } + + impl Deserialize for DeletedPaymentSource { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<DeletedPaymentSource> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for DeletedPaymentSourceBuilder { + type Out = DeletedPaymentSource; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + DeletedPaymentSource::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for DeletedPaymentSource { + type Builder = DeletedPaymentSourceBuilder; + } + impl DeletedPaymentSource { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::DeletedBankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::DeletedCard(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for DeletedPaymentSource { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + impl stripe_types::Object for DeletedPaymentSource { type Id = smol_str::SmolStr; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_person.rs b/generated/stripe_shared/src/deleted_person.rs index 5c31e7795..5c20b9260 100644 --- a/generated/stripe_shared/src/deleted_person.rs +++ b/generated/stripe_shared/src/deleted_person.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedPerson { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::PersonId, } +#[cfg(feature = "min-ser")] +pub struct DeletedPersonBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::PersonId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedPerson { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedPerson>, + builder: DeletedPersonBuilder, + } + + impl Visitor for Place<DeletedPerson> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedPersonBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedPersonBuilder { + type Out = DeletedPerson; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedPerson { + type Builder = DeletedPersonBuilder; + } + + impl FromValueOpt for DeletedPerson { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedPersonBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedPerson { type Id = stripe_shared::PersonId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_plan.rs b/generated/stripe_shared/src/deleted_plan.rs index 0d749aff2..fdc8f8b96 100644 --- a/generated/stripe_shared/src/deleted_plan.rs +++ b/generated/stripe_shared/src/deleted_plan.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedPlan { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::PlanId, } +#[cfg(feature = "min-ser")] +pub struct DeletedPlanBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::PlanId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedPlan { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedPlan>, + builder: DeletedPlanBuilder, + } + + impl Visitor for Place<DeletedPlan> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedPlanBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedPlanBuilder { + type Out = DeletedPlan; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedPlan { + type Builder = DeletedPlanBuilder; + } + + impl FromValueOpt for DeletedPlan { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedPlanBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedPlan { type Id = stripe_shared::PlanId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_product.rs b/generated/stripe_shared/src/deleted_product.rs index 754490d5c..bdbc02349 100644 --- a/generated/stripe_shared/src/deleted_product.rs +++ b/generated/stripe_shared/src/deleted_product.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedProduct { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::ProductId, } +#[cfg(feature = "min-ser")] +pub struct DeletedProductBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::ProductId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedProduct { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedProduct>, + builder: DeletedProductBuilder, + } + + impl Visitor for Place<DeletedProduct> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedProductBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedProductBuilder { + type Out = DeletedProduct; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedProduct { + type Builder = DeletedProductBuilder; + } + + impl FromValueOpt for DeletedProduct { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedProductBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedProduct { type Id = stripe_shared::ProductId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_subscription_item.rs b/generated/stripe_shared/src/deleted_subscription_item.rs index 1fe5b43dd..81fe24dd1 100644 --- a/generated/stripe_shared/src/deleted_subscription_item.rs +++ b/generated/stripe_shared/src/deleted_subscription_item.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedSubscriptionItem { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::SubscriptionItemId, } +#[cfg(feature = "min-ser")] +pub struct DeletedSubscriptionItemBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::SubscriptionItemId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedSubscriptionItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedSubscriptionItem>, + builder: DeletedSubscriptionItemBuilder, + } + + impl Visitor for Place<DeletedSubscriptionItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedSubscriptionItemBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedSubscriptionItemBuilder { + type Out = DeletedSubscriptionItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedSubscriptionItem { + type Builder = DeletedSubscriptionItemBuilder; + } + + impl FromValueOpt for DeletedSubscriptionItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedSubscriptionItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedSubscriptionItem { type Id = stripe_shared::SubscriptionItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_tax_id.rs b/generated/stripe_shared/src/deleted_tax_id.rs index 79bdb8882..fa14cfba3 100644 --- a/generated/stripe_shared/src/deleted_tax_id.rs +++ b/generated/stripe_shared/src/deleted_tax_id.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedTaxId { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::TaxIdId, } +#[cfg(feature = "min-ser")] +pub struct DeletedTaxIdBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::TaxIdId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedTaxId { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedTaxId>, + builder: DeletedTaxIdBuilder, + } + + impl Visitor for Place<DeletedTaxId> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedTaxIdBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedTaxIdBuilder { + type Out = DeletedTaxId; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedTaxId { + type Builder = DeletedTaxIdBuilder; + } + + impl FromValueOpt for DeletedTaxId { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedTaxIdBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedTaxId { type Id = stripe_shared::TaxIdId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/deleted_test_helpers_test_clock.rs b/generated/stripe_shared/src/deleted_test_helpers_test_clock.rs index 748c67122..f42eff122 100644 --- a/generated/stripe_shared/src/deleted_test_helpers_test_clock.rs +++ b/generated/stripe_shared/src/deleted_test_helpers_test_clock.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedTestHelpersTestClock { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::TestHelpersTestClockId, } +#[cfg(feature = "min-ser")] +pub struct DeletedTestHelpersTestClockBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_shared::TestHelpersTestClockId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedTestHelpersTestClock { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedTestHelpersTestClock>, + builder: DeletedTestHelpersTestClockBuilder, + } + + impl Visitor for Place<DeletedTestHelpersTestClock> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedTestHelpersTestClockBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedTestHelpersTestClockBuilder { + type Out = DeletedTestHelpersTestClock; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedTestHelpersTestClock { + type Builder = DeletedTestHelpersTestClockBuilder; + } + + impl FromValueOpt for DeletedTestHelpersTestClock { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedTestHelpersTestClockBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedTestHelpersTestClock { type Id = stripe_shared::TestHelpersTestClockId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/destination_details_unimplemented.rs b/generated/stripe_shared/src/destination_details_unimplemented.rs deleted file mode 100644 index 0c49c86d1..000000000 --- a/generated/stripe_shared/src/destination_details_unimplemented.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct DestinationDetailsUnimplemented {} diff --git a/generated/stripe_shared/src/discount.rs b/generated/stripe_shared/src/discount.rs index 09db8a753..c34da05f6 100644 --- a/generated/stripe_shared/src/discount.rs +++ b/generated/stripe_shared/src/discount.rs @@ -4,7 +4,9 @@ /// Related guide: [Applying discounts to subscriptions](https://stripe.com/docs/billing/subscriptions/discounts). /// /// For more details see <<https://stripe.com/docs/api/discounts/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Discount { /// The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode. /// Will not be present for subscription mode. @@ -30,6 +32,139 @@ pub struct Discount { /// The subscription that this coupon is applied to, if it is applied to a particular subscription. pub subscription: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct DiscountBuilder { + checkout_session: Option<Option<String>>, + coupon: Option<stripe_shared::Coupon>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + end: Option<Option<stripe_types::Timestamp>>, + id: Option<stripe_shared::DiscountId>, + invoice: Option<Option<String>>, + invoice_item: Option<Option<String>>, + promotion_code: Option<Option<stripe_types::Expandable<stripe_shared::PromotionCode>>>, + start: Option<stripe_types::Timestamp>, + subscription: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Discount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Discount>, + builder: DiscountBuilder, + } + + impl Visitor for Place<Discount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DiscountBuilder::deser_default() })) + } + } + + impl MapBuilder for DiscountBuilder { + type Out = Discount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "checkout_session" => Deserialize::begin(&mut self.checkout_session), + "coupon" => Deserialize::begin(&mut self.coupon), + "customer" => Deserialize::begin(&mut self.customer), + "end" => Deserialize::begin(&mut self.end), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "invoice_item" => Deserialize::begin(&mut self.invoice_item), + "promotion_code" => Deserialize::begin(&mut self.promotion_code), + "start" => Deserialize::begin(&mut self.start), + "subscription" => Deserialize::begin(&mut self.subscription), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + checkout_session: Deserialize::default(), + coupon: Deserialize::default(), + customer: Deserialize::default(), + end: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + invoice_item: Deserialize::default(), + promotion_code: Deserialize::default(), + start: Deserialize::default(), + subscription: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let checkout_session = self.checkout_session.take()?; + let coupon = self.coupon.take()?; + let customer = self.customer.take()?; + let end = self.end.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let invoice_item = self.invoice_item.take()?; + let promotion_code = self.promotion_code.take()?; + let start = self.start.take()?; + let subscription = self.subscription.take()?; + + Some(Self::Out { checkout_session, coupon, customer, end, id, invoice, invoice_item, promotion_code, start, subscription }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Discount { + type Builder = DiscountBuilder; + } + + impl FromValueOpt for Discount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DiscountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "checkout_session" => b.checkout_session = Some(FromValueOpt::from_value(v)?), + "coupon" => b.coupon = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "end" => b.end = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "invoice_item" => b.invoice_item = Some(FromValueOpt::from_value(v)?), + "promotion_code" => b.promotion_code = Some(FromValueOpt::from_value(v)?), + "start" => b.start = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Discount { type Id = stripe_shared::DiscountId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/discounts_resource_discount_amount.rs b/generated/stripe_shared/src/discounts_resource_discount_amount.rs index 34eb3dfda..38a3e26ec 100644 --- a/generated/stripe_shared/src/discounts_resource_discount_amount.rs +++ b/generated/stripe_shared/src/discounts_resource_discount_amount.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DiscountsResourceDiscountAmount { /// The amount, in cents (or local equivalent), of the discount. pub amount: i64, /// The discount that was applied to get this discount amount. pub discount: stripe_types::Expandable<stripe_shared::Discount>, } +#[cfg(feature = "min-ser")] +pub struct DiscountsResourceDiscountAmountBuilder { + amount: Option<i64>, + discount: Option<stripe_types::Expandable<stripe_shared::Discount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DiscountsResourceDiscountAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DiscountsResourceDiscountAmount>, + builder: DiscountsResourceDiscountAmountBuilder, + } + + impl Visitor for Place<DiscountsResourceDiscountAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DiscountsResourceDiscountAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for DiscountsResourceDiscountAmountBuilder { + type Out = DiscountsResourceDiscountAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "discount" => Deserialize::begin(&mut self.discount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), discount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let discount = self.discount.take()?; + + Some(Self::Out { amount, discount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DiscountsResourceDiscountAmount { + type Builder = DiscountsResourceDiscountAmountBuilder; + } + + impl FromValueOpt for DiscountsResourceDiscountAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DiscountsResourceDiscountAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "discount" => b.discount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/dispute.rs b/generated/stripe_shared/src/dispute.rs index 20653ecb7..6491af59d 100644 --- a/generated/stripe_shared/src/dispute.rs +++ b/generated/stripe_shared/src/dispute.rs @@ -5,7 +5,9 @@ /// Related guide: [Disputes and fraud](https://stripe.com/docs/disputes) /// /// For more details see <<https://stripe.com/docs/api/disputes/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Dispute { /// Disputed amount. /// Usually the amount of the charge, but it can differ (usually because of currency fluctuation or because only part of the order is disputed). @@ -32,11 +34,9 @@ pub struct Dispute { /// This can be useful for storing additional information about the object in a structured format. pub metadata: std::collections::HashMap<String, String>, /// Network-dependent reason code for the dispute. - #[serde(skip_serializing_if = "Option::is_none")] pub network_reason_code: Option<String>, /// ID of the PaymentIntent that's disputed. pub payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_method_details: Option<stripe_shared::DisputePaymentMethodDetails>, /// Reason given by cardholder for dispute. /// Possible values are `bank_cannot_process`, `check_returned`, `credit_not_processed`, `customer_initiated`, `debit_not_authorized`, `duplicate`, `fraudulent`, `general`, `incorrect_account_details`, `insufficient_funds`, `product_not_received`, `product_unacceptable`, `subscription_canceled`, or `unrecognized`. @@ -46,6 +46,186 @@ pub struct Dispute { /// Possible values are `warning_needs_response`, `warning_under_review`, `warning_closed`, `needs_response`, `under_review`, `won`, or `lost`. pub status: DisputeStatus, } +#[cfg(feature = "min-ser")] +pub struct DisputeBuilder { + amount: Option<i64>, + balance_transactions: Option<Vec<stripe_shared::BalanceTransaction>>, + charge: Option<stripe_types::Expandable<stripe_shared::Charge>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + evidence: Option<stripe_shared::DisputeEvidence>, + evidence_details: Option<stripe_shared::DisputeEvidenceDetails>, + id: Option<stripe_shared::DisputeId>, + is_charge_refundable: Option<bool>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + network_reason_code: Option<Option<String>>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, + payment_method_details: Option<Option<stripe_shared::DisputePaymentMethodDetails>>, + reason: Option<String>, + status: Option<DisputeStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Dispute { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Dispute>, + builder: DisputeBuilder, + } + + impl Visitor for Place<Dispute> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DisputeBuilder::deser_default() })) + } + } + + impl MapBuilder for DisputeBuilder { + type Out = Dispute; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "balance_transactions" => Deserialize::begin(&mut self.balance_transactions), + "charge" => Deserialize::begin(&mut self.charge), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "evidence" => Deserialize::begin(&mut self.evidence), + "evidence_details" => Deserialize::begin(&mut self.evidence_details), + "id" => Deserialize::begin(&mut self.id), + "is_charge_refundable" => Deserialize::begin(&mut self.is_charge_refundable), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "network_reason_code" => Deserialize::begin(&mut self.network_reason_code), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "payment_method_details" => Deserialize::begin(&mut self.payment_method_details), + "reason" => Deserialize::begin(&mut self.reason), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + balance_transactions: Deserialize::default(), + charge: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + evidence: Deserialize::default(), + evidence_details: Deserialize::default(), + id: Deserialize::default(), + is_charge_refundable: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + network_reason_code: Deserialize::default(), + payment_intent: Deserialize::default(), + payment_method_details: Deserialize::default(), + reason: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let balance_transactions = self.balance_transactions.take()?; + let charge = self.charge.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let evidence = self.evidence.take()?; + let evidence_details = self.evidence_details.take()?; + let id = self.id.take()?; + let is_charge_refundable = self.is_charge_refundable.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let network_reason_code = self.network_reason_code.take()?; + let payment_intent = self.payment_intent.take()?; + let payment_method_details = self.payment_method_details.take()?; + let reason = self.reason.take()?; + let status = self.status.take()?; + + Some(Self::Out { + amount, + balance_transactions, + charge, + created, + currency, + evidence, + evidence_details, + id, + is_charge_refundable, + livemode, + metadata, + network_reason_code, + payment_intent, + payment_method_details, + reason, + status, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Dispute { + type Builder = DisputeBuilder; + } + + impl FromValueOpt for Dispute { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DisputeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "balance_transactions" => b.balance_transactions = Some(FromValueOpt::from_value(v)?), + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "evidence" => b.evidence = Some(FromValueOpt::from_value(v)?), + "evidence_details" => b.evidence_details = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "is_charge_refundable" => b.is_charge_refundable = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "network_reason_code" => b.network_reason_code = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "payment_method_details" => b.payment_method_details = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Current status of dispute. /// Possible values are `warning_needs_response`, `warning_under_review`, `warning_closed`, `needs_response`, `under_review`, `won`, or `lost`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -115,6 +295,24 @@ impl<'de> serde::Deserialize<'de> for DisputeStatus { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for DisputeStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for DisputeStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<DisputeStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DisputeStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(DisputeStatus); impl stripe_types::Object for Dispute { type Id = stripe_shared::DisputeId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/dispute_evidence.rs b/generated/stripe_shared/src/dispute_evidence.rs index 9437e4a8f..68aa9ff57 100644 --- a/generated/stripe_shared/src/dispute_evidence.rs +++ b/generated/stripe_shared/src/dispute_evidence.rs @@ -1,5 +1,7 @@ /// For more details see <<https://stripe.com/docs/api/disputes/evidence_object>>. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DisputeEvidence { /// Any server or activity logs showing proof that the customer accessed or downloaded the purchased digital product. /// This information should include IP addresses, corresponding timestamps, and any detailed recorded activity. @@ -65,3 +67,249 @@ pub struct DisputeEvidence { /// Any additional evidence or statements. pub uncategorized_text: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct DisputeEvidenceBuilder { + access_activity_log: Option<Option<String>>, + billing_address: Option<Option<String>>, + cancellation_policy: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + cancellation_policy_disclosure: Option<Option<String>>, + cancellation_rebuttal: Option<Option<String>>, + customer_communication: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + customer_email_address: Option<Option<String>>, + customer_name: Option<Option<String>>, + customer_purchase_ip: Option<Option<String>>, + customer_signature: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + duplicate_charge_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + duplicate_charge_explanation: Option<Option<String>>, + duplicate_charge_id: Option<Option<String>>, + product_description: Option<Option<String>>, + receipt: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + refund_policy: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + refund_policy_disclosure: Option<Option<String>>, + refund_refusal_explanation: Option<Option<String>>, + service_date: Option<Option<String>>, + service_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + shipping_address: Option<Option<String>>, + shipping_carrier: Option<Option<String>>, + shipping_date: Option<Option<String>>, + shipping_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + shipping_tracking_number: Option<Option<String>>, + uncategorized_file: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + uncategorized_text: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DisputeEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DisputeEvidence>, + builder: DisputeEvidenceBuilder, + } + + impl Visitor for Place<DisputeEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DisputeEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for DisputeEvidenceBuilder { + type Out = DisputeEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "access_activity_log" => Deserialize::begin(&mut self.access_activity_log), + "billing_address" => Deserialize::begin(&mut self.billing_address), + "cancellation_policy" => Deserialize::begin(&mut self.cancellation_policy), + "cancellation_policy_disclosure" => Deserialize::begin(&mut self.cancellation_policy_disclosure), + "cancellation_rebuttal" => Deserialize::begin(&mut self.cancellation_rebuttal), + "customer_communication" => Deserialize::begin(&mut self.customer_communication), + "customer_email_address" => Deserialize::begin(&mut self.customer_email_address), + "customer_name" => Deserialize::begin(&mut self.customer_name), + "customer_purchase_ip" => Deserialize::begin(&mut self.customer_purchase_ip), + "customer_signature" => Deserialize::begin(&mut self.customer_signature), + "duplicate_charge_documentation" => Deserialize::begin(&mut self.duplicate_charge_documentation), + "duplicate_charge_explanation" => Deserialize::begin(&mut self.duplicate_charge_explanation), + "duplicate_charge_id" => Deserialize::begin(&mut self.duplicate_charge_id), + "product_description" => Deserialize::begin(&mut self.product_description), + "receipt" => Deserialize::begin(&mut self.receipt), + "refund_policy" => Deserialize::begin(&mut self.refund_policy), + "refund_policy_disclosure" => Deserialize::begin(&mut self.refund_policy_disclosure), + "refund_refusal_explanation" => Deserialize::begin(&mut self.refund_refusal_explanation), + "service_date" => Deserialize::begin(&mut self.service_date), + "service_documentation" => Deserialize::begin(&mut self.service_documentation), + "shipping_address" => Deserialize::begin(&mut self.shipping_address), + "shipping_carrier" => Deserialize::begin(&mut self.shipping_carrier), + "shipping_date" => Deserialize::begin(&mut self.shipping_date), + "shipping_documentation" => Deserialize::begin(&mut self.shipping_documentation), + "shipping_tracking_number" => Deserialize::begin(&mut self.shipping_tracking_number), + "uncategorized_file" => Deserialize::begin(&mut self.uncategorized_file), + "uncategorized_text" => Deserialize::begin(&mut self.uncategorized_text), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + access_activity_log: Deserialize::default(), + billing_address: Deserialize::default(), + cancellation_policy: Deserialize::default(), + cancellation_policy_disclosure: Deserialize::default(), + cancellation_rebuttal: Deserialize::default(), + customer_communication: Deserialize::default(), + customer_email_address: Deserialize::default(), + customer_name: Deserialize::default(), + customer_purchase_ip: Deserialize::default(), + customer_signature: Deserialize::default(), + duplicate_charge_documentation: Deserialize::default(), + duplicate_charge_explanation: Deserialize::default(), + duplicate_charge_id: Deserialize::default(), + product_description: Deserialize::default(), + receipt: Deserialize::default(), + refund_policy: Deserialize::default(), + refund_policy_disclosure: Deserialize::default(), + refund_refusal_explanation: Deserialize::default(), + service_date: Deserialize::default(), + service_documentation: Deserialize::default(), + shipping_address: Deserialize::default(), + shipping_carrier: Deserialize::default(), + shipping_date: Deserialize::default(), + shipping_documentation: Deserialize::default(), + shipping_tracking_number: Deserialize::default(), + uncategorized_file: Deserialize::default(), + uncategorized_text: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let access_activity_log = self.access_activity_log.take()?; + let billing_address = self.billing_address.take()?; + let cancellation_policy = self.cancellation_policy.take()?; + let cancellation_policy_disclosure = self.cancellation_policy_disclosure.take()?; + let cancellation_rebuttal = self.cancellation_rebuttal.take()?; + let customer_communication = self.customer_communication.take()?; + let customer_email_address = self.customer_email_address.take()?; + let customer_name = self.customer_name.take()?; + let customer_purchase_ip = self.customer_purchase_ip.take()?; + let customer_signature = self.customer_signature.take()?; + let duplicate_charge_documentation = self.duplicate_charge_documentation.take()?; + let duplicate_charge_explanation = self.duplicate_charge_explanation.take()?; + let duplicate_charge_id = self.duplicate_charge_id.take()?; + let product_description = self.product_description.take()?; + let receipt = self.receipt.take()?; + let refund_policy = self.refund_policy.take()?; + let refund_policy_disclosure = self.refund_policy_disclosure.take()?; + let refund_refusal_explanation = self.refund_refusal_explanation.take()?; + let service_date = self.service_date.take()?; + let service_documentation = self.service_documentation.take()?; + let shipping_address = self.shipping_address.take()?; + let shipping_carrier = self.shipping_carrier.take()?; + let shipping_date = self.shipping_date.take()?; + let shipping_documentation = self.shipping_documentation.take()?; + let shipping_tracking_number = self.shipping_tracking_number.take()?; + let uncategorized_file = self.uncategorized_file.take()?; + let uncategorized_text = self.uncategorized_text.take()?; + + Some(Self::Out { + access_activity_log, + billing_address, + cancellation_policy, + cancellation_policy_disclosure, + cancellation_rebuttal, + customer_communication, + customer_email_address, + customer_name, + customer_purchase_ip, + customer_signature, + duplicate_charge_documentation, + duplicate_charge_explanation, + duplicate_charge_id, + product_description, + receipt, + refund_policy, + refund_policy_disclosure, + refund_refusal_explanation, + service_date, + service_documentation, + shipping_address, + shipping_carrier, + shipping_date, + shipping_documentation, + shipping_tracking_number, + uncategorized_file, + uncategorized_text, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DisputeEvidence { + type Builder = DisputeEvidenceBuilder; + } + + impl FromValueOpt for DisputeEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DisputeEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "access_activity_log" => b.access_activity_log = Some(FromValueOpt::from_value(v)?), + "billing_address" => b.billing_address = Some(FromValueOpt::from_value(v)?), + "cancellation_policy" => b.cancellation_policy = Some(FromValueOpt::from_value(v)?), + "cancellation_policy_disclosure" => b.cancellation_policy_disclosure = Some(FromValueOpt::from_value(v)?), + "cancellation_rebuttal" => b.cancellation_rebuttal = Some(FromValueOpt::from_value(v)?), + "customer_communication" => b.customer_communication = Some(FromValueOpt::from_value(v)?), + "customer_email_address" => b.customer_email_address = Some(FromValueOpt::from_value(v)?), + "customer_name" => b.customer_name = Some(FromValueOpt::from_value(v)?), + "customer_purchase_ip" => b.customer_purchase_ip = Some(FromValueOpt::from_value(v)?), + "customer_signature" => b.customer_signature = Some(FromValueOpt::from_value(v)?), + "duplicate_charge_documentation" => b.duplicate_charge_documentation = Some(FromValueOpt::from_value(v)?), + "duplicate_charge_explanation" => b.duplicate_charge_explanation = Some(FromValueOpt::from_value(v)?), + "duplicate_charge_id" => b.duplicate_charge_id = Some(FromValueOpt::from_value(v)?), + "product_description" => b.product_description = Some(FromValueOpt::from_value(v)?), + "receipt" => b.receipt = Some(FromValueOpt::from_value(v)?), + "refund_policy" => b.refund_policy = Some(FromValueOpt::from_value(v)?), + "refund_policy_disclosure" => b.refund_policy_disclosure = Some(FromValueOpt::from_value(v)?), + "refund_refusal_explanation" => b.refund_refusal_explanation = Some(FromValueOpt::from_value(v)?), + "service_date" => b.service_date = Some(FromValueOpt::from_value(v)?), + "service_documentation" => b.service_documentation = Some(FromValueOpt::from_value(v)?), + "shipping_address" => b.shipping_address = Some(FromValueOpt::from_value(v)?), + "shipping_carrier" => b.shipping_carrier = Some(FromValueOpt::from_value(v)?), + "shipping_date" => b.shipping_date = Some(FromValueOpt::from_value(v)?), + "shipping_documentation" => b.shipping_documentation = Some(FromValueOpt::from_value(v)?), + "shipping_tracking_number" => b.shipping_tracking_number = Some(FromValueOpt::from_value(v)?), + "uncategorized_file" => b.uncategorized_file = Some(FromValueOpt::from_value(v)?), + "uncategorized_text" => b.uncategorized_text = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/dispute_evidence_details.rs b/generated/stripe_shared/src/dispute_evidence_details.rs index cef52563c..2e1adcae0 100644 --- a/generated/stripe_shared/src/dispute_evidence_details.rs +++ b/generated/stripe_shared/src/dispute_evidence_details.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DisputeEvidenceDetails { /// Date by which evidence must be submitted in order to successfully challenge dispute. /// Will be 0 if the customer's bank or credit card company doesn't allow a response for this particular dispute. @@ -12,3 +14,101 @@ pub struct DisputeEvidenceDetails { /// The number of times evidence has been submitted. Typically, you may only submit evidence once. pub submission_count: u64, } +#[cfg(feature = "min-ser")] +pub struct DisputeEvidenceDetailsBuilder { + due_by: Option<Option<stripe_types::Timestamp>>, + has_evidence: Option<bool>, + past_due: Option<bool>, + submission_count: Option<u64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DisputeEvidenceDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DisputeEvidenceDetails>, + builder: DisputeEvidenceDetailsBuilder, + } + + impl Visitor for Place<DisputeEvidenceDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DisputeEvidenceDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for DisputeEvidenceDetailsBuilder { + type Out = DisputeEvidenceDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "due_by" => Deserialize::begin(&mut self.due_by), + "has_evidence" => Deserialize::begin(&mut self.has_evidence), + "past_due" => Deserialize::begin(&mut self.past_due), + "submission_count" => Deserialize::begin(&mut self.submission_count), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { due_by: Deserialize::default(), has_evidence: Deserialize::default(), past_due: Deserialize::default(), submission_count: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let due_by = self.due_by.take()?; + let has_evidence = self.has_evidence.take()?; + let past_due = self.past_due.take()?; + let submission_count = self.submission_count.take()?; + + Some(Self::Out { due_by, has_evidence, past_due, submission_count }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DisputeEvidenceDetails { + type Builder = DisputeEvidenceDetailsBuilder; + } + + impl FromValueOpt for DisputeEvidenceDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DisputeEvidenceDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "due_by" => b.due_by = Some(FromValueOpt::from_value(v)?), + "has_evidence" => b.has_evidence = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "submission_count" => b.submission_count = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/dispute_payment_method_details.rs b/generated/stripe_shared/src/dispute_payment_method_details.rs index f3fd5f59b..a50a4b66b 100644 --- a/generated/stripe_shared/src/dispute_payment_method_details.rs +++ b/generated/stripe_shared/src/dispute_payment_method_details.rs @@ -1,11 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DisputePaymentMethodDetails { /// Card specific dispute details. pub card: Option<stripe_shared::DisputePaymentMethodDetailsCard>, /// Payment method type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: DisputePaymentMethodDetailsType, } +#[cfg(feature = "min-ser")] +pub struct DisputePaymentMethodDetailsBuilder { + card: Option<Option<stripe_shared::DisputePaymentMethodDetailsCard>>, + type_: Option<DisputePaymentMethodDetailsType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DisputePaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DisputePaymentMethodDetails>, + builder: DisputePaymentMethodDetailsBuilder, + } + + impl Visitor for Place<DisputePaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DisputePaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for DisputePaymentMethodDetailsBuilder { + type Out = DisputePaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "card" => Deserialize::begin(&mut self.card), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { card: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let card = self.card.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { card, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DisputePaymentMethodDetails { + type Builder = DisputePaymentMethodDetailsBuilder; + } + + impl FromValueOpt for DisputePaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DisputePaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Payment method type. #[derive(Copy, Clone, Eq, PartialEq)] pub enum DisputePaymentMethodDetailsType { @@ -53,8 +145,24 @@ impl<'de> serde::Deserialize<'de> for DisputePaymentMethodDetailsType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for DisputePaymentMethodDetailsType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for DisputePaymentMethodDetailsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for DisputePaymentMethodDetailsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<DisputePaymentMethodDetailsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DisputePaymentMethodDetailsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(DisputePaymentMethodDetailsType); diff --git a/generated/stripe_shared/src/dispute_payment_method_details_card.rs b/generated/stripe_shared/src/dispute_payment_method_details_card.rs index f44c8a755..df379af0f 100644 --- a/generated/stripe_shared/src/dispute_payment_method_details_card.rs +++ b/generated/stripe_shared/src/dispute_payment_method_details_card.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DisputePaymentMethodDetailsCard { /// Card brand. /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. @@ -7,3 +9,93 @@ pub struct DisputePaymentMethodDetailsCard { /// The [Network code map](https://stripe.com/docs/disputes/categories#network-code-map) lists all available dispute reason codes by network. pub network_reason_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct DisputePaymentMethodDetailsCardBuilder { + brand: Option<String>, + network_reason_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DisputePaymentMethodDetailsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DisputePaymentMethodDetailsCard>, + builder: DisputePaymentMethodDetailsCardBuilder, + } + + impl Visitor for Place<DisputePaymentMethodDetailsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DisputePaymentMethodDetailsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for DisputePaymentMethodDetailsCardBuilder { + type Out = DisputePaymentMethodDetailsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "brand" => Deserialize::begin(&mut self.brand), + "network_reason_code" => Deserialize::begin(&mut self.network_reason_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { brand: Deserialize::default(), network_reason_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let brand = self.brand.take()?; + let network_reason_code = self.network_reason_code.take()?; + + Some(Self::Out { brand, network_reason_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DisputePaymentMethodDetailsCard { + type Builder = DisputePaymentMethodDetailsCardBuilder; + } + + impl FromValueOpt for DisputePaymentMethodDetailsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DisputePaymentMethodDetailsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "network_reason_code" => b.network_reason_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/email_sent.rs b/generated/stripe_shared/src/email_sent.rs index da23740ac..c0cdfc479 100644 --- a/generated/stripe_shared/src/email_sent.rs +++ b/generated/stripe_shared/src/email_sent.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct EmailSent { /// The timestamp when the email was sent. pub email_sent_at: stripe_types::Timestamp, /// The recipient's email address. pub email_sent_to: String, } +#[cfg(feature = "min-ser")] +pub struct EmailSentBuilder { + email_sent_at: Option<stripe_types::Timestamp>, + email_sent_to: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for EmailSent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<EmailSent>, + builder: EmailSentBuilder, + } + + impl Visitor for Place<EmailSent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: EmailSentBuilder::deser_default() })) + } + } + + impl MapBuilder for EmailSentBuilder { + type Out = EmailSent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "email_sent_at" => Deserialize::begin(&mut self.email_sent_at), + "email_sent_to" => Deserialize::begin(&mut self.email_sent_to), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { email_sent_at: Deserialize::default(), email_sent_to: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let email_sent_at = self.email_sent_at.take()?; + let email_sent_to = self.email_sent_to.take()?; + + Some(Self::Out { email_sent_at, email_sent_to }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for EmailSent { + type Builder = EmailSentBuilder; + } + + impl FromValueOpt for EmailSent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = EmailSentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "email_sent_at" => b.email_sent_at = Some(FromValueOpt::from_value(v)?), + "email_sent_to" => b.email_sent_to = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/error.rs b/generated/stripe_shared/src/error.rs index e8e568b45..8d6e2be93 100644 --- a/generated/stripe_shared/src/error.rs +++ b/generated/stripe_shared/src/error.rs @@ -1,5 +1,93 @@ /// An error response from the Stripe API -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Error { pub error: Box<stripe_shared::ApiErrors>, } +#[cfg(feature = "min-ser")] +pub struct ErrorBuilder { + error: Option<Box<stripe_shared::ApiErrors>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Error { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Error>, + builder: ErrorBuilder, + } + + impl Visitor for Place<Error> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ErrorBuilder::deser_default() })) + } + } + + impl MapBuilder for ErrorBuilder { + type Out = Error; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "error" => Deserialize::begin(&mut self.error), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { error: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let error = self.error.take()?; + + Some(Self::Out { error }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Error { + type Builder = ErrorBuilder; + } + + impl FromValueOpt for Error { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ErrorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "error" => b.error = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/event.rs b/generated/stripe_shared/src/event.rs index 492f51a52..8e7f63f65 100644 --- a/generated/stripe_shared/src/event.rs +++ b/generated/stripe_shared/src/event.rs @@ -30,10 +30,11 @@ /// for 30 days. /// /// For more details see <<https://stripe.com/docs/api/events/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Event { /// The connected account that originates the event. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option<String>, /// The Stripe API version used to render `data`. /// This property is populated only for events on or after October 31, 2014. @@ -50,9 +51,137 @@ pub struct Event { /// Information on the API request that triggers the event. pub request: Option<stripe_shared::NotificationEventRequest>, /// Description of the event (for example, `invoice.created` or `charge.refunded`). - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: EventType, } +#[cfg(feature = "min-ser")] +pub struct EventBuilder { + account: Option<Option<String>>, + api_version: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + data: Option<stripe_shared::NotificationEventData>, + id: Option<stripe_shared::EventId>, + livemode: Option<bool>, + pending_webhooks: Option<i64>, + request: Option<Option<stripe_shared::NotificationEventRequest>>, + type_: Option<EventType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Event { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Event>, + builder: EventBuilder, + } + + impl Visitor for Place<Event> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: EventBuilder::deser_default() })) + } + } + + impl MapBuilder for EventBuilder { + type Out = Event; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "api_version" => Deserialize::begin(&mut self.api_version), + "created" => Deserialize::begin(&mut self.created), + "data" => Deserialize::begin(&mut self.data), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "pending_webhooks" => Deserialize::begin(&mut self.pending_webhooks), + "request" => Deserialize::begin(&mut self.request), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + api_version: Deserialize::default(), + created: Deserialize::default(), + data: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + pending_webhooks: Deserialize::default(), + request: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let api_version = self.api_version.take()?; + let created = self.created.take()?; + let data = self.data.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let pending_webhooks = self.pending_webhooks.take()?; + let request = self.request.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { account, api_version, created, data, id, livemode, pending_webhooks, request, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Event { + type Builder = EventBuilder; + } + + impl FromValueOpt for Event { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = EventBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "api_version" => b.api_version = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "data" => b.data = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "pending_webhooks" => b.pending_webhooks = Some(FromValueOpt::from_value(v)?), + "request" => b.request = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Description of the event (for example, `invoice.created` or `charge.refunded`). #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -89,13 +218,6 @@ pub enum EventType { CheckoutSessionAsyncPaymentSucceeded, CheckoutSessionCompleted, CheckoutSessionExpired, - ClimateOrderCanceled, - ClimateOrderCreated, - ClimateOrderDelayed, - ClimateOrderDelivered, - ClimateOrderProductSubstituted, - ClimateProductCreated, - ClimateProductPricingUpdated, CouponCreated, CouponDeleted, CouponUpdated, @@ -130,7 +252,6 @@ pub enum EventType { FinancialConnectionsAccountDisconnected, FinancialConnectionsAccountReactivated, FinancialConnectionsAccountRefreshedBalance, - FinancialConnectionsAccountRefreshedTransactions, IdentityVerificationSessionCanceled, IdentityVerificationSessionCreated, IdentityVerificationSessionProcessing, @@ -321,13 +442,6 @@ impl EventType { CheckoutSessionAsyncPaymentSucceeded => "checkout.session.async_payment_succeeded", CheckoutSessionCompleted => "checkout.session.completed", CheckoutSessionExpired => "checkout.session.expired", - ClimateOrderCanceled => "climate.order.canceled", - ClimateOrderCreated => "climate.order.created", - ClimateOrderDelayed => "climate.order.delayed", - ClimateOrderDelivered => "climate.order.delivered", - ClimateOrderProductSubstituted => "climate.order.product_substituted", - ClimateProductCreated => "climate.product.created", - ClimateProductPricingUpdated => "climate.product.pricing_updated", CouponCreated => "coupon.created", CouponDeleted => "coupon.deleted", CouponUpdated => "coupon.updated", @@ -346,12 +460,8 @@ impl EventType { CustomerSubscriptionCreated => "customer.subscription.created", CustomerSubscriptionDeleted => "customer.subscription.deleted", CustomerSubscriptionPaused => "customer.subscription.paused", - CustomerSubscriptionPendingUpdateApplied => { - "customer.subscription.pending_update_applied" - } - CustomerSubscriptionPendingUpdateExpired => { - "customer.subscription.pending_update_expired" - } + CustomerSubscriptionPendingUpdateApplied => "customer.subscription.pending_update_applied", + CustomerSubscriptionPendingUpdateExpired => "customer.subscription.pending_update_expired", CustomerSubscriptionResumed => "customer.subscription.resumed", CustomerSubscriptionTrialWillEnd => "customer.subscription.trial_will_end", CustomerSubscriptionUpdated => "customer.subscription.updated", @@ -365,19 +475,12 @@ impl EventType { FinancialConnectionsAccountDeactivated => "financial_connections.account.deactivated", FinancialConnectionsAccountDisconnected => "financial_connections.account.disconnected", FinancialConnectionsAccountReactivated => "financial_connections.account.reactivated", - FinancialConnectionsAccountRefreshedBalance => { - "financial_connections.account.refreshed_balance" - } - FinancialConnectionsAccountRefreshedTransactions => { - "financial_connections.account.refreshed_transactions" - } + FinancialConnectionsAccountRefreshedBalance => "financial_connections.account.refreshed_balance", IdentityVerificationSessionCanceled => "identity.verification_session.canceled", IdentityVerificationSessionCreated => "identity.verification_session.created", IdentityVerificationSessionProcessing => "identity.verification_session.processing", IdentityVerificationSessionRedacted => "identity.verification_session.redacted", - IdentityVerificationSessionRequiresInput => { - "identity.verification_session.requires_input" - } + IdentityVerificationSessionRequiresInput => "identity.verification_session.requires_input", IdentityVerificationSessionVerified => "identity.verification_session.verified", InvoiceCreated => "invoice.created", InvoiceDeleted => "invoice.deleted", @@ -500,31 +603,23 @@ impl EventType { TreasuryCreditReversalPosted => "treasury.credit_reversal.posted", TreasuryDebitReversalCompleted => "treasury.debit_reversal.completed", TreasuryDebitReversalCreated => "treasury.debit_reversal.created", - TreasuryDebitReversalInitialCreditGranted => { - "treasury.debit_reversal.initial_credit_granted" - } + TreasuryDebitReversalInitialCreditGranted => "treasury.debit_reversal.initial_credit_granted", TreasuryFinancialAccountClosed => "treasury.financial_account.closed", TreasuryFinancialAccountCreated => "treasury.financial_account.created", - TreasuryFinancialAccountFeaturesStatusUpdated => { - "treasury.financial_account.features_status_updated" - } + TreasuryFinancialAccountFeaturesStatusUpdated => "treasury.financial_account.features_status_updated", TreasuryInboundTransferCanceled => "treasury.inbound_transfer.canceled", TreasuryInboundTransferCreated => "treasury.inbound_transfer.created", TreasuryInboundTransferFailed => "treasury.inbound_transfer.failed", TreasuryInboundTransferSucceeded => "treasury.inbound_transfer.succeeded", TreasuryOutboundPaymentCanceled => "treasury.outbound_payment.canceled", TreasuryOutboundPaymentCreated => "treasury.outbound_payment.created", - TreasuryOutboundPaymentExpectedArrivalDateUpdated => { - "treasury.outbound_payment.expected_arrival_date_updated" - } + TreasuryOutboundPaymentExpectedArrivalDateUpdated => "treasury.outbound_payment.expected_arrival_date_updated", TreasuryOutboundPaymentFailed => "treasury.outbound_payment.failed", TreasuryOutboundPaymentPosted => "treasury.outbound_payment.posted", TreasuryOutboundPaymentReturned => "treasury.outbound_payment.returned", TreasuryOutboundTransferCanceled => "treasury.outbound_transfer.canceled", TreasuryOutboundTransferCreated => "treasury.outbound_transfer.created", - TreasuryOutboundTransferExpectedArrivalDateUpdated => { - "treasury.outbound_transfer.expected_arrival_date_updated" - } + TreasuryOutboundTransferExpectedArrivalDateUpdated => "treasury.outbound_transfer.expected_arrival_date_updated", TreasuryOutboundTransferFailed => "treasury.outbound_transfer.failed", TreasuryOutboundTransferPosted => "treasury.outbound_transfer.posted", TreasuryOutboundTransferReturned => "treasury.outbound_transfer.returned", @@ -574,13 +669,6 @@ impl std::str::FromStr for EventType { "checkout.session.async_payment_succeeded" => Ok(CheckoutSessionAsyncPaymentSucceeded), "checkout.session.completed" => Ok(CheckoutSessionCompleted), "checkout.session.expired" => Ok(CheckoutSessionExpired), - "climate.order.canceled" => Ok(ClimateOrderCanceled), - "climate.order.created" => Ok(ClimateOrderCreated), - "climate.order.delayed" => Ok(ClimateOrderDelayed), - "climate.order.delivered" => Ok(ClimateOrderDelivered), - "climate.order.product_substituted" => Ok(ClimateOrderProductSubstituted), - "climate.product.created" => Ok(ClimateProductCreated), - "climate.product.pricing_updated" => Ok(ClimateProductPricingUpdated), "coupon.created" => Ok(CouponCreated), "coupon.deleted" => Ok(CouponDeleted), "coupon.updated" => Ok(CouponUpdated), @@ -599,12 +687,8 @@ impl std::str::FromStr for EventType { "customer.subscription.created" => Ok(CustomerSubscriptionCreated), "customer.subscription.deleted" => Ok(CustomerSubscriptionDeleted), "customer.subscription.paused" => Ok(CustomerSubscriptionPaused), - "customer.subscription.pending_update_applied" => { - Ok(CustomerSubscriptionPendingUpdateApplied) - } - "customer.subscription.pending_update_expired" => { - Ok(CustomerSubscriptionPendingUpdateExpired) - } + "customer.subscription.pending_update_applied" => Ok(CustomerSubscriptionPendingUpdateApplied), + "customer.subscription.pending_update_expired" => Ok(CustomerSubscriptionPendingUpdateExpired), "customer.subscription.resumed" => Ok(CustomerSubscriptionResumed), "customer.subscription.trial_will_end" => Ok(CustomerSubscriptionTrialWillEnd), "customer.subscription.updated" => Ok(CustomerSubscriptionUpdated), @@ -612,33 +696,18 @@ impl std::str::FromStr for EventType { "customer.tax_id.deleted" => Ok(CustomerTaxIdDeleted), "customer.tax_id.updated" => Ok(CustomerTaxIdUpdated), "customer.updated" => Ok(CustomerUpdated), - "customer_cash_balance_transaction.created" => { - Ok(CustomerCashBalanceTransactionCreated) - } + "customer_cash_balance_transaction.created" => Ok(CustomerCashBalanceTransactionCreated), "file.created" => Ok(FileCreated), "financial_connections.account.created" => Ok(FinancialConnectionsAccountCreated), - "financial_connections.account.deactivated" => { - Ok(FinancialConnectionsAccountDeactivated) - } - "financial_connections.account.disconnected" => { - Ok(FinancialConnectionsAccountDisconnected) - } - "financial_connections.account.reactivated" => { - Ok(FinancialConnectionsAccountReactivated) - } - "financial_connections.account.refreshed_balance" => { - Ok(FinancialConnectionsAccountRefreshedBalance) - } - "financial_connections.account.refreshed_transactions" => { - Ok(FinancialConnectionsAccountRefreshedTransactions) - } + "financial_connections.account.deactivated" => Ok(FinancialConnectionsAccountDeactivated), + "financial_connections.account.disconnected" => Ok(FinancialConnectionsAccountDisconnected), + "financial_connections.account.reactivated" => Ok(FinancialConnectionsAccountReactivated), + "financial_connections.account.refreshed_balance" => Ok(FinancialConnectionsAccountRefreshedBalance), "identity.verification_session.canceled" => Ok(IdentityVerificationSessionCanceled), "identity.verification_session.created" => Ok(IdentityVerificationSessionCreated), "identity.verification_session.processing" => Ok(IdentityVerificationSessionProcessing), "identity.verification_session.redacted" => Ok(IdentityVerificationSessionRedacted), - "identity.verification_session.requires_input" => { - Ok(IdentityVerificationSessionRequiresInput) - } + "identity.verification_session.requires_input" => Ok(IdentityVerificationSessionRequiresInput), "identity.verification_session.verified" => Ok(IdentityVerificationSessionVerified), "invoice.created" => Ok(InvoiceCreated), "invoice.deleted" => Ok(InvoiceDeleted), @@ -761,31 +830,23 @@ impl std::str::FromStr for EventType { "treasury.credit_reversal.posted" => Ok(TreasuryCreditReversalPosted), "treasury.debit_reversal.completed" => Ok(TreasuryDebitReversalCompleted), "treasury.debit_reversal.created" => Ok(TreasuryDebitReversalCreated), - "treasury.debit_reversal.initial_credit_granted" => { - Ok(TreasuryDebitReversalInitialCreditGranted) - } + "treasury.debit_reversal.initial_credit_granted" => Ok(TreasuryDebitReversalInitialCreditGranted), "treasury.financial_account.closed" => Ok(TreasuryFinancialAccountClosed), "treasury.financial_account.created" => Ok(TreasuryFinancialAccountCreated), - "treasury.financial_account.features_status_updated" => { - Ok(TreasuryFinancialAccountFeaturesStatusUpdated) - } + "treasury.financial_account.features_status_updated" => Ok(TreasuryFinancialAccountFeaturesStatusUpdated), "treasury.inbound_transfer.canceled" => Ok(TreasuryInboundTransferCanceled), "treasury.inbound_transfer.created" => Ok(TreasuryInboundTransferCreated), "treasury.inbound_transfer.failed" => Ok(TreasuryInboundTransferFailed), "treasury.inbound_transfer.succeeded" => Ok(TreasuryInboundTransferSucceeded), "treasury.outbound_payment.canceled" => Ok(TreasuryOutboundPaymentCanceled), "treasury.outbound_payment.created" => Ok(TreasuryOutboundPaymentCreated), - "treasury.outbound_payment.expected_arrival_date_updated" => { - Ok(TreasuryOutboundPaymentExpectedArrivalDateUpdated) - } + "treasury.outbound_payment.expected_arrival_date_updated" => Ok(TreasuryOutboundPaymentExpectedArrivalDateUpdated), "treasury.outbound_payment.failed" => Ok(TreasuryOutboundPaymentFailed), "treasury.outbound_payment.posted" => Ok(TreasuryOutboundPaymentPosted), "treasury.outbound_payment.returned" => Ok(TreasuryOutboundPaymentReturned), "treasury.outbound_transfer.canceled" => Ok(TreasuryOutboundTransferCanceled), "treasury.outbound_transfer.created" => Ok(TreasuryOutboundTransferCreated), - "treasury.outbound_transfer.expected_arrival_date_updated" => { - Ok(TreasuryOutboundTransferExpectedArrivalDateUpdated) - } + "treasury.outbound_transfer.expected_arrival_date_updated" => Ok(TreasuryOutboundTransferExpectedArrivalDateUpdated), "treasury.outbound_transfer.failed" => Ok(TreasuryOutboundTransferFailed), "treasury.outbound_transfer.posted" => Ok(TreasuryOutboundTransferPosted), "treasury.outbound_transfer.returned" => Ok(TreasuryOutboundTransferReturned), @@ -820,9 +881,27 @@ impl<'de> serde::Deserialize<'de> for EventType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(EventType::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for EventType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<EventType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(EventType::from_str(s).unwrap_or(EventType::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(EventType); impl stripe_types::Object for Event { type Id = stripe_shared::EventId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/external_account.rs b/generated/stripe_shared/src/external_account.rs index 60ea6a327..db461915c 100644 --- a/generated/stripe_shared/src/external_account.rs +++ b/generated/stripe_shared/src/external_account.rs @@ -1,12 +1,99 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum ExternalAccount { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct ExternalAccountBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<ExternalAccount>, + builder: ExternalAccountBuilder, + } + + impl Deserialize for ExternalAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<ExternalAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for ExternalAccountBuilder { + type Out = ExternalAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + ExternalAccount::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for ExternalAccount { + type Builder = ExternalAccountBuilder; + } + impl ExternalAccount { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for ExternalAccount { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + impl stripe_types::Object for ExternalAccount { type Id = smol_str::SmolStr; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/external_account_requirements.rs b/generated/stripe_shared/src/external_account_requirements.rs index 2cc4aa592..f3c5569fe 100644 --- a/generated/stripe_shared/src/external_account_requirements.rs +++ b/generated/stripe_shared/src/external_account_requirements.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ExternalAccountRequirements { /// Fields that need to be collected to keep the external account enabled. /// If not collected by `current_deadline`, these fields appear in `past_due` as well, and the account is disabled. @@ -13,3 +15,101 @@ pub struct ExternalAccountRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Option<Vec<String>>, } +#[cfg(feature = "min-ser")] +pub struct ExternalAccountRequirementsBuilder { + currently_due: Option<Option<Vec<String>>>, + errors: Option<Option<Vec<stripe_shared::AccountRequirementsError>>>, + past_due: Option<Option<Vec<String>>>, + pending_verification: Option<Option<Vec<String>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ExternalAccountRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ExternalAccountRequirements>, + builder: ExternalAccountRequirementsBuilder, + } + + impl Visitor for Place<ExternalAccountRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ExternalAccountRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for ExternalAccountRequirementsBuilder { + type Out = ExternalAccountRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "currently_due" => Deserialize::begin(&mut self.currently_due), + "errors" => Deserialize::begin(&mut self.errors), + "past_due" => Deserialize::begin(&mut self.past_due), + "pending_verification" => Deserialize::begin(&mut self.pending_verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { currently_due: Deserialize::default(), errors: Deserialize::default(), past_due: Deserialize::default(), pending_verification: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let currently_due = self.currently_due.take()?; + let errors = self.errors.take()?; + let past_due = self.past_due.take()?; + let pending_verification = self.pending_verification.take()?; + + Some(Self::Out { currently_due, errors, past_due, pending_verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ExternalAccountRequirements { + type Builder = ExternalAccountRequirementsBuilder; + } + + impl FromValueOpt for ExternalAccountRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ExternalAccountRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "currently_due" => b.currently_due = Some(FromValueOpt::from_value(v)?), + "errors" => b.errors = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "pending_verification" => b.pending_verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/fee.rs b/generated/stripe_shared/src/fee.rs index 203adf736..3f290c530 100644 --- a/generated/stripe_shared/src/fee.rs +++ b/generated/stripe_shared/src/fee.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Fee { /// Amount of the fee, in cents. pub amount: i64, @@ -10,6 +12,108 @@ pub struct Fee { /// An arbitrary string attached to the object. Often useful for displaying to users. pub description: Option<String>, /// Type of the fee, one of: `application_fee`, `stripe_fee` or `tax`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, } +#[cfg(feature = "min-ser")] +pub struct FeeBuilder { + amount: Option<i64>, + application: Option<Option<String>>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + type_: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Fee { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Fee>, + builder: FeeBuilder, + } + + impl Visitor for Place<Fee> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FeeBuilder::deser_default() })) + } + } + + impl MapBuilder for FeeBuilder { + type Out = Fee; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "application" => Deserialize::begin(&mut self.application), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), application: Deserialize::default(), currency: Deserialize::default(), description: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let application = self.application.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { amount, application, currency, description, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Fee { + type Builder = FeeBuilder; + } + + impl FromValueOpt for Fee { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FeeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/file.rs b/generated/stripe_shared/src/file.rs index 316ea89bb..226c8f2af 100644 --- a/generated/stripe_shared/src/file.rs +++ b/generated/stripe_shared/src/file.rs @@ -1,13 +1,15 @@ /// This object represents files hosted on Stripe's servers. You can upload /// files with the [create file](https://stripe.com/docs/api#create_file) request /// (for example, when uploading dispute evidence). Stripe also -/// creates files independently (for example, the results of a [Sigma scheduled +/// creates files independetly (for example, the results of a [Sigma scheduled /// query](#scheduled_queries)). /// /// Related guide: [File upload guide](https://stripe.com/docs/file-upload) /// /// For more details see <<https://stripe.com/docs/api/files/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct File { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -18,7 +20,6 @@ pub struct File { /// Unique identifier for the object. pub id: stripe_shared::FileId, /// A list of [file links](https://stripe.com/docs/api#file_links) that point at this file. - #[serde(skip_serializing_if = "Option::is_none")] pub links: Option<stripe_types::List<stripe_shared::FileLink>>, /// The [purpose](https://stripe.com/docs/file-upload#uploading-a-file) of the uploaded file. pub purpose: stripe_shared::FilePurpose, @@ -27,11 +28,144 @@ pub struct File { /// A suitable title for the document. pub title: Option<String>, /// The returned file type (for example, `csv`, `pdf`, `jpg`, or `png`). - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<String>, /// Use your live secret API key to download the file from this URL. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct FileBuilder { + created: Option<stripe_types::Timestamp>, + expires_at: Option<Option<stripe_types::Timestamp>>, + filename: Option<Option<String>>, + id: Option<stripe_shared::FileId>, + links: Option<Option<stripe_types::List<stripe_shared::FileLink>>>, + purpose: Option<stripe_shared::FilePurpose>, + size: Option<u64>, + title: Option<Option<String>>, + type_: Option<Option<String>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for File { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<File>, + builder: FileBuilder, + } + + impl Visitor for Place<File> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FileBuilder::deser_default() })) + } + } + + impl MapBuilder for FileBuilder { + type Out = File; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "filename" => Deserialize::begin(&mut self.filename), + "id" => Deserialize::begin(&mut self.id), + "links" => Deserialize::begin(&mut self.links), + "purpose" => Deserialize::begin(&mut self.purpose), + "size" => Deserialize::begin(&mut self.size), + "title" => Deserialize::begin(&mut self.title), + "type" => Deserialize::begin(&mut self.type_), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + expires_at: Deserialize::default(), + filename: Deserialize::default(), + id: Deserialize::default(), + links: Deserialize::default(), + purpose: Deserialize::default(), + size: Deserialize::default(), + title: Deserialize::default(), + type_: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let expires_at = self.expires_at.take()?; + let filename = self.filename.take()?; + let id = self.id.take()?; + let links = self.links.take()?; + let purpose = self.purpose.take()?; + let size = self.size.take()?; + let title = self.title.take()?; + let type_ = self.type_.take()?; + let url = self.url.take()?; + + Some(Self::Out { created, expires_at, filename, id, links, purpose, size, title, type_, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for File { + type Builder = FileBuilder; + } + + impl FromValueOpt for File { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FileBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "filename" => b.filename = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "links" => b.links = Some(FromValueOpt::from_value(v)?), + "purpose" => b.purpose = Some(FromValueOpt::from_value(v)?), + "size" => b.size = Some(FromValueOpt::from_value(v)?), + "title" => b.title = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for File { type Id = stripe_shared::FileId; fn id(&self) -> &Self::Id { @@ -131,6 +265,24 @@ impl<'de> serde::Deserialize<'de> for FilePurpose { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(FilePurpose::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FilePurpose { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FilePurpose> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FilePurpose::from_str(s).unwrap_or(FilePurpose::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FilePurpose); diff --git a/generated/stripe_shared/src/file_link.rs b/generated/stripe_shared/src/file_link.rs index 79c569794..8e79ae48f 100644 --- a/generated/stripe_shared/src/file_link.rs +++ b/generated/stripe_shared/src/file_link.rs @@ -3,7 +3,9 @@ /// retrieve the contents of the file without authentication. /// /// For more details see <<https://stripe.com/docs/api/file_links/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FileLink { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -23,6 +25,129 @@ pub struct FileLink { /// The publicly accessible URL to download the file. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct FileLinkBuilder { + created: Option<stripe_types::Timestamp>, + expired: Option<bool>, + expires_at: Option<Option<stripe_types::Timestamp>>, + file: Option<stripe_types::Expandable<stripe_shared::File>>, + id: Option<stripe_shared::FileLinkId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FileLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FileLink>, + builder: FileLinkBuilder, + } + + impl Visitor for Place<FileLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FileLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for FileLinkBuilder { + type Out = FileLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "expired" => Deserialize::begin(&mut self.expired), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "file" => Deserialize::begin(&mut self.file), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + expired: Deserialize::default(), + expires_at: Deserialize::default(), + file: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let expired = self.expired.take()?; + let expires_at = self.expires_at.take()?; + let file = self.file.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let url = self.url.take()?; + + Some(Self::Out { created, expired, expires_at, file, id, livemode, metadata, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FileLink { + type Builder = FileLinkBuilder; + } + + impl FromValueOpt for FileLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FileLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "expired" => b.expired = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "file" => b.file = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for FileLink { type Id = stripe_shared::FileLinkId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/funding_instructions.rs b/generated/stripe_shared/src/funding_instructions.rs index 1c24cbf80..abb666f3e 100644 --- a/generated/stripe_shared/src/funding_instructions.rs +++ b/generated/stripe_shared/src/funding_instructions.rs @@ -3,7 +3,9 @@ /// Customers can fund this balance by initiating a bank transfer to any account in the /// `financial_addresses` field. /// Related guide: [Customer balance funding instructions](https://stripe.com/docs/payments/customer-balance/funding-instructions). -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructions { pub bank_transfer: stripe_shared::FundingInstructionsBankTransfer, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. @@ -14,6 +16,104 @@ pub struct FundingInstructions { /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBuilder { + bank_transfer: Option<stripe_shared::FundingInstructionsBankTransfer>, + currency: Option<stripe_types::Currency>, + funding_type: Option<FundingInstructionsFundingType>, + livemode: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructions>, + builder: FundingInstructionsBuilder, + } + + impl Visitor for Place<FundingInstructions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBuilder { + type Out = FundingInstructions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_transfer" => Deserialize::begin(&mut self.bank_transfer), + "currency" => Deserialize::begin(&mut self.currency), + "funding_type" => Deserialize::begin(&mut self.funding_type), + "livemode" => Deserialize::begin(&mut self.livemode), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transfer: Deserialize::default(), currency: Deserialize::default(), funding_type: Deserialize::default(), livemode: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_transfer = self.bank_transfer.take()?; + let currency = self.currency.take()?; + let funding_type = self.funding_type.take()?; + let livemode = self.livemode.take()?; + + Some(Self::Out { bank_transfer, currency, funding_type, livemode }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructions { + type Builder = FundingInstructionsBuilder; + } + + impl FromValueOpt for FundingInstructions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_transfer" => b.bank_transfer = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "funding_type" => b.funding_type = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The `funding_type` of the returned instructions #[derive(Copy, Clone, Eq, PartialEq)] pub enum FundingInstructionsFundingType { @@ -61,8 +161,24 @@ impl<'de> serde::Deserialize<'de> for FundingInstructionsFundingType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FundingInstructionsFundingType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FundingInstructionsFundingType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FundingInstructionsFundingType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FundingInstructionsFundingType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FundingInstructionsFundingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FundingInstructionsFundingType); diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer.rs index 3556b6569..cefb52645 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer.rs @@ -1,13 +1,109 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransfer { /// The country of the bank account to fund pub country: String, /// A list of financial addresses that can be used to fund a particular balance pub financial_addresses: Vec<stripe_shared::FundingInstructionsBankTransferFinancialAddress>, /// The bank_transfer type - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: FundingInstructionsBankTransferType, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferBuilder { + country: Option<String>, + financial_addresses: Option<Vec<stripe_shared::FundingInstructionsBankTransferFinancialAddress>>, + type_: Option<FundingInstructionsBankTransferType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransfer>, + builder: FundingInstructionsBankTransferBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferBuilder { + type Out = FundingInstructionsBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + "financial_addresses" => Deserialize::begin(&mut self.financial_addresses), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default(), financial_addresses: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + let financial_addresses = self.financial_addresses.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { country, financial_addresses, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransfer { + type Builder = FundingInstructionsBankTransferBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "financial_addresses" => b.financial_addresses = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The bank_transfer type #[derive(Copy, Clone, Eq, PartialEq)] pub enum FundingInstructionsBankTransferType { @@ -58,8 +154,24 @@ impl<'de> serde::Deserialize<'de> for FundingInstructionsBankTransferType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for FundingInstructionsBankTransferType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FundingInstructionsBankTransferType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FundingInstructionsBankTransferType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FundingInstructionsBankTransferType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FundingInstructionsBankTransferType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FundingInstructionsBankTransferType); diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer_aba_record.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer_aba_record.rs index 7d573bf59..63255ca49 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer_aba_record.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer_aba_record.rs @@ -1,5 +1,7 @@ /// ABA Records contain U.S. bank account details per the ABA format. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransferAbaRecord { /// The ABA account number pub account_number: String, @@ -8,3 +10,97 @@ pub struct FundingInstructionsBankTransferAbaRecord { /// The ABA routing number pub routing_number: String, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferAbaRecordBuilder { + account_number: Option<String>, + bank_name: Option<String>, + routing_number: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransferAbaRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransferAbaRecord>, + builder: FundingInstructionsBankTransferAbaRecordBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransferAbaRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferAbaRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferAbaRecordBuilder { + type Out = FundingInstructionsBankTransferAbaRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_number" => Deserialize::begin(&mut self.account_number), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_number: Deserialize::default(), bank_name: Deserialize::default(), routing_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_number = self.account_number.take()?; + let bank_name = self.bank_name.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { account_number, bank_name, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransferAbaRecord { + type Builder = FundingInstructionsBankTransferAbaRecordBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransferAbaRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferAbaRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_number" => b.account_number = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer_financial_address.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer_financial_address.rs index e3967d1e3..a3e5f9073 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer_financial_address.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer_financial_address.rs @@ -1,26 +1,143 @@ /// FinancialAddresses contain identifying information that resolves to a FinancialAccount. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransferFinancialAddress { - #[serde(skip_serializing_if = "Option::is_none")] pub aba: Option<stripe_shared::FundingInstructionsBankTransferAbaRecord>, - #[serde(skip_serializing_if = "Option::is_none")] pub iban: Option<stripe_shared::FundingInstructionsBankTransferIbanRecord>, - #[serde(skip_serializing_if = "Option::is_none")] pub sort_code: Option<stripe_shared::FundingInstructionsBankTransferSortCodeRecord>, - #[serde(skip_serializing_if = "Option::is_none")] pub spei: Option<stripe_shared::FundingInstructionsBankTransferSpeiRecord>, /// The payment networks supported by this FinancialAddress - #[serde(skip_serializing_if = "Option::is_none")] - pub supported_networks: - Option<Vec<FundingInstructionsBankTransferFinancialAddressSupportedNetworks>>, - #[serde(skip_serializing_if = "Option::is_none")] + pub supported_networks: Option<Vec<FundingInstructionsBankTransferFinancialAddressSupportedNetworks>>, pub swift: Option<stripe_shared::FundingInstructionsBankTransferSwiftRecord>, /// The type of financial address - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: FundingInstructionsBankTransferFinancialAddressType, - #[serde(skip_serializing_if = "Option::is_none")] pub zengin: Option<stripe_shared::FundingInstructionsBankTransferZenginRecord>, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferFinancialAddressBuilder { + aba: Option<Option<stripe_shared::FundingInstructionsBankTransferAbaRecord>>, + iban: Option<Option<stripe_shared::FundingInstructionsBankTransferIbanRecord>>, + sort_code: Option<Option<stripe_shared::FundingInstructionsBankTransferSortCodeRecord>>, + spei: Option<Option<stripe_shared::FundingInstructionsBankTransferSpeiRecord>>, + supported_networks: Option<Option<Vec<FundingInstructionsBankTransferFinancialAddressSupportedNetworks>>>, + swift: Option<Option<stripe_shared::FundingInstructionsBankTransferSwiftRecord>>, + type_: Option<FundingInstructionsBankTransferFinancialAddressType>, + zengin: Option<Option<stripe_shared::FundingInstructionsBankTransferZenginRecord>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransferFinancialAddress { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransferFinancialAddress>, + builder: FundingInstructionsBankTransferFinancialAddressBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransferFinancialAddress> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferFinancialAddressBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferFinancialAddressBuilder { + type Out = FundingInstructionsBankTransferFinancialAddress; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "aba" => Deserialize::begin(&mut self.aba), + "iban" => Deserialize::begin(&mut self.iban), + "sort_code" => Deserialize::begin(&mut self.sort_code), + "spei" => Deserialize::begin(&mut self.spei), + "supported_networks" => Deserialize::begin(&mut self.supported_networks), + "swift" => Deserialize::begin(&mut self.swift), + "type" => Deserialize::begin(&mut self.type_), + "zengin" => Deserialize::begin(&mut self.zengin), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + aba: Deserialize::default(), + iban: Deserialize::default(), + sort_code: Deserialize::default(), + spei: Deserialize::default(), + supported_networks: Deserialize::default(), + swift: Deserialize::default(), + type_: Deserialize::default(), + zengin: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let aba = self.aba.take()?; + let iban = self.iban.take()?; + let sort_code = self.sort_code.take()?; + let spei = self.spei.take()?; + let supported_networks = self.supported_networks.take()?; + let swift = self.swift.take()?; + let type_ = self.type_.take()?; + let zengin = self.zengin.take()?; + + Some(Self::Out { aba, iban, sort_code, spei, supported_networks, swift, type_, zengin }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransferFinancialAddress { + type Builder = FundingInstructionsBankTransferFinancialAddressBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransferFinancialAddress { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferFinancialAddressBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "aba" => b.aba = Some(FromValueOpt::from_value(v)?), + "iban" => b.iban = Some(FromValueOpt::from_value(v)?), + "sort_code" => b.sort_code = Some(FromValueOpt::from_value(v)?), + "spei" => b.spei = Some(FromValueOpt::from_value(v)?), + "supported_networks" => b.supported_networks = Some(FromValueOpt::from_value(v)?), + "swift" => b.swift = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "zengin" => b.zengin = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The payment networks supported by this FinancialAddress #[derive(Copy, Clone, Eq, PartialEq)] pub enum FundingInstructionsBankTransferFinancialAddressSupportedNetworks { @@ -85,15 +202,31 @@ impl serde::Serialize for FundingInstructionsBankTransferFinancialAddressSupport serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for FundingInstructionsBankTransferFinancialAddressSupportedNetworks -{ +impl<'de> serde::Deserialize<'de> for FundingInstructionsBankTransferFinancialAddressSupportedNetworks { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FundingInstructionsBankTransferFinancialAddressSupportedNetworks")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FundingInstructionsBankTransferFinancialAddressSupportedNetworks { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FundingInstructionsBankTransferFinancialAddressSupportedNetworks> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FundingInstructionsBankTransferFinancialAddressSupportedNetworks::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FundingInstructionsBankTransferFinancialAddressSupportedNetworks); /// The type of financial address #[derive(Copy, Clone, Eq, PartialEq)] pub enum FundingInstructionsBankTransferFinancialAddressType { @@ -156,10 +289,24 @@ impl<'de> serde::Deserialize<'de> for FundingInstructionsBankTransferFinancialAd fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for FundingInstructionsBankTransferFinancialAddressType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for FundingInstructionsBankTransferFinancialAddressType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for FundingInstructionsBankTransferFinancialAddressType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<FundingInstructionsBankTransferFinancialAddressType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FundingInstructionsBankTransferFinancialAddressType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(FundingInstructionsBankTransferFinancialAddressType); diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer_iban_record.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer_iban_record.rs index 271653c71..69815b55c 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer_iban_record.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer_iban_record.rs @@ -1,5 +1,7 @@ /// Iban Records contain E.U. bank account details per the SEPA format. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransferIbanRecord { /// The name of the person or business that owns the bank account pub account_holder_name: String, @@ -10,3 +12,101 @@ pub struct FundingInstructionsBankTransferIbanRecord { /// The IBAN of the account. pub iban: String, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferIbanRecordBuilder { + account_holder_name: Option<String>, + bic: Option<String>, + country: Option<String>, + iban: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransferIbanRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransferIbanRecord>, + builder: FundingInstructionsBankTransferIbanRecordBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransferIbanRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferIbanRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferIbanRecordBuilder { + type Out = FundingInstructionsBankTransferIbanRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_name" => Deserialize::begin(&mut self.account_holder_name), + "bic" => Deserialize::begin(&mut self.bic), + "country" => Deserialize::begin(&mut self.country), + "iban" => Deserialize::begin(&mut self.iban), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_holder_name: Deserialize::default(), bic: Deserialize::default(), country: Deserialize::default(), iban: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_name = self.account_holder_name.take()?; + let bic = self.bic.take()?; + let country = self.country.take()?; + let iban = self.iban.take()?; + + Some(Self::Out { account_holder_name, bic, country, iban }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransferIbanRecord { + type Builder = FundingInstructionsBankTransferIbanRecordBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransferIbanRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferIbanRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_name" => b.account_holder_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "iban" => b.iban = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer_sort_code_record.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer_sort_code_record.rs index 64c33de14..609e7b38d 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer_sort_code_record.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer_sort_code_record.rs @@ -1,5 +1,7 @@ /// Sort Code Records contain U.K. bank account details per the sort code format. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransferSortCodeRecord { /// The name of the person or business that owns the bank account pub account_holder_name: String, @@ -8,3 +10,97 @@ pub struct FundingInstructionsBankTransferSortCodeRecord { /// The six-digit sort code pub sort_code: String, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferSortCodeRecordBuilder { + account_holder_name: Option<String>, + account_number: Option<String>, + sort_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransferSortCodeRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransferSortCodeRecord>, + builder: FundingInstructionsBankTransferSortCodeRecordBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransferSortCodeRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferSortCodeRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferSortCodeRecordBuilder { + type Out = FundingInstructionsBankTransferSortCodeRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_name" => Deserialize::begin(&mut self.account_holder_name), + "account_number" => Deserialize::begin(&mut self.account_number), + "sort_code" => Deserialize::begin(&mut self.sort_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_holder_name: Deserialize::default(), account_number: Deserialize::default(), sort_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_name = self.account_holder_name.take()?; + let account_number = self.account_number.take()?; + let sort_code = self.sort_code.take()?; + + Some(Self::Out { account_holder_name, account_number, sort_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransferSortCodeRecord { + type Builder = FundingInstructionsBankTransferSortCodeRecordBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransferSortCodeRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferSortCodeRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_name" => b.account_holder_name = Some(FromValueOpt::from_value(v)?), + "account_number" => b.account_number = Some(FromValueOpt::from_value(v)?), + "sort_code" => b.sort_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer_spei_record.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer_spei_record.rs index bce20ff9f..3db4c3a6e 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer_spei_record.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer_spei_record.rs @@ -1,5 +1,7 @@ /// SPEI Records contain Mexico bank account details per the SPEI format. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransferSpeiRecord { /// The three-digit bank code pub bank_code: String, @@ -8,3 +10,97 @@ pub struct FundingInstructionsBankTransferSpeiRecord { /// The CLABE number pub clabe: String, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferSpeiRecordBuilder { + bank_code: Option<String>, + bank_name: Option<String>, + clabe: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransferSpeiRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransferSpeiRecord>, + builder: FundingInstructionsBankTransferSpeiRecordBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransferSpeiRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferSpeiRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferSpeiRecordBuilder { + type Out = FundingInstructionsBankTransferSpeiRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "clabe" => Deserialize::begin(&mut self.clabe), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_code: Deserialize::default(), bank_name: Deserialize::default(), clabe: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let clabe = self.clabe.take()?; + + Some(Self::Out { bank_code, bank_name, clabe }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransferSpeiRecord { + type Builder = FundingInstructionsBankTransferSpeiRecordBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransferSpeiRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferSpeiRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "clabe" => b.clabe = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer_swift_record.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer_swift_record.rs index 458b7e023..998642afb 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer_swift_record.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer_swift_record.rs @@ -1,5 +1,7 @@ /// SWIFT Records contain U.S. bank account details per the SWIFT format. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransferSwiftRecord { /// The account number pub account_number: String, @@ -8,3 +10,97 @@ pub struct FundingInstructionsBankTransferSwiftRecord { /// The SWIFT code pub swift_code: String, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferSwiftRecordBuilder { + account_number: Option<String>, + bank_name: Option<String>, + swift_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransferSwiftRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransferSwiftRecord>, + builder: FundingInstructionsBankTransferSwiftRecordBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransferSwiftRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferSwiftRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferSwiftRecordBuilder { + type Out = FundingInstructionsBankTransferSwiftRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_number" => Deserialize::begin(&mut self.account_number), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "swift_code" => Deserialize::begin(&mut self.swift_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_number: Deserialize::default(), bank_name: Deserialize::default(), swift_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_number = self.account_number.take()?; + let bank_name = self.bank_name.take()?; + let swift_code = self.swift_code.take()?; + + Some(Self::Out { account_number, bank_name, swift_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransferSwiftRecord { + type Builder = FundingInstructionsBankTransferSwiftRecordBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransferSwiftRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferSwiftRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_number" => b.account_number = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "swift_code" => b.swift_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer_zengin_record.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer_zengin_record.rs index a50e1be8d..19200c1c9 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer_zengin_record.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer_zengin_record.rs @@ -1,5 +1,7 @@ /// Zengin Records contain Japan bank account details per the Zengin format. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct FundingInstructionsBankTransferZenginRecord { /// The account holder name pub account_holder_name: Option<String>, @@ -16,3 +18,121 @@ pub struct FundingInstructionsBankTransferZenginRecord { /// The branch name of the account pub branch_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct FundingInstructionsBankTransferZenginRecordBuilder { + account_holder_name: Option<Option<String>>, + account_number: Option<Option<String>>, + account_type: Option<Option<String>>, + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + branch_code: Option<Option<String>>, + branch_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FundingInstructionsBankTransferZenginRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<FundingInstructionsBankTransferZenginRecord>, + builder: FundingInstructionsBankTransferZenginRecordBuilder, + } + + impl Visitor for Place<FundingInstructionsBankTransferZenginRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: FundingInstructionsBankTransferZenginRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for FundingInstructionsBankTransferZenginRecordBuilder { + type Out = FundingInstructionsBankTransferZenginRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_name" => Deserialize::begin(&mut self.account_holder_name), + "account_number" => Deserialize::begin(&mut self.account_number), + "account_type" => Deserialize::begin(&mut self.account_type), + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "branch_code" => Deserialize::begin(&mut self.branch_code), + "branch_name" => Deserialize::begin(&mut self.branch_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_name: Deserialize::default(), + account_number: Deserialize::default(), + account_type: Deserialize::default(), + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + branch_code: Deserialize::default(), + branch_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_name = self.account_holder_name.take()?; + let account_number = self.account_number.take()?; + let account_type = self.account_type.take()?; + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let branch_code = self.branch_code.take()?; + let branch_name = self.branch_name.take()?; + + Some(Self::Out { account_holder_name, account_number, account_type, bank_code, bank_name, branch_code, branch_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for FundingInstructionsBankTransferZenginRecord { + type Builder = FundingInstructionsBankTransferZenginRecordBuilder; + } + + impl FromValueOpt for FundingInstructionsBankTransferZenginRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FundingInstructionsBankTransferZenginRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_name" => b.account_holder_name = Some(FromValueOpt::from_value(v)?), + "account_number" => b.account_number = Some(FromValueOpt::from_value(v)?), + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "branch_code" => b.branch_code = Some(FromValueOpt::from_value(v)?), + "branch_name" => b.branch_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice.rs b/generated/stripe_shared/src/invoice.rs index 05578f764..a9022682e 100644 --- a/generated/stripe_shared/src/invoice.rs +++ b/generated/stripe_shared/src/invoice.rs @@ -32,7 +32,9 @@ /// Related guide: [Send invoices to customers](https://stripe.com/docs/billing/invoices/sending) /// /// For more details see <<https://stripe.com/docs/api/invoices/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Invoice { /// The country of the business associated with this invoice, most often the business creating the invoice. pub account_country: Option<String>, @@ -64,7 +66,6 @@ pub struct Invoice { pub attempted: bool, /// Controls whether Stripe performs [automatic collection](https://stripe.com/docs/invoicing/integration/automatic-advancement-collection) of the invoice. /// If `false`, the invoice's state doesn't automatically advance without an explicit action. - #[serde(skip_serializing_if = "Option::is_none")] pub auto_advance: Option<bool>, pub automatic_tax: stripe_shared::AutomaticTax, /// Indicates the reason why the invoice was created. @@ -120,7 +121,6 @@ pub struct Invoice { /// The customer's tax IDs. /// Until the invoice is finalized, this field will contain the same tax IDs as `customer.tax_ids`. /// Once the invoice is finalized, this field will no longer be updated. - #[serde(skip_serializing_if = "Option::is_none")] pub customer_tax_ids: Option<Vec<stripe_shared::InvoicesResourceInvoiceTaxId>>, /// ID of the default payment method for the invoice. /// It must belong to the customer associated with the invoice. @@ -161,18 +161,14 @@ pub struct Invoice { pub from_invoice: Option<stripe_shared::InvoicesFromInvoice>, /// The URL for the hosted invoice page, which allows customers to view and pay an invoice. /// If the invoice has not been finalized yet, this will be null. - #[serde(skip_serializing_if = "Option::is_none")] pub hosted_invoice_url: Option<String>, /// Unique identifier for the object. /// This property is always present unless the invoice is an upcoming invoice. /// See [Retrieve an upcoming invoice](https://stripe.com/docs/api/invoices/upcoming) for more details. - #[serde(skip_serializing_if = "Option::is_none")] pub id: Option<stripe_shared::InvoiceId>, /// The link to download the PDF for the invoice. /// If the invoice has not been finalized yet, this will be null. - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_pdf: Option<String>, - pub issuer: stripe_shared::ConnectAccountReference, /// The error encountered during the previous attempt to finalize the invoice. /// This field is cleared when the invoice is successfully finalized. pub last_finalization_error: Option<Box<stripe_shared::ApiErrors>>, @@ -244,7 +240,6 @@ pub struct Invoice { /// Details about the subscription that created this invoice. pub subscription_details: Option<stripe_shared::SubscriptionDetailsData>, /// Only set for upcoming invoices that preview prorations. The time used to calculate prorations. - #[serde(skip_serializing_if = "Option::is_none")] pub subscription_proration_date: Option<stripe_types::Timestamp>, /// Total of all subscriptions, invoice items, and prorations on the invoice before any invoice level discount or exclusive tax is applied. /// Item discounts are already incorporated. @@ -256,7 +251,6 @@ pub struct Invoice { pub tax: Option<i64>, /// ID of the test clock this invoice belongs to. pub test_clock: Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>, - #[serde(skip_serializing_if = "Option::is_none")] pub threshold_reason: Option<stripe_shared::InvoiceThresholdReason>, /// Total after discounts and taxes. pub total: i64, @@ -273,6 +267,576 @@ pub struct Invoice { /// If the invoice had no webhooks to deliver, this will be set while the invoice is being created. pub webhooks_delivered_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceBuilder { + account_country: Option<Option<String>>, + account_name: Option<Option<String>>, + account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>, + amount_due: Option<i64>, + amount_paid: Option<i64>, + amount_remaining: Option<i64>, + amount_shipping: Option<i64>, + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + application_fee_amount: Option<Option<i64>>, + attempt_count: Option<u64>, + attempted: Option<bool>, + auto_advance: Option<Option<bool>>, + automatic_tax: Option<stripe_shared::AutomaticTax>, + billing_reason: Option<Option<InvoiceBillingReason>>, + charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + collection_method: Option<stripe_shared::InvoiceCollectionMethod>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + customer_address: Option<Option<stripe_shared::Address>>, + customer_email: Option<Option<String>>, + customer_name: Option<Option<String>>, + customer_phone: Option<Option<String>>, + customer_shipping: Option<Option<stripe_shared::Shipping>>, + customer_tax_exempt: Option<Option<InvoiceCustomerTaxExempt>>, + customer_tax_ids: Option<Option<Vec<stripe_shared::InvoicesResourceInvoiceTaxId>>>, + default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + default_source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>, + default_tax_rates: Option<Vec<stripe_shared::TaxRate>>, + description: Option<Option<String>>, + discount: Option<Option<stripe_shared::Discount>>, + discounts: Option<Option<Vec<stripe_types::Expandable<stripe_shared::Discount>>>>, + due_date: Option<Option<stripe_types::Timestamp>>, + effective_at: Option<Option<stripe_types::Timestamp>>, + ending_balance: Option<Option<i64>>, + footer: Option<Option<String>>, + from_invoice: Option<Option<stripe_shared::InvoicesFromInvoice>>, + hosted_invoice_url: Option<Option<String>>, + id: Option<Option<stripe_shared::InvoiceId>>, + invoice_pdf: Option<Option<String>>, + last_finalization_error: Option<Option<Box<stripe_shared::ApiErrors>>>, + latest_revision: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + lines: Option<stripe_types::List<stripe_shared::InvoiceLineItem>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + next_payment_attempt: Option<Option<stripe_types::Timestamp>>, + number: Option<Option<String>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + paid: Option<bool>, + paid_out_of_band: Option<bool>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, + payment_settings: Option<stripe_shared::InvoicesPaymentSettings>, + period_end: Option<stripe_types::Timestamp>, + period_start: Option<stripe_types::Timestamp>, + post_payment_credit_notes_amount: Option<i64>, + pre_payment_credit_notes_amount: Option<i64>, + quote: Option<Option<stripe_types::Expandable<stripe_shared::Quote>>>, + receipt_number: Option<Option<String>>, + rendering: Option<Option<stripe_shared::InvoicesInvoiceRendering>>, + rendering_options: Option<Option<stripe_shared::InvoiceSettingRenderingOptions>>, + shipping_cost: Option<Option<stripe_shared::InvoicesShippingCost>>, + shipping_details: Option<Option<stripe_shared::Shipping>>, + starting_balance: Option<i64>, + statement_descriptor: Option<Option<String>>, + status: Option<Option<stripe_shared::InvoiceStatus>>, + status_transitions: Option<stripe_shared::InvoicesStatusTransitions>, + subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>, + subscription_details: Option<Option<stripe_shared::SubscriptionDetailsData>>, + subscription_proration_date: Option<Option<stripe_types::Timestamp>>, + subtotal: Option<i64>, + subtotal_excluding_tax: Option<Option<i64>>, + tax: Option<Option<i64>>, + test_clock: Option<Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>>, + threshold_reason: Option<Option<stripe_shared::InvoiceThresholdReason>>, + total: Option<i64>, + total_discount_amounts: Option<Option<Vec<stripe_shared::DiscountsResourceDiscountAmount>>>, + total_excluding_tax: Option<Option<i64>>, + total_tax_amounts: Option<Vec<stripe_shared::InvoiceTaxAmount>>, + transfer_data: Option<Option<stripe_shared::InvoiceTransferData>>, + webhooks_delivered_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Invoice { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Invoice>, + builder: InvoiceBuilder, + } + + impl Visitor for Place<Invoice> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceBuilder { + type Out = Invoice; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_country" => Deserialize::begin(&mut self.account_country), + "account_name" => Deserialize::begin(&mut self.account_name), + "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids), + "amount_due" => Deserialize::begin(&mut self.amount_due), + "amount_paid" => Deserialize::begin(&mut self.amount_paid), + "amount_remaining" => Deserialize::begin(&mut self.amount_remaining), + "amount_shipping" => Deserialize::begin(&mut self.amount_shipping), + "application" => Deserialize::begin(&mut self.application), + "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount), + "attempt_count" => Deserialize::begin(&mut self.attempt_count), + "attempted" => Deserialize::begin(&mut self.attempted), + "auto_advance" => Deserialize::begin(&mut self.auto_advance), + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "billing_reason" => Deserialize::begin(&mut self.billing_reason), + "charge" => Deserialize::begin(&mut self.charge), + "collection_method" => Deserialize::begin(&mut self.collection_method), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "custom_fields" => Deserialize::begin(&mut self.custom_fields), + "customer" => Deserialize::begin(&mut self.customer), + "customer_address" => Deserialize::begin(&mut self.customer_address), + "customer_email" => Deserialize::begin(&mut self.customer_email), + "customer_name" => Deserialize::begin(&mut self.customer_name), + "customer_phone" => Deserialize::begin(&mut self.customer_phone), + "customer_shipping" => Deserialize::begin(&mut self.customer_shipping), + "customer_tax_exempt" => Deserialize::begin(&mut self.customer_tax_exempt), + "customer_tax_ids" => Deserialize::begin(&mut self.customer_tax_ids), + "default_payment_method" => Deserialize::begin(&mut self.default_payment_method), + "default_source" => Deserialize::begin(&mut self.default_source), + "default_tax_rates" => Deserialize::begin(&mut self.default_tax_rates), + "description" => Deserialize::begin(&mut self.description), + "discount" => Deserialize::begin(&mut self.discount), + "discounts" => Deserialize::begin(&mut self.discounts), + "due_date" => Deserialize::begin(&mut self.due_date), + "effective_at" => Deserialize::begin(&mut self.effective_at), + "ending_balance" => Deserialize::begin(&mut self.ending_balance), + "footer" => Deserialize::begin(&mut self.footer), + "from_invoice" => Deserialize::begin(&mut self.from_invoice), + "hosted_invoice_url" => Deserialize::begin(&mut self.hosted_invoice_url), + "id" => Deserialize::begin(&mut self.id), + "invoice_pdf" => Deserialize::begin(&mut self.invoice_pdf), + "last_finalization_error" => Deserialize::begin(&mut self.last_finalization_error), + "latest_revision" => Deserialize::begin(&mut self.latest_revision), + "lines" => Deserialize::begin(&mut self.lines), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "next_payment_attempt" => Deserialize::begin(&mut self.next_payment_attempt), + "number" => Deserialize::begin(&mut self.number), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "paid" => Deserialize::begin(&mut self.paid), + "paid_out_of_band" => Deserialize::begin(&mut self.paid_out_of_band), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "payment_settings" => Deserialize::begin(&mut self.payment_settings), + "period_end" => Deserialize::begin(&mut self.period_end), + "period_start" => Deserialize::begin(&mut self.period_start), + "post_payment_credit_notes_amount" => Deserialize::begin(&mut self.post_payment_credit_notes_amount), + "pre_payment_credit_notes_amount" => Deserialize::begin(&mut self.pre_payment_credit_notes_amount), + "quote" => Deserialize::begin(&mut self.quote), + "receipt_number" => Deserialize::begin(&mut self.receipt_number), + "rendering" => Deserialize::begin(&mut self.rendering), + "rendering_options" => Deserialize::begin(&mut self.rendering_options), + "shipping_cost" => Deserialize::begin(&mut self.shipping_cost), + "shipping_details" => Deserialize::begin(&mut self.shipping_details), + "starting_balance" => Deserialize::begin(&mut self.starting_balance), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "subscription" => Deserialize::begin(&mut self.subscription), + "subscription_details" => Deserialize::begin(&mut self.subscription_details), + "subscription_proration_date" => Deserialize::begin(&mut self.subscription_proration_date), + "subtotal" => Deserialize::begin(&mut self.subtotal), + "subtotal_excluding_tax" => Deserialize::begin(&mut self.subtotal_excluding_tax), + "tax" => Deserialize::begin(&mut self.tax), + "test_clock" => Deserialize::begin(&mut self.test_clock), + "threshold_reason" => Deserialize::begin(&mut self.threshold_reason), + "total" => Deserialize::begin(&mut self.total), + "total_discount_amounts" => Deserialize::begin(&mut self.total_discount_amounts), + "total_excluding_tax" => Deserialize::begin(&mut self.total_excluding_tax), + "total_tax_amounts" => Deserialize::begin(&mut self.total_tax_amounts), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + "webhooks_delivered_at" => Deserialize::begin(&mut self.webhooks_delivered_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_country: Deserialize::default(), + account_name: Deserialize::default(), + account_tax_ids: Deserialize::default(), + amount_due: Deserialize::default(), + amount_paid: Deserialize::default(), + amount_remaining: Deserialize::default(), + amount_shipping: Deserialize::default(), + application: Deserialize::default(), + application_fee_amount: Deserialize::default(), + attempt_count: Deserialize::default(), + attempted: Deserialize::default(), + auto_advance: Deserialize::default(), + automatic_tax: Deserialize::default(), + billing_reason: Deserialize::default(), + charge: Deserialize::default(), + collection_method: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + custom_fields: Deserialize::default(), + customer: Deserialize::default(), + customer_address: Deserialize::default(), + customer_email: Deserialize::default(), + customer_name: Deserialize::default(), + customer_phone: Deserialize::default(), + customer_shipping: Deserialize::default(), + customer_tax_exempt: Deserialize::default(), + customer_tax_ids: Deserialize::default(), + default_payment_method: Deserialize::default(), + default_source: Deserialize::default(), + default_tax_rates: Deserialize::default(), + description: Deserialize::default(), + discount: Deserialize::default(), + discounts: Deserialize::default(), + due_date: Deserialize::default(), + effective_at: Deserialize::default(), + ending_balance: Deserialize::default(), + footer: Deserialize::default(), + from_invoice: Deserialize::default(), + hosted_invoice_url: Deserialize::default(), + id: Deserialize::default(), + invoice_pdf: Deserialize::default(), + last_finalization_error: Deserialize::default(), + latest_revision: Deserialize::default(), + lines: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + next_payment_attempt: Deserialize::default(), + number: Deserialize::default(), + on_behalf_of: Deserialize::default(), + paid: Deserialize::default(), + paid_out_of_band: Deserialize::default(), + payment_intent: Deserialize::default(), + payment_settings: Deserialize::default(), + period_end: Deserialize::default(), + period_start: Deserialize::default(), + post_payment_credit_notes_amount: Deserialize::default(), + pre_payment_credit_notes_amount: Deserialize::default(), + quote: Deserialize::default(), + receipt_number: Deserialize::default(), + rendering: Deserialize::default(), + rendering_options: Deserialize::default(), + shipping_cost: Deserialize::default(), + shipping_details: Deserialize::default(), + starting_balance: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + subscription: Deserialize::default(), + subscription_details: Deserialize::default(), + subscription_proration_date: Deserialize::default(), + subtotal: Deserialize::default(), + subtotal_excluding_tax: Deserialize::default(), + tax: Deserialize::default(), + test_clock: Deserialize::default(), + threshold_reason: Deserialize::default(), + total: Deserialize::default(), + total_discount_amounts: Deserialize::default(), + total_excluding_tax: Deserialize::default(), + total_tax_amounts: Deserialize::default(), + transfer_data: Deserialize::default(), + webhooks_delivered_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_country = self.account_country.take()?; + let account_name = self.account_name.take()?; + let account_tax_ids = self.account_tax_ids.take()?; + let amount_due = self.amount_due.take()?; + let amount_paid = self.amount_paid.take()?; + let amount_remaining = self.amount_remaining.take()?; + let amount_shipping = self.amount_shipping.take()?; + let application = self.application.take()?; + let application_fee_amount = self.application_fee_amount.take()?; + let attempt_count = self.attempt_count.take()?; + let attempted = self.attempted.take()?; + let auto_advance = self.auto_advance.take()?; + let automatic_tax = self.automatic_tax.take()?; + let billing_reason = self.billing_reason.take()?; + let charge = self.charge.take()?; + let collection_method = self.collection_method.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let custom_fields = self.custom_fields.take()?; + let customer = self.customer.take()?; + let customer_address = self.customer_address.take()?; + let customer_email = self.customer_email.take()?; + let customer_name = self.customer_name.take()?; + let customer_phone = self.customer_phone.take()?; + let customer_shipping = self.customer_shipping.take()?; + let customer_tax_exempt = self.customer_tax_exempt.take()?; + let customer_tax_ids = self.customer_tax_ids.take()?; + let default_payment_method = self.default_payment_method.take()?; + let default_source = self.default_source.take()?; + let default_tax_rates = self.default_tax_rates.take()?; + let description = self.description.take()?; + let discount = self.discount.take()?; + let discounts = self.discounts.take()?; + let due_date = self.due_date.take()?; + let effective_at = self.effective_at.take()?; + let ending_balance = self.ending_balance.take()?; + let footer = self.footer.take()?; + let from_invoice = self.from_invoice.take()?; + let hosted_invoice_url = self.hosted_invoice_url.take()?; + let id = self.id.take()?; + let invoice_pdf = self.invoice_pdf.take()?; + let last_finalization_error = self.last_finalization_error.take()?; + let latest_revision = self.latest_revision.take()?; + let lines = self.lines.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let next_payment_attempt = self.next_payment_attempt.take()?; + let number = self.number.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let paid = self.paid.take()?; + let paid_out_of_band = self.paid_out_of_band.take()?; + let payment_intent = self.payment_intent.take()?; + let payment_settings = self.payment_settings.take()?; + let period_end = self.period_end.take()?; + let period_start = self.period_start.take()?; + let post_payment_credit_notes_amount = self.post_payment_credit_notes_amount.take()?; + let pre_payment_credit_notes_amount = self.pre_payment_credit_notes_amount.take()?; + let quote = self.quote.take()?; + let receipt_number = self.receipt_number.take()?; + let rendering = self.rendering.take()?; + let rendering_options = self.rendering_options.take()?; + let shipping_cost = self.shipping_cost.take()?; + let shipping_details = self.shipping_details.take()?; + let starting_balance = self.starting_balance.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + let subscription = self.subscription.take()?; + let subscription_details = self.subscription_details.take()?; + let subscription_proration_date = self.subscription_proration_date.take()?; + let subtotal = self.subtotal.take()?; + let subtotal_excluding_tax = self.subtotal_excluding_tax.take()?; + let tax = self.tax.take()?; + let test_clock = self.test_clock.take()?; + let threshold_reason = self.threshold_reason.take()?; + let total = self.total.take()?; + let total_discount_amounts = self.total_discount_amounts.take()?; + let total_excluding_tax = self.total_excluding_tax.take()?; + let total_tax_amounts = self.total_tax_amounts.take()?; + let transfer_data = self.transfer_data.take()?; + let webhooks_delivered_at = self.webhooks_delivered_at.take()?; + + Some(Self::Out { + account_country, + account_name, + account_tax_ids, + amount_due, + amount_paid, + amount_remaining, + amount_shipping, + application, + application_fee_amount, + attempt_count, + attempted, + auto_advance, + automatic_tax, + billing_reason, + charge, + collection_method, + created, + currency, + custom_fields, + customer, + customer_address, + customer_email, + customer_name, + customer_phone, + customer_shipping, + customer_tax_exempt, + customer_tax_ids, + default_payment_method, + default_source, + default_tax_rates, + description, + discount, + discounts, + due_date, + effective_at, + ending_balance, + footer, + from_invoice, + hosted_invoice_url, + id, + invoice_pdf, + last_finalization_error, + latest_revision, + lines, + livemode, + metadata, + next_payment_attempt, + number, + on_behalf_of, + paid, + paid_out_of_band, + payment_intent, + payment_settings, + period_end, + period_start, + post_payment_credit_notes_amount, + pre_payment_credit_notes_amount, + quote, + receipt_number, + rendering, + rendering_options, + shipping_cost, + shipping_details, + starting_balance, + statement_descriptor, + status, + status_transitions, + subscription, + subscription_details, + subscription_proration_date, + subtotal, + subtotal_excluding_tax, + tax, + test_clock, + threshold_reason, + total, + total_discount_amounts, + total_excluding_tax, + total_tax_amounts, + transfer_data, + webhooks_delivered_at, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Invoice { + type Builder = InvoiceBuilder; + } + + impl FromValueOpt for Invoice { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_country" => b.account_country = Some(FromValueOpt::from_value(v)?), + "account_name" => b.account_name = Some(FromValueOpt::from_value(v)?), + "account_tax_ids" => b.account_tax_ids = Some(FromValueOpt::from_value(v)?), + "amount_due" => b.amount_due = Some(FromValueOpt::from_value(v)?), + "amount_paid" => b.amount_paid = Some(FromValueOpt::from_value(v)?), + "amount_remaining" => b.amount_remaining = Some(FromValueOpt::from_value(v)?), + "amount_shipping" => b.amount_shipping = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "application_fee_amount" => b.application_fee_amount = Some(FromValueOpt::from_value(v)?), + "attempt_count" => b.attempt_count = Some(FromValueOpt::from_value(v)?), + "attempted" => b.attempted = Some(FromValueOpt::from_value(v)?), + "auto_advance" => b.auto_advance = Some(FromValueOpt::from_value(v)?), + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "billing_reason" => b.billing_reason = Some(FromValueOpt::from_value(v)?), + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "collection_method" => b.collection_method = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "custom_fields" => b.custom_fields = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "customer_address" => b.customer_address = Some(FromValueOpt::from_value(v)?), + "customer_email" => b.customer_email = Some(FromValueOpt::from_value(v)?), + "customer_name" => b.customer_name = Some(FromValueOpt::from_value(v)?), + "customer_phone" => b.customer_phone = Some(FromValueOpt::from_value(v)?), + "customer_shipping" => b.customer_shipping = Some(FromValueOpt::from_value(v)?), + "customer_tax_exempt" => b.customer_tax_exempt = Some(FromValueOpt::from_value(v)?), + "customer_tax_ids" => b.customer_tax_ids = Some(FromValueOpt::from_value(v)?), + "default_payment_method" => b.default_payment_method = Some(FromValueOpt::from_value(v)?), + "default_source" => b.default_source = Some(FromValueOpt::from_value(v)?), + "default_tax_rates" => b.default_tax_rates = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discount" => b.discount = Some(FromValueOpt::from_value(v)?), + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "due_date" => b.due_date = Some(FromValueOpt::from_value(v)?), + "effective_at" => b.effective_at = Some(FromValueOpt::from_value(v)?), + "ending_balance" => b.ending_balance = Some(FromValueOpt::from_value(v)?), + "footer" => b.footer = Some(FromValueOpt::from_value(v)?), + "from_invoice" => b.from_invoice = Some(FromValueOpt::from_value(v)?), + "hosted_invoice_url" => b.hosted_invoice_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice_pdf" => b.invoice_pdf = Some(FromValueOpt::from_value(v)?), + "last_finalization_error" => b.last_finalization_error = Some(FromValueOpt::from_value(v)?), + "latest_revision" => b.latest_revision = Some(FromValueOpt::from_value(v)?), + "lines" => b.lines = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "next_payment_attempt" => b.next_payment_attempt = Some(FromValueOpt::from_value(v)?), + "number" => b.number = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "paid" => b.paid = Some(FromValueOpt::from_value(v)?), + "paid_out_of_band" => b.paid_out_of_band = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "payment_settings" => b.payment_settings = Some(FromValueOpt::from_value(v)?), + "period_end" => b.period_end = Some(FromValueOpt::from_value(v)?), + "period_start" => b.period_start = Some(FromValueOpt::from_value(v)?), + "post_payment_credit_notes_amount" => b.post_payment_credit_notes_amount = Some(FromValueOpt::from_value(v)?), + "pre_payment_credit_notes_amount" => b.pre_payment_credit_notes_amount = Some(FromValueOpt::from_value(v)?), + "quote" => b.quote = Some(FromValueOpt::from_value(v)?), + "receipt_number" => b.receipt_number = Some(FromValueOpt::from_value(v)?), + "rendering" => b.rendering = Some(FromValueOpt::from_value(v)?), + "rendering_options" => b.rendering_options = Some(FromValueOpt::from_value(v)?), + "shipping_cost" => b.shipping_cost = Some(FromValueOpt::from_value(v)?), + "shipping_details" => b.shipping_details = Some(FromValueOpt::from_value(v)?), + "starting_balance" => b.starting_balance = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + "subscription_details" => b.subscription_details = Some(FromValueOpt::from_value(v)?), + "subscription_proration_date" => b.subscription_proration_date = Some(FromValueOpt::from_value(v)?), + "subtotal" => b.subtotal = Some(FromValueOpt::from_value(v)?), + "subtotal_excluding_tax" => b.subtotal_excluding_tax = Some(FromValueOpt::from_value(v)?), + "tax" => b.tax = Some(FromValueOpt::from_value(v)?), + "test_clock" => b.test_clock = Some(FromValueOpt::from_value(v)?), + "threshold_reason" => b.threshold_reason = Some(FromValueOpt::from_value(v)?), + "total" => b.total = Some(FromValueOpt::from_value(v)?), + "total_discount_amounts" => b.total_discount_amounts = Some(FromValueOpt::from_value(v)?), + "total_excluding_tax" => b.total_excluding_tax = Some(FromValueOpt::from_value(v)?), + "total_tax_amounts" => b.total_tax_amounts = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + "webhooks_delivered_at" => b.webhooks_delivered_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates the reason why the invoice was created. /// /// * `manual`: Unrelated to a subscription, for example, created via the invoice editor. @@ -353,10 +917,27 @@ impl<'de> serde::Deserialize<'de> for InvoiceBillingReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for InvoiceBillingReason")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoiceBillingReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceBillingReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceBillingReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceBillingReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceBillingReason); /// The customer's tax exempt status. /// Until the invoice is finalized, this field will equal `customer.tax_exempt`. /// Once the invoice is finalized, this field will no longer be updated. @@ -412,10 +993,27 @@ impl<'de> serde::Deserialize<'de> for InvoiceCustomerTaxExempt { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for InvoiceCustomerTaxExempt")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoiceCustomerTaxExempt")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceCustomerTaxExempt { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceCustomerTaxExempt> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceCustomerTaxExempt::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceCustomerTaxExempt); impl stripe_types::Object for Invoice { type Id = Option<stripe_shared::InvoiceId>; fn id(&self) -> &Self::Id { @@ -472,10 +1070,27 @@ impl<'de> serde::Deserialize<'de> for InvoiceCollectionMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for InvoiceCollectionMethod")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoiceCollectionMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceCollectionMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceCollectionMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceCollectionMethod); #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoiceStatus { Draft, @@ -537,3 +1152,21 @@ impl<'de> serde::Deserialize<'de> for InvoiceStatus { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoiceStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceStatus); diff --git a/generated/stripe_shared/src/invoice_installments_card.rs b/generated/stripe_shared/src/invoice_installments_card.rs index eb15116d7..ca91872d3 100644 --- a/generated/stripe_shared/src/invoice_installments_card.rs +++ b/generated/stripe_shared/src/invoice_installments_card.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceInstallmentsCard { /// Whether Installments are enabled for this Invoice. pub enabled: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceInstallmentsCardBuilder { + enabled: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceInstallmentsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceInstallmentsCard>, + builder: InvoiceInstallmentsCardBuilder, + } + + impl Visitor for Place<InvoiceInstallmentsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceInstallmentsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceInstallmentsCardBuilder { + type Out = InvoiceInstallmentsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceInstallmentsCard { + type Builder = InvoiceInstallmentsCardBuilder; + } + + impl FromValueOpt for InvoiceInstallmentsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceInstallmentsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_item.rs b/generated/stripe_shared/src/invoice_item.rs index 3d3ee3ac4..36e826d90 100644 --- a/generated/stripe_shared/src/invoice_item.rs +++ b/generated/stripe_shared/src/invoice_item.rs @@ -15,7 +15,9 @@ /// Related guides: [Integrate with the Invoicing API](https://stripe.com/docs/invoicing/integration), [Subscription Invoices](https://stripe.com/docs/billing/invoices/subscription#adding-upcoming-invoice-items). /// /// For more details see <<https://stripe.com/docs/api/invoiceitems/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceItem { /// Amount (in the `currency` specified) of the invoice item. /// This should always be equal to `unit_amount * quantity`. @@ -57,7 +59,6 @@ pub struct InvoiceItem { /// The subscription that this invoice item has been created for, if any. pub subscription: Option<stripe_types::Expandable<stripe_shared::Subscription>>, /// The subscription item that this invoice item has been created for, if any. - #[serde(skip_serializing_if = "Option::is_none")] pub subscription_item: Option<String>, /// The tax rates which apply to the invoice item. /// When set, the `default_tax_rates` on the invoice do not apply to this invoice item. @@ -69,6 +70,222 @@ pub struct InvoiceItem { /// Same as `unit_amount`, but contains a decimal value with at most 12 decimal places. pub unit_amount_decimal: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceItemBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, + customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, + date: Option<stripe_types::Timestamp>, + description: Option<Option<String>>, + discountable: Option<bool>, + discounts: Option<Option<Vec<stripe_types::Expandable<stripe_shared::Discount>>>>, + id: Option<stripe_shared::InvoiceItemId>, + invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + period: Option<stripe_shared::InvoiceLineItemPeriod>, + plan: Option<Option<stripe_shared::Plan>>, + price: Option<Option<stripe_shared::Price>>, + proration: Option<bool>, + quantity: Option<u64>, + subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>, + subscription_item: Option<Option<String>>, + tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>, + test_clock: Option<Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>>, + unit_amount: Option<Option<i64>>, + unit_amount_decimal: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceItem>, + builder: InvoiceItemBuilder, + } + + impl Visitor for Place<InvoiceItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceItemBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceItemBuilder { + type Out = InvoiceItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "date" => Deserialize::begin(&mut self.date), + "description" => Deserialize::begin(&mut self.description), + "discountable" => Deserialize::begin(&mut self.discountable), + "discounts" => Deserialize::begin(&mut self.discounts), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "period" => Deserialize::begin(&mut self.period), + "plan" => Deserialize::begin(&mut self.plan), + "price" => Deserialize::begin(&mut self.price), + "proration" => Deserialize::begin(&mut self.proration), + "quantity" => Deserialize::begin(&mut self.quantity), + "subscription" => Deserialize::begin(&mut self.subscription), + "subscription_item" => Deserialize::begin(&mut self.subscription_item), + "tax_rates" => Deserialize::begin(&mut self.tax_rates), + "test_clock" => Deserialize::begin(&mut self.test_clock), + "unit_amount" => Deserialize::begin(&mut self.unit_amount), + "unit_amount_decimal" => Deserialize::begin(&mut self.unit_amount_decimal), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + date: Deserialize::default(), + description: Deserialize::default(), + discountable: Deserialize::default(), + discounts: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + period: Deserialize::default(), + plan: Deserialize::default(), + price: Deserialize::default(), + proration: Deserialize::default(), + quantity: Deserialize::default(), + subscription: Deserialize::default(), + subscription_item: Deserialize::default(), + tax_rates: Deserialize::default(), + test_clock: Deserialize::default(), + unit_amount: Deserialize::default(), + unit_amount_decimal: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let date = self.date.take()?; + let description = self.description.take()?; + let discountable = self.discountable.take()?; + let discounts = self.discounts.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let period = self.period.take()?; + let plan = self.plan.take()?; + let price = self.price.take()?; + let proration = self.proration.take()?; + let quantity = self.quantity.take()?; + let subscription = self.subscription.take()?; + let subscription_item = self.subscription_item.take()?; + let tax_rates = self.tax_rates.take()?; + let test_clock = self.test_clock.take()?; + let unit_amount = self.unit_amount.take()?; + let unit_amount_decimal = self.unit_amount_decimal.take()?; + + Some(Self::Out { + amount, + currency, + customer, + date, + description, + discountable, + discounts, + id, + invoice, + livemode, + metadata, + period, + plan, + price, + proration, + quantity, + subscription, + subscription_item, + tax_rates, + test_clock, + unit_amount, + unit_amount_decimal, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceItem { + type Builder = InvoiceItemBuilder; + } + + impl FromValueOpt for InvoiceItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "date" => b.date = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discountable" => b.discountable = Some(FromValueOpt::from_value(v)?), + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "period" => b.period = Some(FromValueOpt::from_value(v)?), + "plan" => b.plan = Some(FromValueOpt::from_value(v)?), + "price" => b.price = Some(FromValueOpt::from_value(v)?), + "proration" => b.proration = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + "subscription_item" => b.subscription_item = Some(FromValueOpt::from_value(v)?), + "tax_rates" => b.tax_rates = Some(FromValueOpt::from_value(v)?), + "test_clock" => b.test_clock = Some(FromValueOpt::from_value(v)?), + "unit_amount" => b.unit_amount = Some(FromValueOpt::from_value(v)?), + "unit_amount_decimal" => b.unit_amount_decimal = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for InvoiceItem { type Id = stripe_shared::InvoiceItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/invoice_item_threshold_reason.rs b/generated/stripe_shared/src/invoice_item_threshold_reason.rs index 76947aae7..aae3446cb 100644 --- a/generated/stripe_shared/src/invoice_item_threshold_reason.rs +++ b/generated/stripe_shared/src/invoice_item_threshold_reason.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceItemThresholdReason { /// The IDs of the line items that triggered the threshold invoice. pub line_item_ids: Vec<String>, /// The quantity threshold boundary that applied to the given line item. pub usage_gte: i64, } +#[cfg(feature = "min-ser")] +pub struct InvoiceItemThresholdReasonBuilder { + line_item_ids: Option<Vec<String>>, + usage_gte: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceItemThresholdReason { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceItemThresholdReason>, + builder: InvoiceItemThresholdReasonBuilder, + } + + impl Visitor for Place<InvoiceItemThresholdReason> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceItemThresholdReasonBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceItemThresholdReasonBuilder { + type Out = InvoiceItemThresholdReason; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "line_item_ids" => Deserialize::begin(&mut self.line_item_ids), + "usage_gte" => Deserialize::begin(&mut self.usage_gte), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { line_item_ids: Deserialize::default(), usage_gte: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let line_item_ids = self.line_item_ids.take()?; + let usage_gte = self.usage_gte.take()?; + + Some(Self::Out { line_item_ids, usage_gte }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceItemThresholdReason { + type Builder = InvoiceItemThresholdReasonBuilder; + } + + impl FromValueOpt for InvoiceItemThresholdReason { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceItemThresholdReasonBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "line_item_ids" => b.line_item_ids = Some(FromValueOpt::from_value(v)?), + "usage_gte" => b.usage_gte = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_line_item.rs b/generated/stripe_shared/src/invoice_line_item.rs index 262d0115e..da12359c4 100644 --- a/generated/stripe_shared/src/invoice_line_item.rs +++ b/generated/stripe_shared/src/invoice_line_item.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceLineItem { /// The amount, in cents (or local equivalent). pub amount: i64, @@ -20,7 +22,6 @@ pub struct InvoiceLineItem { /// Unique identifier for the object. pub id: stripe_shared::InvoiceLineItemId, /// The ID of the [invoice item](https://stripe.com/docs/api/invoiceitems) associated with this line item if any. - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_item: Option<stripe_types::Expandable<stripe_shared::InvoiceItem>>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, @@ -43,20 +44,239 @@ pub struct InvoiceLineItem { pub subscription: Option<stripe_types::Expandable<stripe_shared::Subscription>>, /// The subscription item that generated this line item. /// Left empty if the line item is not an explicit result of a subscription. - #[serde(skip_serializing_if = "Option::is_none")] pub subscription_item: Option<stripe_types::Expandable<stripe_shared::SubscriptionItem>>, /// The amount of tax calculated per tax rate for this line item - #[serde(skip_serializing_if = "Option::is_none")] pub tax_amounts: Option<Vec<stripe_shared::InvoiceTaxAmount>>, /// The tax rates which apply to the line item. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option<Vec<stripe_shared::TaxRate>>, /// A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: InvoiceLineItemType, /// The amount in cents (or local equivalent) representing the unit amount for this line item, excluding all tax and discounts. pub unit_amount_excluding_tax: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceLineItemBuilder { + amount: Option<i64>, + amount_excluding_tax: Option<Option<i64>>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + discount_amounts: Option<Option<Vec<stripe_shared::DiscountsResourceDiscountAmount>>>, + discountable: Option<bool>, + discounts: Option<Option<Vec<stripe_types::Expandable<stripe_shared::Discount>>>>, + id: Option<stripe_shared::InvoiceLineItemId>, + invoice_item: Option<Option<stripe_types::Expandable<stripe_shared::InvoiceItem>>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + period: Option<stripe_shared::InvoiceLineItemPeriod>, + plan: Option<Option<stripe_shared::Plan>>, + price: Option<Option<stripe_shared::Price>>, + proration: Option<bool>, + proration_details: Option<Option<stripe_shared::InvoicesResourceLineItemsProrationDetails>>, + quantity: Option<Option<u64>>, + subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>, + subscription_item: Option<Option<stripe_types::Expandable<stripe_shared::SubscriptionItem>>>, + tax_amounts: Option<Option<Vec<stripe_shared::InvoiceTaxAmount>>>, + tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>, + type_: Option<InvoiceLineItemType>, + unit_amount_excluding_tax: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceLineItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceLineItem>, + builder: InvoiceLineItemBuilder, + } + + impl Visitor for Place<InvoiceLineItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceLineItemBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceLineItemBuilder { + type Out = InvoiceLineItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_excluding_tax" => Deserialize::begin(&mut self.amount_excluding_tax), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "discount_amounts" => Deserialize::begin(&mut self.discount_amounts), + "discountable" => Deserialize::begin(&mut self.discountable), + "discounts" => Deserialize::begin(&mut self.discounts), + "id" => Deserialize::begin(&mut self.id), + "invoice_item" => Deserialize::begin(&mut self.invoice_item), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "period" => Deserialize::begin(&mut self.period), + "plan" => Deserialize::begin(&mut self.plan), + "price" => Deserialize::begin(&mut self.price), + "proration" => Deserialize::begin(&mut self.proration), + "proration_details" => Deserialize::begin(&mut self.proration_details), + "quantity" => Deserialize::begin(&mut self.quantity), + "subscription" => Deserialize::begin(&mut self.subscription), + "subscription_item" => Deserialize::begin(&mut self.subscription_item), + "tax_amounts" => Deserialize::begin(&mut self.tax_amounts), + "tax_rates" => Deserialize::begin(&mut self.tax_rates), + "type" => Deserialize::begin(&mut self.type_), + "unit_amount_excluding_tax" => Deserialize::begin(&mut self.unit_amount_excluding_tax), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_excluding_tax: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + discount_amounts: Deserialize::default(), + discountable: Deserialize::default(), + discounts: Deserialize::default(), + id: Deserialize::default(), + invoice_item: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + period: Deserialize::default(), + plan: Deserialize::default(), + price: Deserialize::default(), + proration: Deserialize::default(), + proration_details: Deserialize::default(), + quantity: Deserialize::default(), + subscription: Deserialize::default(), + subscription_item: Deserialize::default(), + tax_amounts: Deserialize::default(), + tax_rates: Deserialize::default(), + type_: Deserialize::default(), + unit_amount_excluding_tax: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_excluding_tax = self.amount_excluding_tax.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let discount_amounts = self.discount_amounts.take()?; + let discountable = self.discountable.take()?; + let discounts = self.discounts.take()?; + let id = self.id.take()?; + let invoice_item = self.invoice_item.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let period = self.period.take()?; + let plan = self.plan.take()?; + let price = self.price.take()?; + let proration = self.proration.take()?; + let proration_details = self.proration_details.take()?; + let quantity = self.quantity.take()?; + let subscription = self.subscription.take()?; + let subscription_item = self.subscription_item.take()?; + let tax_amounts = self.tax_amounts.take()?; + let tax_rates = self.tax_rates.take()?; + let type_ = self.type_.take()?; + let unit_amount_excluding_tax = self.unit_amount_excluding_tax.take()?; + + Some(Self::Out { + amount, + amount_excluding_tax, + currency, + description, + discount_amounts, + discountable, + discounts, + id, + invoice_item, + livemode, + metadata, + period, + plan, + price, + proration, + proration_details, + quantity, + subscription, + subscription_item, + tax_amounts, + tax_rates, + type_, + unit_amount_excluding_tax, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceLineItem { + type Builder = InvoiceLineItemBuilder; + } + + impl FromValueOpt for InvoiceLineItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceLineItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_excluding_tax" => b.amount_excluding_tax = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discount_amounts" => b.discount_amounts = Some(FromValueOpt::from_value(v)?), + "discountable" => b.discountable = Some(FromValueOpt::from_value(v)?), + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice_item" => b.invoice_item = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "period" => b.period = Some(FromValueOpt::from_value(v)?), + "plan" => b.plan = Some(FromValueOpt::from_value(v)?), + "price" => b.price = Some(FromValueOpt::from_value(v)?), + "proration" => b.proration = Some(FromValueOpt::from_value(v)?), + "proration_details" => b.proration_details = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + "subscription_item" => b.subscription_item = Some(FromValueOpt::from_value(v)?), + "tax_amounts" => b.tax_amounts = Some(FromValueOpt::from_value(v)?), + "tax_rates" => b.tax_rates = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "unit_amount_excluding_tax" => b.unit_amount_excluding_tax = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoiceLineItemType { @@ -107,10 +327,27 @@ impl<'de> serde::Deserialize<'de> for InvoiceLineItemType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for InvoiceLineItemType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoiceLineItemType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceLineItemType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceLineItemType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceLineItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceLineItemType); impl stripe_types::Object for InvoiceLineItem { type Id = stripe_shared::InvoiceLineItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/invoice_line_item_period.rs b/generated/stripe_shared/src/invoice_line_item_period.rs index 19b7fe0ba..bf190ec34 100644 --- a/generated/stripe_shared/src/invoice_line_item_period.rs +++ b/generated/stripe_shared/src/invoice_line_item_period.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceLineItemPeriod { /// The end of the period, which must be greater than or equal to the start. This value is inclusive. pub end: stripe_types::Timestamp, /// The start of the period. This value is inclusive. pub start: stripe_types::Timestamp, } +#[cfg(feature = "min-ser")] +pub struct InvoiceLineItemPeriodBuilder { + end: Option<stripe_types::Timestamp>, + start: Option<stripe_types::Timestamp>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceLineItemPeriod { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceLineItemPeriod>, + builder: InvoiceLineItemPeriodBuilder, + } + + impl Visitor for Place<InvoiceLineItemPeriod> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceLineItemPeriodBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceLineItemPeriodBuilder { + type Out = InvoiceLineItemPeriod; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "end" => Deserialize::begin(&mut self.end), + "start" => Deserialize::begin(&mut self.start), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end: Deserialize::default(), start: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let end = self.end.take()?; + let start = self.start.take()?; + + Some(Self::Out { end, start }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceLineItemPeriod { + type Builder = InvoiceLineItemPeriodBuilder; + } + + impl FromValueOpt for InvoiceLineItemPeriod { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceLineItemPeriodBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "end" => b.end = Some(FromValueOpt::from_value(v)?), + "start" => b.start = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_mandate_options_card.rs b/generated/stripe_shared/src/invoice_mandate_options_card.rs index 8ec277463..64bc68e3f 100644 --- a/generated/stripe_shared/src/invoice_mandate_options_card.rs +++ b/generated/stripe_shared/src/invoice_mandate_options_card.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceMandateOptionsCard { /// Amount to be charged for future payments. pub amount: Option<i64>, @@ -9,6 +11,100 @@ pub struct InvoiceMandateOptionsCard { /// A description of the mandate or subscription that is meant to be displayed to the customer. pub description: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceMandateOptionsCardBuilder { + amount: Option<Option<i64>>, + amount_type: Option<Option<InvoiceMandateOptionsCardAmountType>>, + description: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceMandateOptionsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceMandateOptionsCard>, + builder: InvoiceMandateOptionsCardBuilder, + } + + impl Visitor for Place<InvoiceMandateOptionsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceMandateOptionsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceMandateOptionsCardBuilder { + type Out = InvoiceMandateOptionsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_type" => Deserialize::begin(&mut self.amount_type), + "description" => Deserialize::begin(&mut self.description), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), amount_type: Deserialize::default(), description: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_type = self.amount_type.take()?; + let description = self.description.take()?; + + Some(Self::Out { amount, amount_type, description }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceMandateOptionsCard { + type Builder = InvoiceMandateOptionsCardBuilder; + } + + impl FromValueOpt for InvoiceMandateOptionsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceMandateOptionsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_type" => b.amount_type = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// One of `fixed` or `maximum`. /// If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. /// If `maximum`, the amount charged can be up to the value passed for the `amount` param. @@ -61,8 +157,24 @@ impl<'de> serde::Deserialize<'de> for InvoiceMandateOptionsCardAmountType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for InvoiceMandateOptionsCardAmountType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoiceMandateOptionsCardAmountType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceMandateOptionsCardAmountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceMandateOptionsCardAmountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceMandateOptionsCardAmountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceMandateOptionsCardAmountType); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_acss_debit.rs b/generated/stripe_shared/src/invoice_payment_method_options_acss_debit.rs index d4bbc066f..d8de85c91 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_acss_debit.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_acss_debit.rs @@ -1,11 +1,101 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsAcssDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebitMandateOptions>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option<InvoicePaymentMethodOptionsAcssDebitVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsAcssDebitBuilder { + mandate_options: Option<Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebitMandateOptions>>, + verification_method: Option<Option<InvoicePaymentMethodOptionsAcssDebitVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsAcssDebit>, + builder: InvoicePaymentMethodOptionsAcssDebitBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsAcssDebitBuilder { + type Out = InvoicePaymentMethodOptionsAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { mandate_options: Deserialize::default(), verification_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let mandate_options = self.mandate_options.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { mandate_options, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsAcssDebit { + type Builder = InvoicePaymentMethodOptionsAcssDebitBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoicePaymentMethodOptionsAcssDebitVerificationMethod { @@ -59,10 +149,24 @@ impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsAcssDebitVerifi fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for InvoicePaymentMethodOptionsAcssDebitVerificationMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsAcssDebitVerificationMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsAcssDebitVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsAcssDebitVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsAcssDebitVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsAcssDebitVerificationMethod); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_acss_debit_mandate_options.rs b/generated/stripe_shared/src/invoice_payment_method_options_acss_debit_mandate_options.rs index b26bf2259..5e202c03b 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_acss_debit_mandate_options.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_acss_debit_mandate_options.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsAcssDebitMandateOptions { /// Transaction type of the mandate. pub transaction_type: Option<InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType>, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder { + transaction_type: Option<Option<InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsAcssDebitMandateOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsAcssDebitMandateOptions>, + builder: InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsAcssDebitMandateOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder { + type Out = InvoicePaymentMethodOptionsAcssDebitMandateOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "transaction_type" => Deserialize::begin(&mut self.transaction_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { transaction_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let transaction_type = self.transaction_type.take()?; + + Some(Self::Out { transaction_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsAcssDebitMandateOptions { + type Builder = InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsAcssDebitMandateOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "transaction_type" => b.transaction_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -49,12 +137,28 @@ impl serde::Serialize for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTran serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType -{ +impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_bancontact.rs b/generated/stripe_shared/src/invoice_payment_method_options_bancontact.rs index 620989038..4b441bdac 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_bancontact.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_bancontact.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. pub preferred_language: InvoicePaymentMethodOptionsBancontactPreferredLanguage, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsBancontactBuilder { + preferred_language: Option<InvoicePaymentMethodOptionsBancontactPreferredLanguage>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsBancontact { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsBancontact>, + builder: InvoicePaymentMethodOptionsBancontactBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsBancontact> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsBancontactBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsBancontactBuilder { + type Out = InvoicePaymentMethodOptionsBancontact; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { preferred_language: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let preferred_language = self.preferred_language.take()?; + + Some(Self::Out { preferred_language }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsBancontact { + type Builder = InvoicePaymentMethodOptionsBancontactBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsBancontact { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsBancontactBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoicePaymentMethodOptionsBancontactPreferredLanguage { @@ -59,10 +147,24 @@ impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsBancontactPrefe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for InvoicePaymentMethodOptionsBancontactPreferredLanguage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsBancontactPreferredLanguage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsBancontactPreferredLanguage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsBancontactPreferredLanguage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsBancontactPreferredLanguage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsBancontactPreferredLanguage); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_card.rs b/generated/stripe_shared/src/invoice_payment_method_options_card.rs index 39c32a89a..f75af3ec9 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_card.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_card.rs @@ -1,12 +1,103 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsCard { - #[serde(skip_serializing_if = "Option::is_none")] pub installments: Option<stripe_shared::InvoiceInstallmentsCard>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. pub request_three_d_secure: Option<InvoicePaymentMethodOptionsCardRequestThreeDSecure>, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsCardBuilder { + installments: Option<Option<stripe_shared::InvoiceInstallmentsCard>>, + request_three_d_secure: Option<Option<InvoicePaymentMethodOptionsCardRequestThreeDSecure>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsCard>, + builder: InvoicePaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsCardBuilder { + type Out = InvoicePaymentMethodOptionsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "installments" => Deserialize::begin(&mut self.installments), + "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { installments: Deserialize::default(), request_three_d_secure: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let installments = self.installments.take()?; + let request_three_d_secure = self.request_three_d_secure.take()?; + + Some(Self::Out { installments, request_three_d_secure }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsCard { + type Builder = InvoicePaymentMethodOptionsCardBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "installments" => b.installments = Some(FromValueOpt::from_value(v)?), + "request_three_d_secure" => b.request_three_d_secure = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. @@ -14,7 +105,6 @@ pub struct InvoicePaymentMethodOptionsCard { pub enum InvoicePaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl InvoicePaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -22,7 +112,6 @@ impl InvoicePaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -34,7 +123,6 @@ impl std::str::FromStr for InvoicePaymentMethodOptionsCardRequestThreeDSecure { match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -62,10 +150,24 @@ impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsCardRequestThre fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for InvoicePaymentMethodOptionsCardRequestThreeDSecure", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsCardRequestThreeDSecure")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsCardRequestThreeDSecure> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsCardRequestThreeDSecure::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsCardRequestThreeDSecure); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_customer_balance.rs b/generated/stripe_shared/src/invoice_payment_method_options_customer_balance.rs index 940dc6b7b..8bd84bc28 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_customer_balance.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_customer_balance.rs @@ -1,12 +1,102 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsCustomerBalance { - #[serde(skip_serializing_if = "Option::is_none")] - pub bank_transfer: - Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalanceBankTransfer>, + pub bank_transfer: Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalanceBankTransfer>, /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. pub funding_type: Option<InvoicePaymentMethodOptionsCustomerBalanceFundingType>, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsCustomerBalanceBuilder { + bank_transfer: Option<Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalanceBankTransfer>>, + funding_type: Option<Option<InvoicePaymentMethodOptionsCustomerBalanceFundingType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsCustomerBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsCustomerBalance>, + builder: InvoicePaymentMethodOptionsCustomerBalanceBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsCustomerBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsCustomerBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsCustomerBalanceBuilder { + type Out = InvoicePaymentMethodOptionsCustomerBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_transfer" => Deserialize::begin(&mut self.bank_transfer), + "funding_type" => Deserialize::begin(&mut self.funding_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transfer: Deserialize::default(), funding_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_transfer = self.bank_transfer.take()?; + let funding_type = self.funding_type.take()?; + + Some(Self::Out { bank_transfer, funding_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsCustomerBalance { + type Builder = InvoicePaymentMethodOptionsCustomerBalanceBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsCustomerBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsCustomerBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_transfer" => b.bank_transfer = Some(FromValueOpt::from_value(v)?), + "funding_type" => b.funding_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -55,10 +145,24 @@ impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsCustomerBalance fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for InvoicePaymentMethodOptionsCustomerBalanceFundingType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsCustomerBalanceFundingType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsCustomerBalanceFundingType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsCustomerBalanceFundingType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsCustomerBalanceFundingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsCustomerBalanceFundingType); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer.rs b/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer.rs index 156446afc..c43154262 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer.rs @@ -1,10 +1,100 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsCustomerBalanceBankTransfer { - #[serde(skip_serializing_if = "Option::is_none")] - pub eu_bank_transfer: - Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer>, + pub eu_bank_transfer: Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer>, /// The bank transfer type that can be used for funding. /// Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder { + eu_bank_transfer: Option<Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer>>, + type_: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsCustomerBalanceBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsCustomerBalanceBankTransfer>, + builder: InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsCustomerBalanceBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder { + type Out = InvoicePaymentMethodOptionsCustomerBalanceBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "eu_bank_transfer" => Deserialize::begin(&mut self.eu_bank_transfer), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eu_bank_transfer: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let eu_bank_transfer = self.eu_bank_transfer.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { eu_bank_transfer, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsCustomerBalanceBankTransfer { + type Builder = InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsCustomerBalanceBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "eu_bank_transfer" => b.eu_bank_transfer = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer_eu_bank_transfer.rs b/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer_eu_bank_transfer.rs index 9f880a3d6..6d8d6680b 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer_eu_bank_transfer.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_customer_balance_bank_transfer_eu_bank_transfer.rs @@ -1,9 +1,97 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer { /// The desired country code of the bank account information. /// Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`. pub country: InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder { + country: Option<InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer>, + builder: InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder { + type Out = InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + + Some(Self::Out { country }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer { + type Builder = InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The desired country code of the bank account information. /// Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -29,9 +117,7 @@ impl InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry } } -impl std::str::FromStr - for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry -{ +impl std::str::FromStr for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry::*; @@ -46,24 +132,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry -{ +impl std::fmt::Display for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry -{ +impl std::fmt::Debug for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry -{ +impl serde::Serialize for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -71,12 +151,28 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry -{ +impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_konbini.rs b/generated/stripe_shared/src/invoice_payment_method_options_konbini.rs index 676a93018..0dc7b8bb4 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_konbini.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_konbini.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsKonbini {} +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsKonbiniBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsKonbini { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsKonbini>, + builder: InvoicePaymentMethodOptionsKonbiniBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsKonbini> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsKonbiniBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsKonbiniBuilder { + type Out = InvoicePaymentMethodOptionsKonbini; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsKonbini { + type Builder = InvoicePaymentMethodOptionsKonbiniBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsKonbini { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsKonbiniBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account.rs b/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account.rs index c02b52ea5..23449539f 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account.rs @@ -1,12 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsUsBankAccount { - #[serde(skip_serializing_if = "Option::is_none")] - pub financial_connections: - Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions>, + pub financial_connections: Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option<InvoicePaymentMethodOptionsUsBankAccountVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsUsBankAccountBuilder { + financial_connections: Option<Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions>>, + verification_method: Option<Option<InvoicePaymentMethodOptionsUsBankAccountVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsUsBankAccount>, + builder: InvoicePaymentMethodOptionsUsBankAccountBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsUsBankAccountBuilder { + type Out = InvoicePaymentMethodOptionsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "financial_connections" => Deserialize::begin(&mut self.financial_connections), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { financial_connections: Deserialize::default(), verification_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let financial_connections = self.financial_connections.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { financial_connections, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsUsBankAccount { + type Builder = InvoicePaymentMethodOptionsUsBankAccountBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "financial_connections" => b.financial_connections = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoicePaymentMethodOptionsUsBankAccountVerificationMethod { @@ -60,10 +149,24 @@ impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsUsBankAccountVe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for InvoicePaymentMethodOptionsUsBankAccountVerificationMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsUsBankAccountVerificationMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsUsBankAccountVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsUsBankAccountVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsUsBankAccountVerificationMethod); diff --git a/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account_linked_account_options.rs b/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account_linked_account_options.rs index 5d6060734..b671bee5a 100644 --- a/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account_linked_account_options.rs +++ b/generated/stripe_shared/src/invoice_payment_method_options_us_bank_account_linked_account_options.rs @@ -1,12 +1,102 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions { /// The list of permissions to request. The `payment_method` permission must be included. - #[serde(skip_serializing_if = "Option::is_none")] - pub permissions: - Option<Vec<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions>>, + pub permissions: Option<Vec<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions>>, /// Data features requested to be retrieved upon account creation. pub prefetch: Option<Vec<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch>>, } +#[cfg(feature = "min-ser")] +pub struct InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder { + permissions: Option<Option<Vec<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions>>>, + prefetch: Option<Option<Vec<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions>, + builder: InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder, + } + + impl Visitor for Place<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder { + type Out = InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "permissions" => Deserialize::begin(&mut self.permissions), + "prefetch" => Deserialize::begin(&mut self.prefetch), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { permissions: Deserialize::default(), prefetch: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let permissions = self.permissions.take()?; + let prefetch = self.prefetch.take()?; + + Some(Self::Out { permissions, prefetch }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions { + type Builder = InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder; + } + + impl FromValueOpt for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "permissions" => b.permissions = Some(FromValueOpt::from_value(v)?), + "prefetch" => b.prefetch = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The list of permissions to request. The `payment_method` permission must be included. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions { @@ -56,27 +146,41 @@ impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountO serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions -{ +impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions); /// Data features requested to be retrieved upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch { Balances, - Transactions, } impl InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch { pub fn as_str(self) -> &'static str { use InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } @@ -87,7 +191,6 @@ impl std::str::FromStr for InvoicePaymentMethodOptionsUsBankAccountLinkedAccount use InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } @@ -111,12 +214,28 @@ impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountO serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch -{ +impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch); diff --git a/generated/stripe_shared/src/invoice_rendering_pdf.rs b/generated/stripe_shared/src/invoice_rendering_pdf.rs index 5ede36ef1..1c94d18e6 100644 --- a/generated/stripe_shared/src/invoice_rendering_pdf.rs +++ b/generated/stripe_shared/src/invoice_rendering_pdf.rs @@ -1,10 +1,98 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceRenderingPdf { /// Page size of invoice pdf. /// Options include a4, letter, and auto. /// If set to auto, page size will be switched to a4 or letter based on customer locale. pub page_size: Option<InvoiceRenderingPdfPageSize>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceRenderingPdfBuilder { + page_size: Option<Option<InvoiceRenderingPdfPageSize>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceRenderingPdf { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceRenderingPdf>, + builder: InvoiceRenderingPdfBuilder, + } + + impl Visitor for Place<InvoiceRenderingPdf> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceRenderingPdfBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceRenderingPdfBuilder { + type Out = InvoiceRenderingPdf; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "page_size" => Deserialize::begin(&mut self.page_size), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { page_size: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let page_size = self.page_size.take()?; + + Some(Self::Out { page_size }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceRenderingPdf { + type Builder = InvoiceRenderingPdfBuilder; + } + + impl FromValueOpt for InvoiceRenderingPdf { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceRenderingPdfBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "page_size" => b.page_size = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Page size of invoice pdf. /// Options include a4, letter, and auto. /// If set to auto, page size will be switched to a4 or letter based on customer locale. @@ -60,7 +148,24 @@ impl<'de> serde::Deserialize<'de> for InvoiceRenderingPdfPageSize { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for InvoiceRenderingPdfPageSize")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoiceRenderingPdfPageSize")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceRenderingPdfPageSize { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceRenderingPdfPageSize> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceRenderingPdfPageSize::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceRenderingPdfPageSize); diff --git a/generated/stripe_shared/src/invoice_setting_custom_field.rs b/generated/stripe_shared/src/invoice_setting_custom_field.rs index 6a3c97ccc..23df55712 100644 --- a/generated/stripe_shared/src/invoice_setting_custom_field.rs +++ b/generated/stripe_shared/src/invoice_setting_custom_field.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceSettingCustomField { /// The name of the custom field. pub name: String, /// The value of the custom field. pub value: String, } +#[cfg(feature = "min-ser")] +pub struct InvoiceSettingCustomFieldBuilder { + name: Option<String>, + value: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceSettingCustomField { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceSettingCustomField>, + builder: InvoiceSettingCustomFieldBuilder, + } + + impl Visitor for Place<InvoiceSettingCustomField> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceSettingCustomFieldBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceSettingCustomFieldBuilder { + type Out = InvoiceSettingCustomField; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "name" => Deserialize::begin(&mut self.name), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { name: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let name = self.name.take()?; + let value = self.value.take()?; + + Some(Self::Out { name, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceSettingCustomField { + type Builder = InvoiceSettingCustomFieldBuilder; + } + + impl FromValueOpt for InvoiceSettingCustomField { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingCustomFieldBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_setting_customer_setting.rs b/generated/stripe_shared/src/invoice_setting_customer_setting.rs index 4af0fd658..66db7523e 100644 --- a/generated/stripe_shared/src/invoice_setting_customer_setting.rs +++ b/generated/stripe_shared/src/invoice_setting_customer_setting.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceSettingCustomerSetting { /// Default custom fields to be displayed on invoices for this customer. pub custom_fields: Option<Vec<stripe_shared::InvoiceSettingCustomField>>, @@ -9,3 +11,101 @@ pub struct InvoiceSettingCustomerSetting { /// Default options for invoice PDF rendering for this customer. pub rendering_options: Option<stripe_shared::InvoiceSettingRenderingOptions>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceSettingCustomerSettingBuilder { + custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>, + default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + footer: Option<Option<String>>, + rendering_options: Option<Option<stripe_shared::InvoiceSettingRenderingOptions>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceSettingCustomerSetting { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceSettingCustomerSetting>, + builder: InvoiceSettingCustomerSettingBuilder, + } + + impl Visitor for Place<InvoiceSettingCustomerSetting> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceSettingCustomerSettingBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceSettingCustomerSettingBuilder { + type Out = InvoiceSettingCustomerSetting; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom_fields" => Deserialize::begin(&mut self.custom_fields), + "default_payment_method" => Deserialize::begin(&mut self.default_payment_method), + "footer" => Deserialize::begin(&mut self.footer), + "rendering_options" => Deserialize::begin(&mut self.rendering_options), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom_fields: Deserialize::default(), default_payment_method: Deserialize::default(), footer: Deserialize::default(), rendering_options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom_fields = self.custom_fields.take()?; + let default_payment_method = self.default_payment_method.take()?; + let footer = self.footer.take()?; + let rendering_options = self.rendering_options.take()?; + + Some(Self::Out { custom_fields, default_payment_method, footer, rendering_options }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceSettingCustomerSetting { + type Builder = InvoiceSettingCustomerSettingBuilder; + } + + impl FromValueOpt for InvoiceSettingCustomerSetting { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingCustomerSettingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom_fields" => b.custom_fields = Some(FromValueOpt::from_value(v)?), + "default_payment_method" => b.default_payment_method = Some(FromValueOpt::from_value(v)?), + "footer" => b.footer = Some(FromValueOpt::from_value(v)?), + "rendering_options" => b.rendering_options = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_setting_quote_setting.rs b/generated/stripe_shared/src/invoice_setting_quote_setting.rs index 079a33825..63e3b423f 100644 --- a/generated/stripe_shared/src/invoice_setting_quote_setting.rs +++ b/generated/stripe_shared/src/invoice_setting_quote_setting.rs @@ -1,7 +1,94 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceSettingQuoteSetting { /// Number of days within which a customer must pay invoices generated by this quote. /// This value will be `null` for quotes where `collection_method=charge_automatically`. pub days_until_due: Option<u32>, - pub issuer: stripe_shared::ConnectAccountReference, } +#[cfg(feature = "min-ser")] +pub struct InvoiceSettingQuoteSettingBuilder { + days_until_due: Option<Option<u32>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceSettingQuoteSetting { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceSettingQuoteSetting>, + builder: InvoiceSettingQuoteSettingBuilder, + } + + impl Visitor for Place<InvoiceSettingQuoteSetting> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceSettingQuoteSettingBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceSettingQuoteSettingBuilder { + type Out = InvoiceSettingQuoteSetting; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "days_until_due" => Deserialize::begin(&mut self.days_until_due), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { days_until_due: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let days_until_due = self.days_until_due.take()?; + + Some(Self::Out { days_until_due }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceSettingQuoteSetting { + type Builder = InvoiceSettingQuoteSettingBuilder; + } + + impl FromValueOpt for InvoiceSettingQuoteSetting { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingQuoteSettingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "days_until_due" => b.days_until_due = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_setting_rendering_options.rs b/generated/stripe_shared/src/invoice_setting_rendering_options.rs index 152f5561f..3988bf098 100644 --- a/generated/stripe_shared/src/invoice_setting_rendering_options.rs +++ b/generated/stripe_shared/src/invoice_setting_rendering_options.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceSettingRenderingOptions { /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. pub amount_tax_display: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceSettingRenderingOptionsBuilder { + amount_tax_display: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceSettingRenderingOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceSettingRenderingOptions>, + builder: InvoiceSettingRenderingOptionsBuilder, + } + + impl Visitor for Place<InvoiceSettingRenderingOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceSettingRenderingOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceSettingRenderingOptionsBuilder { + type Out = InvoiceSettingRenderingOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_tax_display" => Deserialize::begin(&mut self.amount_tax_display), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_tax_display: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_tax_display = self.amount_tax_display.take()?; + + Some(Self::Out { amount_tax_display }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceSettingRenderingOptions { + type Builder = InvoiceSettingRenderingOptionsBuilder; + } + + impl FromValueOpt for InvoiceSettingRenderingOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingRenderingOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_tax_display" => b.amount_tax_display = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_setting_subscription_schedule_phase_setting.rs b/generated/stripe_shared/src/invoice_setting_subscription_schedule_phase_setting.rs index 9263d736a..d07f9fe91 100644 --- a/generated/stripe_shared/src/invoice_setting_subscription_schedule_phase_setting.rs +++ b/generated/stripe_shared/src/invoice_setting_subscription_schedule_phase_setting.rs @@ -1,13 +1,94 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceSettingSubscriptionSchedulePhaseSetting { - /// The account tax IDs associated with this phase of the subscription schedule. - /// Will be set on invoices generated by this phase of the subscription schedule. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>, /// Number of days within which a customer must pay invoices generated by this subscription schedule. /// This value will be `null` for subscription schedules where `billing=charge_automatically`. pub days_until_due: Option<u32>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - pub issuer: Option<stripe_shared::ConnectAccountReference>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceSettingSubscriptionSchedulePhaseSettingBuilder { + days_until_due: Option<Option<u32>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceSettingSubscriptionSchedulePhaseSetting { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceSettingSubscriptionSchedulePhaseSetting>, + builder: InvoiceSettingSubscriptionSchedulePhaseSettingBuilder, + } + + impl Visitor for Place<InvoiceSettingSubscriptionSchedulePhaseSetting> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceSettingSubscriptionSchedulePhaseSettingBuilder { + type Out = InvoiceSettingSubscriptionSchedulePhaseSetting; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "days_until_due" => Deserialize::begin(&mut self.days_until_due), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { days_until_due: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let days_until_due = self.days_until_due.take()?; + + Some(Self::Out { days_until_due }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceSettingSubscriptionSchedulePhaseSetting { + type Builder = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder; + } + + impl FromValueOpt for InvoiceSettingSubscriptionSchedulePhaseSetting { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "days_until_due" => b.days_until_due = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_setting_subscription_schedule_setting.rs b/generated/stripe_shared/src/invoice_setting_subscription_schedule_setting.rs index 1d85917fd..ab144f093 100644 --- a/generated/stripe_shared/src/invoice_setting_subscription_schedule_setting.rs +++ b/generated/stripe_shared/src/invoice_setting_subscription_schedule_setting.rs @@ -1,11 +1,94 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceSettingSubscriptionScheduleSetting { - /// The account tax IDs associated with the subscription schedule. - /// Will be set on invoices generated by the subscription schedule. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>, /// Number of days within which a customer must pay invoices generated by this subscription schedule. /// This value will be `null` for subscription schedules where `billing=charge_automatically`. pub days_until_due: Option<u32>, - pub issuer: stripe_shared::ConnectAccountReference, } +#[cfg(feature = "min-ser")] +pub struct InvoiceSettingSubscriptionScheduleSettingBuilder { + days_until_due: Option<Option<u32>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceSettingSubscriptionScheduleSetting { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceSettingSubscriptionScheduleSetting>, + builder: InvoiceSettingSubscriptionScheduleSettingBuilder, + } + + impl Visitor for Place<InvoiceSettingSubscriptionScheduleSetting> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceSettingSubscriptionScheduleSettingBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceSettingSubscriptionScheduleSettingBuilder { + type Out = InvoiceSettingSubscriptionScheduleSetting; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "days_until_due" => Deserialize::begin(&mut self.days_until_due), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { days_until_due: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let days_until_due = self.days_until_due.take()?; + + Some(Self::Out { days_until_due }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceSettingSubscriptionScheduleSetting { + type Builder = InvoiceSettingSubscriptionScheduleSettingBuilder; + } + + impl FromValueOpt for InvoiceSettingSubscriptionScheduleSetting { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingSubscriptionScheduleSettingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "days_until_due" => b.days_until_due = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_tax_amount.rs b/generated/stripe_shared/src/invoice_tax_amount.rs index f72f84f57..76f750c46 100644 --- a/generated/stripe_shared/src/invoice_tax_amount.rs +++ b/generated/stripe_shared/src/invoice_tax_amount.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceTaxAmount { /// The amount, in cents (or local equivalent), of the tax. pub amount: i64, @@ -12,6 +14,114 @@ pub struct InvoiceTaxAmount { /// The amount on which tax is calculated, in cents (or local equivalent). pub taxable_amount: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceTaxAmountBuilder { + amount: Option<i64>, + inclusive: Option<bool>, + tax_rate: Option<stripe_types::Expandable<stripe_shared::TaxRate>>, + taxability_reason: Option<Option<InvoiceTaxAmountTaxabilityReason>>, + taxable_amount: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceTaxAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceTaxAmount>, + builder: InvoiceTaxAmountBuilder, + } + + impl Visitor for Place<InvoiceTaxAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceTaxAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceTaxAmountBuilder { + type Out = InvoiceTaxAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "inclusive" => Deserialize::begin(&mut self.inclusive), + "tax_rate" => Deserialize::begin(&mut self.tax_rate), + "taxability_reason" => Deserialize::begin(&mut self.taxability_reason), + "taxable_amount" => Deserialize::begin(&mut self.taxable_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + inclusive: Deserialize::default(), + tax_rate: Deserialize::default(), + taxability_reason: Deserialize::default(), + taxable_amount: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let inclusive = self.inclusive.take()?; + let tax_rate = self.tax_rate.take()?; + let taxability_reason = self.taxability_reason.take()?; + let taxable_amount = self.taxable_amount.take()?; + + Some(Self::Out { amount, inclusive, tax_rate, taxability_reason, taxable_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceTaxAmount { + type Builder = InvoiceTaxAmountBuilder; + } + + impl FromValueOpt for InvoiceTaxAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceTaxAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "inclusive" => b.inclusive = Some(FromValueOpt::from_value(v)?), + "tax_rate" => b.tax_rate = Some(FromValueOpt::from_value(v)?), + "taxability_reason" => b.taxability_reason = Some(FromValueOpt::from_value(v)?), + "taxable_amount" => b.taxable_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reasoning behind this tax, for example, if the product is tax exempt. /// The possible values for this field may be extended as new tax rules are supported. #[derive(Copy, Clone, Eq, PartialEq)] @@ -106,6 +216,24 @@ impl<'de> serde::Deserialize<'de> for InvoiceTaxAmountTaxabilityReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(InvoiceTaxAmountTaxabilityReason::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoiceTaxAmountTaxabilityReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoiceTaxAmountTaxabilityReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceTaxAmountTaxabilityReason::from_str(s).unwrap_or(InvoiceTaxAmountTaxabilityReason::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoiceTaxAmountTaxabilityReason); diff --git a/generated/stripe_shared/src/invoice_threshold_reason.rs b/generated/stripe_shared/src/invoice_threshold_reason.rs index fdf1ccc36..922ef2c16 100644 --- a/generated/stripe_shared/src/invoice_threshold_reason.rs +++ b/generated/stripe_shared/src/invoice_threshold_reason.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceThresholdReason { /// The total invoice amount threshold boundary if it triggered the threshold invoice. pub amount_gte: Option<i64>, /// Indicates which line items triggered a threshold invoice. pub item_reasons: Vec<stripe_shared::InvoiceItemThresholdReason>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceThresholdReasonBuilder { + amount_gte: Option<Option<i64>>, + item_reasons: Option<Vec<stripe_shared::InvoiceItemThresholdReason>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceThresholdReason { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceThresholdReason>, + builder: InvoiceThresholdReasonBuilder, + } + + impl Visitor for Place<InvoiceThresholdReason> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceThresholdReasonBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceThresholdReasonBuilder { + type Out = InvoiceThresholdReason; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_gte" => Deserialize::begin(&mut self.amount_gte), + "item_reasons" => Deserialize::begin(&mut self.item_reasons), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_gte: Deserialize::default(), item_reasons: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_gte = self.amount_gte.take()?; + let item_reasons = self.item_reasons.take()?; + + Some(Self::Out { amount_gte, item_reasons }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceThresholdReason { + type Builder = InvoiceThresholdReasonBuilder; + } + + impl FromValueOpt for InvoiceThresholdReason { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceThresholdReasonBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_gte" => b.amount_gte = Some(FromValueOpt::from_value(v)?), + "item_reasons" => b.item_reasons = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoice_transfer_data.rs b/generated/stripe_shared/src/invoice_transfer_data.rs index 82e728763..c025d0875 100644 --- a/generated/stripe_shared/src/invoice_transfer_data.rs +++ b/generated/stripe_shared/src/invoice_transfer_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoiceTransferData { /// The amount in cents (or local equivalent) that will be transferred to the destination account when the invoice is paid. /// By default, the entire amount is transferred to the destination. @@ -6,3 +8,93 @@ pub struct InvoiceTransferData { /// The account where funds from the payment will be transferred to upon payment success. pub destination: stripe_types::Expandable<stripe_shared::Account>, } +#[cfg(feature = "min-ser")] +pub struct InvoiceTransferDataBuilder { + amount: Option<Option<i64>>, + destination: Option<stripe_types::Expandable<stripe_shared::Account>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoiceTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoiceTransferData>, + builder: InvoiceTransferDataBuilder, + } + + impl Visitor for Place<InvoiceTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoiceTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoiceTransferDataBuilder { + type Out = InvoiceTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "destination" => Deserialize::begin(&mut self.destination), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let destination = self.destination.take()?; + + Some(Self::Out { amount, destination }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoiceTransferData { + type Builder = InvoiceTransferDataBuilder; + } + + impl FromValueOpt for InvoiceTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoices_from_invoice.rs b/generated/stripe_shared/src/invoices_from_invoice.rs index 86c86e8cc..ee55d0ce6 100644 --- a/generated/stripe_shared/src/invoices_from_invoice.rs +++ b/generated/stripe_shared/src/invoices_from_invoice.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesFromInvoice { /// The relation between this invoice and the cloned invoice pub action: String, /// The invoice that was cloned. pub invoice: stripe_types::Expandable<stripe_shared::Invoice>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesFromInvoiceBuilder { + action: Option<String>, + invoice: Option<stripe_types::Expandable<stripe_shared::Invoice>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesFromInvoice { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesFromInvoice>, + builder: InvoicesFromInvoiceBuilder, + } + + impl Visitor for Place<InvoicesFromInvoice> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesFromInvoiceBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesFromInvoiceBuilder { + type Out = InvoicesFromInvoice; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "action" => Deserialize::begin(&mut self.action), + "invoice" => Deserialize::begin(&mut self.invoice), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { action: Deserialize::default(), invoice: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let action = self.action.take()?; + let invoice = self.invoice.take()?; + + Some(Self::Out { action, invoice }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesFromInvoice { + type Builder = InvoicesFromInvoiceBuilder; + } + + impl FromValueOpt for InvoicesFromInvoice { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesFromInvoiceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "action" => b.action = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoices_invoice_rendering.rs b/generated/stripe_shared/src/invoices_invoice_rendering.rs index 4197addf4..86df59186 100644 --- a/generated/stripe_shared/src/invoices_invoice_rendering.rs +++ b/generated/stripe_shared/src/invoices_invoice_rendering.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesInvoiceRendering { /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. pub amount_tax_display: Option<String>, /// Invoice pdf rendering options pub pdf: Option<stripe_shared::InvoiceRenderingPdf>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesInvoiceRenderingBuilder { + amount_tax_display: Option<Option<String>>, + pdf: Option<Option<stripe_shared::InvoiceRenderingPdf>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesInvoiceRendering { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesInvoiceRendering>, + builder: InvoicesInvoiceRenderingBuilder, + } + + impl Visitor for Place<InvoicesInvoiceRendering> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesInvoiceRenderingBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesInvoiceRenderingBuilder { + type Out = InvoicesInvoiceRendering; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_tax_display" => Deserialize::begin(&mut self.amount_tax_display), + "pdf" => Deserialize::begin(&mut self.pdf), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_tax_display: Deserialize::default(), pdf: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_tax_display = self.amount_tax_display.take()?; + let pdf = self.pdf.take()?; + + Some(Self::Out { amount_tax_display, pdf }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesInvoiceRendering { + type Builder = InvoicesInvoiceRenderingBuilder; + } + + impl FromValueOpt for InvoicesInvoiceRendering { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesInvoiceRenderingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_tax_display" => b.amount_tax_display = Some(FromValueOpt::from_value(v)?), + "pdf" => b.pdf = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoices_payment_method_options.rs b/generated/stripe_shared/src/invoices_payment_method_options.rs index 899acde20..7f5f0f32f 100644 --- a/generated/stripe_shared/src/invoices_payment_method_options.rs +++ b/generated/stripe_shared/src/invoices_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesPaymentMethodOptions { /// If paying by `acss_debit`, this sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent. pub acss_debit: Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebit>, @@ -13,3 +15,116 @@ pub struct InvoicesPaymentMethodOptions { /// If paying by `us_bank_account`, this sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent. pub us_bank_account: Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesPaymentMethodOptionsBuilder { + acss_debit: Option<Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebit>>, + bancontact: Option<Option<stripe_shared::InvoicePaymentMethodOptionsBancontact>>, + card: Option<Option<stripe_shared::InvoicePaymentMethodOptionsCard>>, + customer_balance: Option<Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalance>>, + konbini: Option<Option<stripe_shared::InvoicePaymentMethodOptionsKonbini>>, + us_bank_account: Option<Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesPaymentMethodOptions>, + builder: InvoicesPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<InvoicesPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesPaymentMethodOptionsBuilder { + type Out = InvoicesPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "card" => Deserialize::begin(&mut self.card), + "customer_balance" => Deserialize::begin(&mut self.customer_balance), + "konbini" => Deserialize::begin(&mut self.konbini), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + bancontact: Deserialize::default(), + card: Deserialize::default(), + customer_balance: Deserialize::default(), + konbini: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let bancontact = self.bancontact.take()?; + let card = self.card.take()?; + let customer_balance = self.customer_balance.take()?; + let konbini = self.konbini.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { acss_debit, bancontact, card, customer_balance, konbini, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesPaymentMethodOptions { + type Builder = InvoicesPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for InvoicesPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "customer_balance" => b.customer_balance = Some(FromValueOpt::from_value(v)?), + "konbini" => b.konbini = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoices_payment_settings.rs b/generated/stripe_shared/src/invoices_payment_settings.rs index e0137a6da..b8ff9cb59 100644 --- a/generated/stripe_shared/src/invoices_payment_settings.rs +++ b/generated/stripe_shared/src/invoices_payment_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesPaymentSettings { /// ID of the mandate to be used for this invoice. /// It must correspond to the payment method used to pay the invoice, including the invoice's default_payment_method or default_source, if set. @@ -10,6 +12,100 @@ pub struct InvoicesPaymentSettings { /// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). pub payment_method_types: Option<Vec<InvoicesPaymentSettingsPaymentMethodTypes>>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesPaymentSettingsBuilder { + default_mandate: Option<Option<String>>, + payment_method_options: Option<Option<stripe_shared::InvoicesPaymentMethodOptions>>, + payment_method_types: Option<Option<Vec<InvoicesPaymentSettingsPaymentMethodTypes>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesPaymentSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesPaymentSettings>, + builder: InvoicesPaymentSettingsBuilder, + } + + impl Visitor for Place<InvoicesPaymentSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesPaymentSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesPaymentSettingsBuilder { + type Out = InvoicesPaymentSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "default_mandate" => Deserialize::begin(&mut self.default_mandate), + "payment_method_options" => Deserialize::begin(&mut self.payment_method_options), + "payment_method_types" => Deserialize::begin(&mut self.payment_method_types), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { default_mandate: Deserialize::default(), payment_method_options: Deserialize::default(), payment_method_types: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let default_mandate = self.default_mandate.take()?; + let payment_method_options = self.payment_method_options.take()?; + let payment_method_types = self.payment_method_types.take()?; + + Some(Self::Out { default_mandate, payment_method_options, payment_method_types }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesPaymentSettings { + type Builder = InvoicesPaymentSettingsBuilder; + } + + impl FromValueOpt for InvoicesPaymentSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesPaymentSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "default_mandate" => b.default_mandate = Some(FromValueOpt::from_value(v)?), + "payment_method_options" => b.payment_method_options = Some(FromValueOpt::from_value(v)?), + "payment_method_types" => b.payment_method_types = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The list of payment method types (e.g. /// card) to provide to the invoice’s PaymentIntent. /// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). @@ -26,14 +122,12 @@ pub enum InvoicesPaymentSettingsPaymentMethodTypes { Card, Cashapp, CustomerBalance, - Eps, Fpx, Giropay, Grabpay, Ideal, Konbini, Link, - P24, Paynow, Paypal, Promptpay, @@ -59,14 +153,12 @@ impl InvoicesPaymentSettingsPaymentMethodTypes { Card => "card", Cashapp => "cashapp", CustomerBalance => "customer_balance", - Eps => "eps", Fpx => "fpx", Giropay => "giropay", Grabpay => "grabpay", Ideal => "ideal", Konbini => "konbini", Link => "link", - P24 => "p24", Paynow => "paynow", Paypal => "paypal", Promptpay => "promptpay", @@ -95,14 +187,12 @@ impl std::str::FromStr for InvoicesPaymentSettingsPaymentMethodTypes { "card" => Ok(Card), "cashapp" => Ok(Cashapp), "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), "fpx" => Ok(Fpx), "giropay" => Ok(Giropay), "grabpay" => Ok(Grabpay), "ideal" => Ok(Ideal), "konbini" => Ok(Konbini), "link" => Ok(Link), - "p24" => Ok(P24), "paynow" => Ok(Paynow), "paypal" => Ok(Paypal), "promptpay" => Ok(Promptpay), @@ -138,6 +228,24 @@ impl<'de> serde::Deserialize<'de> for InvoicesPaymentSettingsPaymentMethodTypes fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(InvoicesPaymentSettingsPaymentMethodTypes::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicesPaymentSettingsPaymentMethodTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicesPaymentSettingsPaymentMethodTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicesPaymentSettingsPaymentMethodTypes::from_str(s).unwrap_or(InvoicesPaymentSettingsPaymentMethodTypes::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicesPaymentSettingsPaymentMethodTypes); diff --git a/generated/stripe_shared/src/invoices_resource_invoice_tax_id.rs b/generated/stripe_shared/src/invoices_resource_invoice_tax_id.rs index fd0cd95ed..e9c7c3055 100644 --- a/generated/stripe_shared/src/invoices_resource_invoice_tax_id.rs +++ b/generated/stripe_shared/src/invoices_resource_invoice_tax_id.rs @@ -1,11 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesResourceInvoiceTaxId { /// The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: InvoicesResourceInvoiceTaxIdType, /// The value of the tax ID. pub value: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesResourceInvoiceTaxIdBuilder { + type_: Option<InvoicesResourceInvoiceTaxIdType>, + value: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesResourceInvoiceTaxId { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesResourceInvoiceTaxId>, + builder: InvoicesResourceInvoiceTaxIdBuilder, + } + + impl Visitor for Place<InvoicesResourceInvoiceTaxId> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesResourceInvoiceTaxIdBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesResourceInvoiceTaxIdBuilder { + type Out = InvoicesResourceInvoiceTaxId; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "type" => Deserialize::begin(&mut self.type_), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let type_ = self.type_.take()?; + let value = self.value.take()?; + + Some(Self::Out { type_, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesResourceInvoiceTaxId { + type Builder = InvoicesResourceInvoiceTaxIdBuilder; + } + + impl FromValueOpt for InvoicesResourceInvoiceTaxId { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesResourceInvoiceTaxIdBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, or `unknown`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InvoicesResourceInvoiceTaxIdType { @@ -251,8 +343,24 @@ impl<'de> serde::Deserialize<'de> for InvoicesResourceInvoiceTaxIdType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for InvoicesResourceInvoiceTaxIdType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InvoicesResourceInvoiceTaxIdType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InvoicesResourceInvoiceTaxIdType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InvoicesResourceInvoiceTaxIdType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoicesResourceInvoiceTaxIdType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InvoicesResourceInvoiceTaxIdType); diff --git a/generated/stripe_shared/src/invoices_resource_line_items_credited_items.rs b/generated/stripe_shared/src/invoices_resource_line_items_credited_items.rs index bf86d3cc0..008d49fdf 100644 --- a/generated/stripe_shared/src/invoices_resource_line_items_credited_items.rs +++ b/generated/stripe_shared/src/invoices_resource_line_items_credited_items.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesResourceLineItemsCreditedItems { /// Invoice containing the credited invoice line items pub invoice: String, /// Credited invoice line items pub invoice_line_items: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesResourceLineItemsCreditedItemsBuilder { + invoice: Option<String>, + invoice_line_items: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesResourceLineItemsCreditedItems { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesResourceLineItemsCreditedItems>, + builder: InvoicesResourceLineItemsCreditedItemsBuilder, + } + + impl Visitor for Place<InvoicesResourceLineItemsCreditedItems> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesResourceLineItemsCreditedItemsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesResourceLineItemsCreditedItemsBuilder { + type Out = InvoicesResourceLineItemsCreditedItems; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "invoice" => Deserialize::begin(&mut self.invoice), + "invoice_line_items" => Deserialize::begin(&mut self.invoice_line_items), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { invoice: Deserialize::default(), invoice_line_items: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let invoice = self.invoice.take()?; + let invoice_line_items = self.invoice_line_items.take()?; + + Some(Self::Out { invoice, invoice_line_items }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesResourceLineItemsCreditedItems { + type Builder = InvoicesResourceLineItemsCreditedItemsBuilder; + } + + impl FromValueOpt for InvoicesResourceLineItemsCreditedItems { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesResourceLineItemsCreditedItemsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "invoice_line_items" => b.invoice_line_items = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoices_resource_line_items_proration_details.rs b/generated/stripe_shared/src/invoices_resource_line_items_proration_details.rs index ff08c0c51..1496c7b1c 100644 --- a/generated/stripe_shared/src/invoices_resource_line_items_proration_details.rs +++ b/generated/stripe_shared/src/invoices_resource_line_items_proration_details.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesResourceLineItemsProrationDetails { /// For a credit proration `line_item`, the original debit line_items to which the credit proration applies. pub credited_items: Option<stripe_shared::InvoicesResourceLineItemsCreditedItems>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesResourceLineItemsProrationDetailsBuilder { + credited_items: Option<Option<stripe_shared::InvoicesResourceLineItemsCreditedItems>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesResourceLineItemsProrationDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesResourceLineItemsProrationDetails>, + builder: InvoicesResourceLineItemsProrationDetailsBuilder, + } + + impl Visitor for Place<InvoicesResourceLineItemsProrationDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesResourceLineItemsProrationDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesResourceLineItemsProrationDetailsBuilder { + type Out = InvoicesResourceLineItemsProrationDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "credited_items" => Deserialize::begin(&mut self.credited_items), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { credited_items: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let credited_items = self.credited_items.take()?; + + Some(Self::Out { credited_items }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesResourceLineItemsProrationDetails { + type Builder = InvoicesResourceLineItemsProrationDetailsBuilder; + } + + impl FromValueOpt for InvoicesResourceLineItemsProrationDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesResourceLineItemsProrationDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "credited_items" => b.credited_items = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoices_shipping_cost.rs b/generated/stripe_shared/src/invoices_shipping_cost.rs index 944ab7de0..df542ab2f 100644 --- a/generated/stripe_shared/src/invoices_shipping_cost.rs +++ b/generated/stripe_shared/src/invoices_shipping_cost.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesShippingCost { /// Total shipping cost before any taxes are applied. pub amount_subtotal: i64, @@ -9,6 +11,113 @@ pub struct InvoicesShippingCost { /// The ID of the ShippingRate for this invoice. pub shipping_rate: Option<stripe_types::Expandable<stripe_shared::ShippingRate>>, /// The taxes applied to the shipping rate. - #[serde(skip_serializing_if = "Option::is_none")] pub taxes: Option<Vec<stripe_shared::LineItemsTaxAmount>>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesShippingCostBuilder { + amount_subtotal: Option<i64>, + amount_tax: Option<i64>, + amount_total: Option<i64>, + shipping_rate: Option<Option<stripe_types::Expandable<stripe_shared::ShippingRate>>>, + taxes: Option<Option<Vec<stripe_shared::LineItemsTaxAmount>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesShippingCost { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesShippingCost>, + builder: InvoicesShippingCostBuilder, + } + + impl Visitor for Place<InvoicesShippingCost> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesShippingCostBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesShippingCostBuilder { + type Out = InvoicesShippingCost; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "shipping_rate" => Deserialize::begin(&mut self.shipping_rate), + "taxes" => Deserialize::begin(&mut self.taxes), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_subtotal: Deserialize::default(), + amount_tax: Deserialize::default(), + amount_total: Deserialize::default(), + shipping_rate: Deserialize::default(), + taxes: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_subtotal = self.amount_subtotal.take()?; + let amount_tax = self.amount_tax.take()?; + let amount_total = self.amount_total.take()?; + let shipping_rate = self.shipping_rate.take()?; + let taxes = self.taxes.take()?; + + Some(Self::Out { amount_subtotal, amount_tax, amount_total, shipping_rate, taxes }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesShippingCost { + type Builder = InvoicesShippingCostBuilder; + } + + impl FromValueOpt for InvoicesShippingCost { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesShippingCostBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "shipping_rate" => b.shipping_rate = Some(FromValueOpt::from_value(v)?), + "taxes" => b.taxes = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/invoices_status_transitions.rs b/generated/stripe_shared/src/invoices_status_transitions.rs index 6f9935f05..a20238530 100644 --- a/generated/stripe_shared/src/invoices_status_transitions.rs +++ b/generated/stripe_shared/src/invoices_status_transitions.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InvoicesStatusTransitions { /// The time that the invoice draft was finalized. pub finalized_at: Option<stripe_types::Timestamp>, @@ -9,3 +11,101 @@ pub struct InvoicesStatusTransitions { /// The time that the invoice was voided. pub voided_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct InvoicesStatusTransitionsBuilder { + finalized_at: Option<Option<stripe_types::Timestamp>>, + marked_uncollectible_at: Option<Option<stripe_types::Timestamp>>, + paid_at: Option<Option<stripe_types::Timestamp>>, + voided_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InvoicesStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InvoicesStatusTransitions>, + builder: InvoicesStatusTransitionsBuilder, + } + + impl Visitor for Place<InvoicesStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InvoicesStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for InvoicesStatusTransitionsBuilder { + type Out = InvoicesStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "finalized_at" => Deserialize::begin(&mut self.finalized_at), + "marked_uncollectible_at" => Deserialize::begin(&mut self.marked_uncollectible_at), + "paid_at" => Deserialize::begin(&mut self.paid_at), + "voided_at" => Deserialize::begin(&mut self.voided_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { finalized_at: Deserialize::default(), marked_uncollectible_at: Deserialize::default(), paid_at: Deserialize::default(), voided_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let finalized_at = self.finalized_at.take()?; + let marked_uncollectible_at = self.marked_uncollectible_at.take()?; + let paid_at = self.paid_at.take()?; + let voided_at = self.voided_at.take()?; + + Some(Self::Out { finalized_at, marked_uncollectible_at, paid_at, voided_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InvoicesStatusTransitions { + type Builder = InvoicesStatusTransitionsBuilder; + } + + impl FromValueOpt for InvoicesStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoicesStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "finalized_at" => b.finalized_at = Some(FromValueOpt::from_value(v)?), + "marked_uncollectible_at" => b.marked_uncollectible_at = Some(FromValueOpt::from_value(v)?), + "paid_at" => b.paid_at = Some(FromValueOpt::from_value(v)?), + "voided_at" => b.voided_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_authorization.rs b/generated/stripe_shared/src/issuing_authorization.rs index e0d046fcb..09707f1f8 100644 --- a/generated/stripe_shared/src/issuing_authorization.rs +++ b/generated/stripe_shared/src/issuing_authorization.rs @@ -6,7 +6,9 @@ /// Related guide: [Issued card authorizations](https://stripe.com/docs/issuing/purchases/authorizations). /// /// For more details see <<https://stripe.com/docs/api/issuing/authorizations/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorization { /// The total amount that was authorized or rejected. /// This amount is in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). @@ -62,12 +64,10 @@ pub struct IssuingAuthorization { pub status: stripe_shared::IssuingAuthorizationStatus, /// [Token](https://stripe.com/docs/api/issuing/tokens/object) object used for this authorization. /// If a network token was not used for this authorization, this field will be null. - #[serde(skip_serializing_if = "Option::is_none")] pub token: Option<stripe_types::Expandable<stripe_shared::IssuingToken>>, /// List of [transactions](https://stripe.com/docs/api/issuing/transactions) associated with this authorization. pub transactions: Vec<stripe_shared::IssuingTransaction>, /// [Treasury](https://stripe.com/docs/api/treasury) details related to this authorization if it was created on a [FinancialAccount](https://stripe.com/docs/api/treasury/financial_accounts). - #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option<stripe_shared::IssuingAuthorizationTreasury>, pub verification_data: stripe_shared::IssuingAuthorizationVerificationData, /// The digital wallet used for this transaction. @@ -75,6 +75,234 @@ pub struct IssuingAuthorization { /// Will populate as `null` when no digital wallet was utilized. pub wallet: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationBuilder { + amount: Option<i64>, + amount_details: Option<Option<stripe_shared::IssuingAuthorizationAmountDetails>>, + approved: Option<bool>, + authorization_method: Option<stripe_shared::IssuingAuthorizationAuthorizationMethod>, + balance_transactions: Option<Vec<stripe_shared::BalanceTransaction>>, + card: Option<stripe_shared::IssuingCard>, + cardholder: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCardholder>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + id: Option<stripe_shared::IssuingAuthorizationId>, + livemode: Option<bool>, + merchant_amount: Option<i64>, + merchant_currency: Option<stripe_types::Currency>, + merchant_data: Option<stripe_shared::IssuingAuthorizationMerchantData>, + metadata: Option<std::collections::HashMap<String, String>>, + network_data: Option<Option<stripe_shared::IssuingAuthorizationNetworkData>>, + pending_request: Option<Option<stripe_shared::IssuingAuthorizationPendingRequest>>, + request_history: Option<Vec<stripe_shared::IssuingAuthorizationRequest>>, + status: Option<stripe_shared::IssuingAuthorizationStatus>, + token: Option<Option<stripe_types::Expandable<stripe_shared::IssuingToken>>>, + transactions: Option<Vec<stripe_shared::IssuingTransaction>>, + treasury: Option<Option<stripe_shared::IssuingAuthorizationTreasury>>, + verification_data: Option<stripe_shared::IssuingAuthorizationVerificationData>, + wallet: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorization { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorization>, + builder: IssuingAuthorizationBuilder, + } + + impl Visitor for Place<IssuingAuthorization> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationBuilder { + type Out = IssuingAuthorization; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_details" => Deserialize::begin(&mut self.amount_details), + "approved" => Deserialize::begin(&mut self.approved), + "authorization_method" => Deserialize::begin(&mut self.authorization_method), + "balance_transactions" => Deserialize::begin(&mut self.balance_transactions), + "card" => Deserialize::begin(&mut self.card), + "cardholder" => Deserialize::begin(&mut self.cardholder), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "merchant_amount" => Deserialize::begin(&mut self.merchant_amount), + "merchant_currency" => Deserialize::begin(&mut self.merchant_currency), + "merchant_data" => Deserialize::begin(&mut self.merchant_data), + "metadata" => Deserialize::begin(&mut self.metadata), + "network_data" => Deserialize::begin(&mut self.network_data), + "pending_request" => Deserialize::begin(&mut self.pending_request), + "request_history" => Deserialize::begin(&mut self.request_history), + "status" => Deserialize::begin(&mut self.status), + "token" => Deserialize::begin(&mut self.token), + "transactions" => Deserialize::begin(&mut self.transactions), + "treasury" => Deserialize::begin(&mut self.treasury), + "verification_data" => Deserialize::begin(&mut self.verification_data), + "wallet" => Deserialize::begin(&mut self.wallet), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_details: Deserialize::default(), + approved: Deserialize::default(), + authorization_method: Deserialize::default(), + balance_transactions: Deserialize::default(), + card: Deserialize::default(), + cardholder: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + merchant_amount: Deserialize::default(), + merchant_currency: Deserialize::default(), + merchant_data: Deserialize::default(), + metadata: Deserialize::default(), + network_data: Deserialize::default(), + pending_request: Deserialize::default(), + request_history: Deserialize::default(), + status: Deserialize::default(), + token: Deserialize::default(), + transactions: Deserialize::default(), + treasury: Deserialize::default(), + verification_data: Deserialize::default(), + wallet: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_details = self.amount_details.take()?; + let approved = self.approved.take()?; + let authorization_method = self.authorization_method.take()?; + let balance_transactions = self.balance_transactions.take()?; + let card = self.card.take()?; + let cardholder = self.cardholder.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let merchant_amount = self.merchant_amount.take()?; + let merchant_currency = self.merchant_currency.take()?; + let merchant_data = self.merchant_data.take()?; + let metadata = self.metadata.take()?; + let network_data = self.network_data.take()?; + let pending_request = self.pending_request.take()?; + let request_history = self.request_history.take()?; + let status = self.status.take()?; + let token = self.token.take()?; + let transactions = self.transactions.take()?; + let treasury = self.treasury.take()?; + let verification_data = self.verification_data.take()?; + let wallet = self.wallet.take()?; + + Some(Self::Out { + amount, + amount_details, + approved, + authorization_method, + balance_transactions, + card, + cardholder, + created, + currency, + id, + livemode, + merchant_amount, + merchant_currency, + merchant_data, + metadata, + network_data, + pending_request, + request_history, + status, + token, + transactions, + treasury, + verification_data, + wallet, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorization { + type Builder = IssuingAuthorizationBuilder; + } + + impl FromValueOpt for IssuingAuthorization { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_details" => b.amount_details = Some(FromValueOpt::from_value(v)?), + "approved" => b.approved = Some(FromValueOpt::from_value(v)?), + "authorization_method" => b.authorization_method = Some(FromValueOpt::from_value(v)?), + "balance_transactions" => b.balance_transactions = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "cardholder" => b.cardholder = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "merchant_amount" => b.merchant_amount = Some(FromValueOpt::from_value(v)?), + "merchant_currency" => b.merchant_currency = Some(FromValueOpt::from_value(v)?), + "merchant_data" => b.merchant_data = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "network_data" => b.network_data = Some(FromValueOpt::from_value(v)?), + "pending_request" => b.pending_request = Some(FromValueOpt::from_value(v)?), + "request_history" => b.request_history = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "token" => b.token = Some(FromValueOpt::from_value(v)?), + "transactions" => b.transactions = Some(FromValueOpt::from_value(v)?), + "treasury" => b.treasury = Some(FromValueOpt::from_value(v)?), + "verification_data" => b.verification_data = Some(FromValueOpt::from_value(v)?), + "wallet" => b.wallet = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for IssuingAuthorization { type Id = stripe_shared::IssuingAuthorizationId; fn id(&self) -> &Self::Id { @@ -140,11 +368,27 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthorizationMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingAuthorizationAuthorizationMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationAuthorizationMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationAuthorizationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationAuthorizationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationAuthorizationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthorizationMethod); #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationStatus { Closed, @@ -197,7 +441,24 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationStatus); diff --git a/generated/stripe_shared/src/issuing_authorization_amount_details.rs b/generated/stripe_shared/src/issuing_authorization_amount_details.rs index f4d63c2f2..d85c7436a 100644 --- a/generated/stripe_shared/src/issuing_authorization_amount_details.rs +++ b/generated/stripe_shared/src/issuing_authorization_amount_details.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationAmountDetails { /// The fee charged by the ATM for the cash withdrawal. pub atm_fee: Option<i64>, /// The amount of cash requested by the cardholder. pub cashback_amount: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationAmountDetailsBuilder { + atm_fee: Option<Option<i64>>, + cashback_amount: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationAmountDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationAmountDetails>, + builder: IssuingAuthorizationAmountDetailsBuilder, + } + + impl Visitor for Place<IssuingAuthorizationAmountDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationAmountDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationAmountDetailsBuilder { + type Out = IssuingAuthorizationAmountDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "atm_fee" => Deserialize::begin(&mut self.atm_fee), + "cashback_amount" => Deserialize::begin(&mut self.cashback_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { atm_fee: Deserialize::default(), cashback_amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let atm_fee = self.atm_fee.take()?; + let cashback_amount = self.cashback_amount.take()?; + + Some(Self::Out { atm_fee, cashback_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationAmountDetails { + type Builder = IssuingAuthorizationAmountDetailsBuilder; + } + + impl FromValueOpt for IssuingAuthorizationAmountDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationAmountDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "atm_fee" => b.atm_fee = Some(FromValueOpt::from_value(v)?), + "cashback_amount" => b.cashback_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_authorization_authentication_exemption.rs b/generated/stripe_shared/src/issuing_authorization_authentication_exemption.rs index b359c3008..39ae6ffa7 100644 --- a/generated/stripe_shared/src/issuing_authorization_authentication_exemption.rs +++ b/generated/stripe_shared/src/issuing_authorization_authentication_exemption.rs @@ -1,11 +1,103 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationAuthenticationExemption { /// The entity that requested the exemption, either the acquiring merchant or the Issuing user. pub claimed_by: IssuingAuthorizationAuthenticationExemptionClaimedBy, /// The specific exemption claimed for this authorization. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: IssuingAuthorizationAuthenticationExemptionType, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationAuthenticationExemptionBuilder { + claimed_by: Option<IssuingAuthorizationAuthenticationExemptionClaimedBy>, + type_: Option<IssuingAuthorizationAuthenticationExemptionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationAuthenticationExemption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationAuthenticationExemption>, + builder: IssuingAuthorizationAuthenticationExemptionBuilder, + } + + impl Visitor for Place<IssuingAuthorizationAuthenticationExemption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationAuthenticationExemptionBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationAuthenticationExemptionBuilder { + type Out = IssuingAuthorizationAuthenticationExemption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "claimed_by" => Deserialize::begin(&mut self.claimed_by), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { claimed_by: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let claimed_by = self.claimed_by.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { claimed_by, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationAuthenticationExemption { + type Builder = IssuingAuthorizationAuthenticationExemptionBuilder; + } + + impl FromValueOpt for IssuingAuthorizationAuthenticationExemption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationAuthenticationExemptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "claimed_by" => b.claimed_by = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The entity that requested the exemption, either the acquiring merchant or the Issuing user. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationAuthenticationExemptionClaimedBy { @@ -56,19 +148,32 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthenticationExemptio fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingAuthorizationAuthenticationExemptionClaimedBy", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationAuthenticationExemptionClaimedBy")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationAuthenticationExemptionClaimedBy { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationAuthenticationExemptionClaimedBy> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationAuthenticationExemptionClaimedBy::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthenticationExemptionClaimedBy); /// The specific exemption claimed for this authorization. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationAuthenticationExemptionType { LowValueTransaction, TransactionRiskAnalysis, - Unknown, } impl IssuingAuthorizationAuthenticationExemptionType { pub fn as_str(self) -> &'static str { @@ -76,7 +181,6 @@ impl IssuingAuthorizationAuthenticationExemptionType { match self { LowValueTransaction => "low_value_transaction", TransactionRiskAnalysis => "transaction_risk_analysis", - Unknown => "unknown", } } } @@ -88,7 +192,6 @@ impl std::str::FromStr for IssuingAuthorizationAuthenticationExemptionType { match s { "low_value_transaction" => Ok(LowValueTransaction), "transaction_risk_analysis" => Ok(TransactionRiskAnalysis), - "unknown" => Ok(Unknown), _ => Err(()), } } @@ -116,10 +219,24 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthenticationExemptio fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingAuthorizationAuthenticationExemptionType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationAuthenticationExemptionType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationAuthenticationExemptionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationAuthenticationExemptionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationAuthenticationExemptionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthenticationExemptionType); diff --git a/generated/stripe_shared/src/issuing_authorization_merchant_data.rs b/generated/stripe_shared/src/issuing_authorization_merchant_data.rs index b88adc535..ad2cc3dd3 100644 --- a/generated/stripe_shared/src/issuing_authorization_merchant_data.rs +++ b/generated/stripe_shared/src/issuing_authorization_merchant_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationMerchantData { /// A categorization of the seller's type of business. /// See our [merchant categories guide](https://stripe.com/docs/issuing/merchant-categories) for a list of possible values. @@ -23,3 +25,136 @@ pub struct IssuingAuthorizationMerchantData { /// URL provided by the merchant on a 3DS request pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationMerchantDataBuilder { + category: Option<String>, + category_code: Option<String>, + city: Option<Option<String>>, + country: Option<Option<String>>, + name: Option<Option<String>>, + network_id: Option<String>, + postal_code: Option<Option<String>>, + state: Option<Option<String>>, + terminal_id: Option<Option<String>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationMerchantData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationMerchantData>, + builder: IssuingAuthorizationMerchantDataBuilder, + } + + impl Visitor for Place<IssuingAuthorizationMerchantData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationMerchantDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationMerchantDataBuilder { + type Out = IssuingAuthorizationMerchantData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "category" => Deserialize::begin(&mut self.category), + "category_code" => Deserialize::begin(&mut self.category_code), + "city" => Deserialize::begin(&mut self.city), + "country" => Deserialize::begin(&mut self.country), + "name" => Deserialize::begin(&mut self.name), + "network_id" => Deserialize::begin(&mut self.network_id), + "postal_code" => Deserialize::begin(&mut self.postal_code), + "state" => Deserialize::begin(&mut self.state), + "terminal_id" => Deserialize::begin(&mut self.terminal_id), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + category: Deserialize::default(), + category_code: Deserialize::default(), + city: Deserialize::default(), + country: Deserialize::default(), + name: Deserialize::default(), + network_id: Deserialize::default(), + postal_code: Deserialize::default(), + state: Deserialize::default(), + terminal_id: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let category = self.category.take()?; + let category_code = self.category_code.take()?; + let city = self.city.take()?; + let country = self.country.take()?; + let name = self.name.take()?; + let network_id = self.network_id.take()?; + let postal_code = self.postal_code.take()?; + let state = self.state.take()?; + let terminal_id = self.terminal_id.take()?; + let url = self.url.take()?; + + Some(Self::Out { category, category_code, city, country, name, network_id, postal_code, state, terminal_id, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationMerchantData { + type Builder = IssuingAuthorizationMerchantDataBuilder; + } + + impl FromValueOpt for IssuingAuthorizationMerchantData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationMerchantDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "category" => b.category = Some(FromValueOpt::from_value(v)?), + "category_code" => b.category_code = Some(FromValueOpt::from_value(v)?), + "city" => b.city = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "network_id" => b.network_id = Some(FromValueOpt::from_value(v)?), + "postal_code" => b.postal_code = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + "terminal_id" => b.terminal_id = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_authorization_network_data.rs b/generated/stripe_shared/src/issuing_authorization_network_data.rs index dae11162c..002b5cf2f 100644 --- a/generated/stripe_shared/src/issuing_authorization_network_data.rs +++ b/generated/stripe_shared/src/issuing_authorization_network_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationNetworkData { /// Identifier assigned to the acquirer by the card network. /// Sometimes this value is not provided by the network; in this case, the value will be `null`. @@ -9,3 +11,97 @@ pub struct IssuingAuthorizationNetworkData { /// Unique identifier for the authorization assigned by the card network used to match subsequent messages, disputes, and transactions. pub transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationNetworkDataBuilder { + acquiring_institution_id: Option<Option<String>>, + system_trace_audit_number: Option<Option<String>>, + transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationNetworkData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationNetworkData>, + builder: IssuingAuthorizationNetworkDataBuilder, + } + + impl Visitor for Place<IssuingAuthorizationNetworkData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationNetworkDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationNetworkDataBuilder { + type Out = IssuingAuthorizationNetworkData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acquiring_institution_id" => Deserialize::begin(&mut self.acquiring_institution_id), + "system_trace_audit_number" => Deserialize::begin(&mut self.system_trace_audit_number), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { acquiring_institution_id: Deserialize::default(), system_trace_audit_number: Deserialize::default(), transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acquiring_institution_id = self.acquiring_institution_id.take()?; + let system_trace_audit_number = self.system_trace_audit_number.take()?; + let transaction_id = self.transaction_id.take()?; + + Some(Self::Out { acquiring_institution_id, system_trace_audit_number, transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationNetworkData { + type Builder = IssuingAuthorizationNetworkDataBuilder; + } + + impl FromValueOpt for IssuingAuthorizationNetworkData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationNetworkDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acquiring_institution_id" => b.acquiring_institution_id = Some(FromValueOpt::from_value(v)?), + "system_trace_audit_number" => b.system_trace_audit_number = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_authorization_pending_request.rs b/generated/stripe_shared/src/issuing_authorization_pending_request.rs index 6f6b1f49f..2a04719de 100644 --- a/generated/stripe_shared/src/issuing_authorization_pending_request.rs +++ b/generated/stripe_shared/src/issuing_authorization_pending_request.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationPendingRequest { /// The additional amount Stripe will hold if the authorization is approved, in the card's [currency](https://stripe.com/docs/api#issuing_authorization_object-pending-request-currency) and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub amount: i64, @@ -19,3 +21,121 @@ pub struct IssuingAuthorizationPendingRequest { /// Takes on values between 1 and 99. pub network_risk_score: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationPendingRequestBuilder { + amount: Option<i64>, + amount_details: Option<Option<stripe_shared::IssuingAuthorizationAmountDetails>>, + currency: Option<stripe_types::Currency>, + is_amount_controllable: Option<bool>, + merchant_amount: Option<i64>, + merchant_currency: Option<stripe_types::Currency>, + network_risk_score: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationPendingRequest { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationPendingRequest>, + builder: IssuingAuthorizationPendingRequestBuilder, + } + + impl Visitor for Place<IssuingAuthorizationPendingRequest> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationPendingRequestBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationPendingRequestBuilder { + type Out = IssuingAuthorizationPendingRequest; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_details" => Deserialize::begin(&mut self.amount_details), + "currency" => Deserialize::begin(&mut self.currency), + "is_amount_controllable" => Deserialize::begin(&mut self.is_amount_controllable), + "merchant_amount" => Deserialize::begin(&mut self.merchant_amount), + "merchant_currency" => Deserialize::begin(&mut self.merchant_currency), + "network_risk_score" => Deserialize::begin(&mut self.network_risk_score), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_details: Deserialize::default(), + currency: Deserialize::default(), + is_amount_controllable: Deserialize::default(), + merchant_amount: Deserialize::default(), + merchant_currency: Deserialize::default(), + network_risk_score: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_details = self.amount_details.take()?; + let currency = self.currency.take()?; + let is_amount_controllable = self.is_amount_controllable.take()?; + let merchant_amount = self.merchant_amount.take()?; + let merchant_currency = self.merchant_currency.take()?; + let network_risk_score = self.network_risk_score.take()?; + + Some(Self::Out { amount, amount_details, currency, is_amount_controllable, merchant_amount, merchant_currency, network_risk_score }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationPendingRequest { + type Builder = IssuingAuthorizationPendingRequestBuilder; + } + + impl FromValueOpt for IssuingAuthorizationPendingRequest { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationPendingRequestBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_details" => b.amount_details = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "is_amount_controllable" => b.is_amount_controllable = Some(FromValueOpt::from_value(v)?), + "merchant_amount" => b.merchant_amount = Some(FromValueOpt::from_value(v)?), + "merchant_currency" => b.merchant_currency = Some(FromValueOpt::from_value(v)?), + "network_risk_score" => b.network_risk_score = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_authorization_request.rs b/generated/stripe_shared/src/issuing_authorization_request.rs index 406ac98d0..10c5420ba 100644 --- a/generated/stripe_shared/src/issuing_authorization_request.rs +++ b/generated/stripe_shared/src/issuing_authorization_request.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationRequest { /// The `pending_request.amount` at the time of the request, presented in your card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// Stripe held this amount from your account to fund the authorization if the request was approved. @@ -36,6 +38,149 @@ pub struct IssuingAuthorizationRequest { /// Referred to by networks as transmission time. pub requested_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationRequestBuilder { + amount: Option<i64>, + amount_details: Option<Option<stripe_shared::IssuingAuthorizationAmountDetails>>, + approved: Option<bool>, + authorization_code: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + merchant_amount: Option<i64>, + merchant_currency: Option<stripe_types::Currency>, + network_risk_score: Option<Option<i64>>, + reason: Option<IssuingAuthorizationRequestReason>, + reason_message: Option<Option<String>>, + requested_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationRequest { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationRequest>, + builder: IssuingAuthorizationRequestBuilder, + } + + impl Visitor for Place<IssuingAuthorizationRequest> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationRequestBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationRequestBuilder { + type Out = IssuingAuthorizationRequest; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_details" => Deserialize::begin(&mut self.amount_details), + "approved" => Deserialize::begin(&mut self.approved), + "authorization_code" => Deserialize::begin(&mut self.authorization_code), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "merchant_amount" => Deserialize::begin(&mut self.merchant_amount), + "merchant_currency" => Deserialize::begin(&mut self.merchant_currency), + "network_risk_score" => Deserialize::begin(&mut self.network_risk_score), + "reason" => Deserialize::begin(&mut self.reason), + "reason_message" => Deserialize::begin(&mut self.reason_message), + "requested_at" => Deserialize::begin(&mut self.requested_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_details: Deserialize::default(), + approved: Deserialize::default(), + authorization_code: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + merchant_amount: Deserialize::default(), + merchant_currency: Deserialize::default(), + network_risk_score: Deserialize::default(), + reason: Deserialize::default(), + reason_message: Deserialize::default(), + requested_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_details = self.amount_details.take()?; + let approved = self.approved.take()?; + let authorization_code = self.authorization_code.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let merchant_amount = self.merchant_amount.take()?; + let merchant_currency = self.merchant_currency.take()?; + let network_risk_score = self.network_risk_score.take()?; + let reason = self.reason.take()?; + let reason_message = self.reason_message.take()?; + let requested_at = self.requested_at.take()?; + + Some(Self::Out { amount, amount_details, approved, authorization_code, created, currency, merchant_amount, merchant_currency, network_risk_score, reason, reason_message, requested_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationRequest { + type Builder = IssuingAuthorizationRequestBuilder; + } + + impl FromValueOpt for IssuingAuthorizationRequest { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationRequestBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_details" => b.amount_details = Some(FromValueOpt::from_value(v)?), + "approved" => b.approved = Some(FromValueOpt::from_value(v)?), + "authorization_code" => b.authorization_code = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "merchant_amount" => b.merchant_amount = Some(FromValueOpt::from_value(v)?), + "merchant_currency" => b.merchant_currency = Some(FromValueOpt::from_value(v)?), + "network_risk_score" => b.network_risk_score = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "reason_message" => b.reason_message = Some(FromValueOpt::from_value(v)?), + "requested_at" => b.requested_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// When an authorization is approved or declined by you or by Stripe, this field provides additional detail on the reason for the outcome. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -126,6 +271,24 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationRequestReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(IssuingAuthorizationRequestReason::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationRequestReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationRequestReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationRequestReason::from_str(s).unwrap_or(IssuingAuthorizationRequestReason::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationRequestReason); diff --git a/generated/stripe_shared/src/issuing_authorization_three_d_secure.rs b/generated/stripe_shared/src/issuing_authorization_three_d_secure.rs index 30b56e6bc..55fbddbce 100644 --- a/generated/stripe_shared/src/issuing_authorization_three_d_secure.rs +++ b/generated/stripe_shared/src/issuing_authorization_three_d_secure.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationThreeDSecure { /// The outcome of the 3D Secure authentication request. pub result: IssuingAuthorizationThreeDSecureResult, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationThreeDSecureBuilder { + result: Option<IssuingAuthorizationThreeDSecureResult>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationThreeDSecure { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationThreeDSecure>, + builder: IssuingAuthorizationThreeDSecureBuilder, + } + + impl Visitor for Place<IssuingAuthorizationThreeDSecure> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationThreeDSecureBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationThreeDSecureBuilder { + type Out = IssuingAuthorizationThreeDSecure; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "result" => Deserialize::begin(&mut self.result), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { result: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let result = self.result.take()?; + + Some(Self::Out { result }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationThreeDSecure { + type Builder = IssuingAuthorizationThreeDSecureBuilder; + } + + impl FromValueOpt for IssuingAuthorizationThreeDSecure { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationThreeDSecureBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "result" => b.result = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The outcome of the 3D Secure authentication request. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationThreeDSecureResult { @@ -59,8 +147,24 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationThreeDSecureResult { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingAuthorizationThreeDSecureResult") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationThreeDSecureResult")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationThreeDSecureResult { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationThreeDSecureResult> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationThreeDSecureResult::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationThreeDSecureResult); diff --git a/generated/stripe_shared/src/issuing_authorization_treasury.rs b/generated/stripe_shared/src/issuing_authorization_treasury.rs index 58eac0bde..79a5a39a9 100644 --- a/generated/stripe_shared/src/issuing_authorization_treasury.rs +++ b/generated/stripe_shared/src/issuing_authorization_treasury.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationTreasury { /// The array of [ReceivedCredits](https://stripe.com/docs/api/treasury/received_credits) associated with this authorization. pub received_credits: Vec<String>, @@ -7,3 +9,97 @@ pub struct IssuingAuthorizationTreasury { /// The Treasury [Transaction](https://stripe.com/docs/api/treasury/transactions) associated with this authorization. pub transaction: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationTreasuryBuilder { + received_credits: Option<Vec<String>>, + received_debits: Option<Vec<String>>, + transaction: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationTreasury { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationTreasury>, + builder: IssuingAuthorizationTreasuryBuilder, + } + + impl Visitor for Place<IssuingAuthorizationTreasury> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationTreasuryBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationTreasuryBuilder { + type Out = IssuingAuthorizationTreasury; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "received_credits" => Deserialize::begin(&mut self.received_credits), + "received_debits" => Deserialize::begin(&mut self.received_debits), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { received_credits: Deserialize::default(), received_debits: Deserialize::default(), transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let received_credits = self.received_credits.take()?; + let received_debits = self.received_debits.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { received_credits, received_debits, transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationTreasury { + type Builder = IssuingAuthorizationTreasuryBuilder; + } + + impl FromValueOpt for IssuingAuthorizationTreasury { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationTreasuryBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "received_credits" => b.received_credits = Some(FromValueOpt::from_value(v)?), + "received_debits" => b.received_debits = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_authorization_verification_data.rs b/generated/stripe_shared/src/issuing_authorization_verification_data.rs index 80e7ed58e..726a5e2e5 100644 --- a/generated/stripe_shared/src/issuing_authorization_verification_data.rs +++ b/generated/stripe_shared/src/issuing_authorization_verification_data.rs @@ -1,12 +1,13 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingAuthorizationVerificationData { /// Whether the cardholder provided an address first line and if it matched the cardholder’s `billing.address.line1`. pub address_line1_check: IssuingAuthorizationVerificationDataAddressLine1Check, /// Whether the cardholder provided a postal code and if it matched the cardholder’s `billing.address.postal_code`. pub address_postal_code_check: IssuingAuthorizationVerificationDataAddressPostalCodeCheck, /// The exemption applied to this authorization. - pub authentication_exemption: - Option<stripe_shared::IssuingAuthorizationAuthenticationExemption>, + pub authentication_exemption: Option<stripe_shared::IssuingAuthorizationAuthenticationExemption>, /// Whether the cardholder provided a CVC and if it matched Stripe’s record. pub cvc_check: IssuingAuthorizationVerificationDataCvcCheck, /// Whether the cardholder provided an expiry date and if it matched Stripe’s record. @@ -16,6 +17,124 @@ pub struct IssuingAuthorizationVerificationData { /// 3D Secure details. pub three_d_secure: Option<stripe_shared::IssuingAuthorizationThreeDSecure>, } +#[cfg(feature = "min-ser")] +pub struct IssuingAuthorizationVerificationDataBuilder { + address_line1_check: Option<IssuingAuthorizationVerificationDataAddressLine1Check>, + address_postal_code_check: Option<IssuingAuthorizationVerificationDataAddressPostalCodeCheck>, + authentication_exemption: Option<Option<stripe_shared::IssuingAuthorizationAuthenticationExemption>>, + cvc_check: Option<IssuingAuthorizationVerificationDataCvcCheck>, + expiry_check: Option<IssuingAuthorizationVerificationDataExpiryCheck>, + postal_code: Option<Option<String>>, + three_d_secure: Option<Option<stripe_shared::IssuingAuthorizationThreeDSecure>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingAuthorizationVerificationData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingAuthorizationVerificationData>, + builder: IssuingAuthorizationVerificationDataBuilder, + } + + impl Visitor for Place<IssuingAuthorizationVerificationData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingAuthorizationVerificationDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingAuthorizationVerificationDataBuilder { + type Out = IssuingAuthorizationVerificationData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address_line1_check" => Deserialize::begin(&mut self.address_line1_check), + "address_postal_code_check" => Deserialize::begin(&mut self.address_postal_code_check), + "authentication_exemption" => Deserialize::begin(&mut self.authentication_exemption), + "cvc_check" => Deserialize::begin(&mut self.cvc_check), + "expiry_check" => Deserialize::begin(&mut self.expiry_check), + "postal_code" => Deserialize::begin(&mut self.postal_code), + "three_d_secure" => Deserialize::begin(&mut self.three_d_secure), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address_line1_check: Deserialize::default(), + address_postal_code_check: Deserialize::default(), + authentication_exemption: Deserialize::default(), + cvc_check: Deserialize::default(), + expiry_check: Deserialize::default(), + postal_code: Deserialize::default(), + three_d_secure: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address_line1_check = self.address_line1_check.take()?; + let address_postal_code_check = self.address_postal_code_check.take()?; + let authentication_exemption = self.authentication_exemption.take()?; + let cvc_check = self.cvc_check.take()?; + let expiry_check = self.expiry_check.take()?; + let postal_code = self.postal_code.take()?; + let three_d_secure = self.three_d_secure.take()?; + + Some(Self::Out { address_line1_check, address_postal_code_check, authentication_exemption, cvc_check, expiry_check, postal_code, three_d_secure }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingAuthorizationVerificationData { + type Builder = IssuingAuthorizationVerificationDataBuilder; + } + + impl FromValueOpt for IssuingAuthorizationVerificationData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingAuthorizationVerificationDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address_line1_check" => b.address_line1_check = Some(FromValueOpt::from_value(v)?), + "address_postal_code_check" => b.address_postal_code_check = Some(FromValueOpt::from_value(v)?), + "authentication_exemption" => b.authentication_exemption = Some(FromValueOpt::from_value(v)?), + "cvc_check" => b.cvc_check = Some(FromValueOpt::from_value(v)?), + "expiry_check" => b.expiry_check = Some(FromValueOpt::from_value(v)?), + "postal_code" => b.postal_code = Some(FromValueOpt::from_value(v)?), + "three_d_secure" => b.three_d_secure = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether the cardholder provided an address first line and if it matched the cardholder’s `billing.address.line1`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationVerificationDataAddressLine1Check { @@ -69,13 +188,27 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddres fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingAuthorizationVerificationDataAddressLine1Check", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationVerificationDataAddressLine1Check")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressLine1Check { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataAddressLine1Check> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationVerificationDataAddressLine1Check::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataAddressLine1Check); /// Whether the cardholder provided a postal code and if it matched the cardholder’s `billing.address.postal_code`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationVerificationDataAddressPostalCodeCheck { @@ -129,13 +262,27 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddres fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingAuthorizationVerificationDataAddressPostalCodeCheck", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationVerificationDataAddressPostalCodeCheck")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressPostalCodeCheck { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataAddressPostalCodeCheck> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationVerificationDataAddressPostalCodeCheck::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataAddressPostalCodeCheck); /// Whether the cardholder provided a CVC and if it matched Stripe’s record. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationVerificationDataCvcCheck { @@ -189,13 +336,27 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataCvcChe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingAuthorizationVerificationDataCvcCheck", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationVerificationDataCvcCheck")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataCvcCheck { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataCvcCheck> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationVerificationDataCvcCheck::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataCvcCheck); /// Whether the cardholder provided an expiry date and if it matched Stripe’s record. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingAuthorizationVerificationDataExpiryCheck { @@ -249,10 +410,24 @@ impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataExpiry fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingAuthorizationVerificationDataExpiryCheck", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingAuthorizationVerificationDataExpiryCheck")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataExpiryCheck { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingAuthorizationVerificationDataExpiryCheck> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationVerificationDataExpiryCheck::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataExpiryCheck); diff --git a/generated/stripe_shared/src/issuing_card.rs b/generated/stripe_shared/src/issuing_card.rs index 27602fc82..cf5199f57 100644 --- a/generated/stripe_shared/src/issuing_card.rs +++ b/generated/stripe_shared/src/issuing_card.rs @@ -1,7 +1,9 @@ /// You can [create physical or virtual cards](https://stripe.com/docs/issuing/cards) that are issued to cardholders. /// /// For more details see <<https://stripe.com/docs/api/issuing/cards/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCard { /// The brand of the card. pub brand: String, @@ -16,14 +18,12 @@ pub struct IssuingCard { /// The card's CVC. /// For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://stripe.com/docs/api/expanding_objects). /// Additionally, it's only available via the ["Retrieve a card" endpoint](https://stripe.com/docs/api/issuing/cards/retrieve), not via "List all cards" or any other endpoint. - #[serde(skip_serializing_if = "Option::is_none")] pub cvc: Option<String>, /// The expiration month of the card. pub exp_month: i64, /// The expiration year of the card. pub exp_year: i64, /// The financial account this card is attached to. - #[serde(skip_serializing_if = "Option::is_none")] pub financial_account: Option<String>, /// Unique identifier for the object. pub id: stripe_shared::IssuingCardId, @@ -37,7 +37,6 @@ pub struct IssuingCard { /// The full unredacted card number. /// For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with [the `expand` parameter](https://stripe.com/docs/api/expanding_objects). /// Additionally, it's only available via the ["Retrieve a card" endpoint](https://stripe.com/docs/api/issuing/cards/retrieve), not via "List all cards" or any other endpoint. - #[serde(skip_serializing_if = "Option::is_none")] pub number: Option<String>, /// The latest card that replaces this card, if any. pub replaced_by: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>, @@ -53,11 +52,227 @@ pub struct IssuingCard { /// Defaults to `inactive`. pub status: stripe_shared::IssuingCardStatus, /// The type of the card. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_shared::IssuingCardType, /// Information relating to digital wallets (like Apple Pay and Google Pay). pub wallets: Option<stripe_shared::IssuingCardWallets>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardBuilder { + brand: Option<String>, + cancellation_reason: Option<Option<IssuingCardCancellationReason>>, + cardholder: Option<stripe_shared::IssuingCardholder>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + cvc: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + financial_account: Option<Option<String>>, + id: Option<stripe_shared::IssuingCardId>, + last4: Option<String>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + number: Option<Option<String>>, + replaced_by: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCard>>>, + replacement_for: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCard>>>, + replacement_reason: Option<Option<stripe_shared::IssuingCardReplacementReason>>, + shipping: Option<Option<stripe_shared::IssuingCardShipping>>, + spending_controls: Option<stripe_shared::IssuingCardAuthorizationControls>, + status: Option<stripe_shared::IssuingCardStatus>, + type_: Option<stripe_shared::IssuingCardType>, + wallets: Option<Option<stripe_shared::IssuingCardWallets>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCard>, + builder: IssuingCardBuilder, + } + + impl Visitor for Place<IssuingCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardBuilder { + type Out = IssuingCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "brand" => Deserialize::begin(&mut self.brand), + "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason), + "cardholder" => Deserialize::begin(&mut self.cardholder), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "cvc" => Deserialize::begin(&mut self.cvc), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "id" => Deserialize::begin(&mut self.id), + "last4" => Deserialize::begin(&mut self.last4), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "number" => Deserialize::begin(&mut self.number), + "replaced_by" => Deserialize::begin(&mut self.replaced_by), + "replacement_for" => Deserialize::begin(&mut self.replacement_for), + "replacement_reason" => Deserialize::begin(&mut self.replacement_reason), + "shipping" => Deserialize::begin(&mut self.shipping), + "spending_controls" => Deserialize::begin(&mut self.spending_controls), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + "wallets" => Deserialize::begin(&mut self.wallets), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + brand: Deserialize::default(), + cancellation_reason: Deserialize::default(), + cardholder: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + cvc: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + financial_account: Deserialize::default(), + id: Deserialize::default(), + last4: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + number: Deserialize::default(), + replaced_by: Deserialize::default(), + replacement_for: Deserialize::default(), + replacement_reason: Deserialize::default(), + shipping: Deserialize::default(), + spending_controls: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + wallets: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let brand = self.brand.take()?; + let cancellation_reason = self.cancellation_reason.take()?; + let cardholder = self.cardholder.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let cvc = self.cvc.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let financial_account = self.financial_account.take()?; + let id = self.id.take()?; + let last4 = self.last4.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let number = self.number.take()?; + let replaced_by = self.replaced_by.take()?; + let replacement_for = self.replacement_for.take()?; + let replacement_reason = self.replacement_reason.take()?; + let shipping = self.shipping.take()?; + let spending_controls = self.spending_controls.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + let wallets = self.wallets.take()?; + + Some(Self::Out { + brand, + cancellation_reason, + cardholder, + created, + currency, + cvc, + exp_month, + exp_year, + financial_account, + id, + last4, + livemode, + metadata, + number, + replaced_by, + replacement_for, + replacement_reason, + shipping, + spending_controls, + status, + type_, + wallets, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCard { + type Builder = IssuingCardBuilder; + } + + impl FromValueOpt for IssuingCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "cancellation_reason" => b.cancellation_reason = Some(FromValueOpt::from_value(v)?), + "cardholder" => b.cardholder = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "cvc" => b.cvc = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "number" => b.number = Some(FromValueOpt::from_value(v)?), + "replaced_by" => b.replaced_by = Some(FromValueOpt::from_value(v)?), + "replacement_for" => b.replacement_for = Some(FromValueOpt::from_value(v)?), + "replacement_reason" => b.replacement_reason = Some(FromValueOpt::from_value(v)?), + "shipping" => b.shipping = Some(FromValueOpt::from_value(v)?), + "spending_controls" => b.spending_controls = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "wallets" => b.wallets = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reason why the card was canceled. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardCancellationReason { @@ -111,11 +326,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardCancellationReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingCardCancellationReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardCancellationReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardCancellationReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardCancellationReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardCancellationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardCancellationReason); impl stripe_types::Object for IssuingCard { type Id = stripe_shared::IssuingCardId; fn id(&self) -> &Self::Id { @@ -178,10 +409,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardReplacementReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardReplacementReason")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardReplacementReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardReplacementReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardReplacementReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardReplacementReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardReplacementReason); #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardStatus { Active, @@ -234,10 +482,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardStatus); #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardType { Physical, @@ -287,7 +552,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardType); diff --git a/generated/stripe_shared/src/issuing_card_apple_pay.rs b/generated/stripe_shared/src/issuing_card_apple_pay.rs index b968c6e43..e695ddec4 100644 --- a/generated/stripe_shared/src/issuing_card_apple_pay.rs +++ b/generated/stripe_shared/src/issuing_card_apple_pay.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardApplePay { /// Apple Pay Eligibility pub eligible: bool, /// Reason the card is ineligible for Apple Pay pub ineligible_reason: Option<IssuingCardApplePayIneligibleReason>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardApplePayBuilder { + eligible: Option<bool>, + ineligible_reason: Option<Option<IssuingCardApplePayIneligibleReason>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardApplePay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardApplePay>, + builder: IssuingCardApplePayBuilder, + } + + impl Visitor for Place<IssuingCardApplePay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardApplePayBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardApplePayBuilder { + type Out = IssuingCardApplePay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "eligible" => Deserialize::begin(&mut self.eligible), + "ineligible_reason" => Deserialize::begin(&mut self.ineligible_reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eligible: Deserialize::default(), ineligible_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let eligible = self.eligible.take()?; + let ineligible_reason = self.ineligible_reason.take()?; + + Some(Self::Out { eligible, ineligible_reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardApplePay { + type Builder = IssuingCardApplePayBuilder; + } + + impl FromValueOpt for IssuingCardApplePay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardApplePayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "eligible" => b.eligible = Some(FromValueOpt::from_value(v)?), + "ineligible_reason" => b.ineligible_reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason the card is ineligible for Apple Pay #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardApplePayIneligibleReason { @@ -58,8 +150,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardApplePayIneligibleReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingCardApplePayIneligibleReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardApplePayIneligibleReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardApplePayIneligibleReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardApplePayIneligibleReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardApplePayIneligibleReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardApplePayIneligibleReason); diff --git a/generated/stripe_shared/src/issuing_card_authorization_controls.rs b/generated/stripe_shared/src/issuing_card_authorization_controls.rs index f1428a4e5..0a1a6582a 100644 --- a/generated/stripe_shared/src/issuing_card_authorization_controls.rs +++ b/generated/stripe_shared/src/issuing_card_authorization_controls.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardAuthorizationControls { /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to allow. /// All other categories will be blocked. @@ -13,6 +15,104 @@ pub struct IssuingCardAuthorizationControls { /// Currency of the amounts within `spending_limits`. Always the same as the currency of the card. pub spending_limits_currency: Option<stripe_types::Currency>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardAuthorizationControlsBuilder { + allowed_categories: Option<Option<Vec<IssuingCardAuthorizationControlsAllowedCategories>>>, + blocked_categories: Option<Option<Vec<IssuingCardAuthorizationControlsBlockedCategories>>>, + spending_limits: Option<Option<Vec<stripe_shared::IssuingCardSpendingLimit>>>, + spending_limits_currency: Option<Option<stripe_types::Currency>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardAuthorizationControls { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardAuthorizationControls>, + builder: IssuingCardAuthorizationControlsBuilder, + } + + impl Visitor for Place<IssuingCardAuthorizationControls> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardAuthorizationControlsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardAuthorizationControlsBuilder { + type Out = IssuingCardAuthorizationControls; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allowed_categories" => Deserialize::begin(&mut self.allowed_categories), + "blocked_categories" => Deserialize::begin(&mut self.blocked_categories), + "spending_limits" => Deserialize::begin(&mut self.spending_limits), + "spending_limits_currency" => Deserialize::begin(&mut self.spending_limits_currency), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_categories: Deserialize::default(), blocked_categories: Deserialize::default(), spending_limits: Deserialize::default(), spending_limits_currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allowed_categories = self.allowed_categories.take()?; + let blocked_categories = self.blocked_categories.take()?; + let spending_limits = self.spending_limits.take()?; + let spending_limits_currency = self.spending_limits_currency.take()?; + + Some(Self::Out { allowed_categories, blocked_categories, spending_limits, spending_limits_currency }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardAuthorizationControls { + type Builder = IssuingCardAuthorizationControlsBuilder; + } + + impl FromValueOpt for IssuingCardAuthorizationControls { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardAuthorizationControlsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allowed_categories" => b.allowed_categories = Some(FromValueOpt::from_value(v)?), + "blocked_categories" => b.blocked_categories = Some(FromValueOpt::from_value(v)?), + "spending_limits" => b.spending_limits = Some(FromValueOpt::from_value(v)?), + "spending_limits_currency" => b.spending_limits_currency = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to allow. /// All other categories will be blocked. /// Cannot be set with `blocked_categories`. @@ -359,9 +459,7 @@ impl IssuingCardAuthorizationControlsAllowedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -371,9 +469,7 @@ impl IssuingCardAuthorizationControlsAllowedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -415,9 +511,7 @@ impl IssuingCardAuthorizationControlsAllowedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -427,14 +521,10 @@ impl IssuingCardAuthorizationControlsAllowedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -455,18 +545,14 @@ impl IssuingCardAuthorizationControlsAllowedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -474,12 +560,8 @@ impl IssuingCardAuthorizationControlsAllowedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -499,9 +581,7 @@ impl IssuingCardAuthorizationControlsAllowedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -514,14 +594,10 @@ impl IssuingCardAuthorizationControlsAllowedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -531,9 +607,7 @@ impl IssuingCardAuthorizationControlsAllowedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -545,9 +619,7 @@ impl IssuingCardAuthorizationControlsAllowedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -567,18 +639,14 @@ impl IssuingCardAuthorizationControlsAllowedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -592,9 +660,7 @@ impl IssuingCardAuthorizationControlsAllowedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -606,21 +672,15 @@ impl IssuingCardAuthorizationControlsAllowedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -636,13 +696,9 @@ impl IssuingCardAuthorizationControlsAllowedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -708,9 +764,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -720,9 +774,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -764,9 +816,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -776,14 +826,10 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -804,20 +850,14 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -825,12 +865,8 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -850,9 +886,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -865,28 +899,20 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -898,9 +924,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -920,18 +944,14 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -945,9 +965,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -959,21 +977,15 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -989,13 +1001,9 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsAllowedCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1040,9 +1048,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardAuthorizationControlsAllowedCat fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(IssuingCardAuthorizationControlsAllowedCategories::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardAuthorizationControlsAllowedCategories { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardAuthorizationControlsAllowedCategories> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardAuthorizationControlsAllowedCategories::from_str(s).unwrap_or(IssuingCardAuthorizationControlsAllowedCategories::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardAuthorizationControlsAllowedCategories); /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to decline. /// All other categories will be allowed. /// Cannot be set with `allowed_categories`. @@ -1389,9 +1415,7 @@ impl IssuingCardAuthorizationControlsBlockedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -1401,9 +1425,7 @@ impl IssuingCardAuthorizationControlsBlockedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -1445,9 +1467,7 @@ impl IssuingCardAuthorizationControlsBlockedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -1457,14 +1477,10 @@ impl IssuingCardAuthorizationControlsBlockedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -1485,18 +1501,14 @@ impl IssuingCardAuthorizationControlsBlockedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -1504,12 +1516,8 @@ impl IssuingCardAuthorizationControlsBlockedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -1529,9 +1537,7 @@ impl IssuingCardAuthorizationControlsBlockedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -1544,14 +1550,10 @@ impl IssuingCardAuthorizationControlsBlockedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -1561,9 +1563,7 @@ impl IssuingCardAuthorizationControlsBlockedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -1575,9 +1575,7 @@ impl IssuingCardAuthorizationControlsBlockedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -1597,18 +1595,14 @@ impl IssuingCardAuthorizationControlsBlockedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -1622,9 +1616,7 @@ impl IssuingCardAuthorizationControlsBlockedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -1636,21 +1628,15 @@ impl IssuingCardAuthorizationControlsBlockedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -1666,13 +1652,9 @@ impl IssuingCardAuthorizationControlsBlockedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -1738,9 +1720,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -1750,9 +1730,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -1794,9 +1772,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -1806,14 +1782,10 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -1834,20 +1806,14 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -1855,12 +1821,8 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -1880,9 +1842,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -1895,28 +1855,20 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -1928,9 +1880,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -1950,18 +1900,14 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -1975,9 +1921,7 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -1989,21 +1933,15 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -2019,13 +1957,9 @@ impl std::str::FromStr for IssuingCardAuthorizationControlsBlockedCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -2070,6 +2004,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardAuthorizationControlsBlockedCat fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(IssuingCardAuthorizationControlsBlockedCategories::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardAuthorizationControlsBlockedCategories { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardAuthorizationControlsBlockedCategories> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardAuthorizationControlsBlockedCategories::from_str(s).unwrap_or(IssuingCardAuthorizationControlsBlockedCategories::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardAuthorizationControlsBlockedCategories); diff --git a/generated/stripe_shared/src/issuing_card_google_pay.rs b/generated/stripe_shared/src/issuing_card_google_pay.rs index 0b8418878..12d09f543 100644 --- a/generated/stripe_shared/src/issuing_card_google_pay.rs +++ b/generated/stripe_shared/src/issuing_card_google_pay.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardGooglePay { /// Google Pay Eligibility pub eligible: bool, /// Reason the card is ineligible for Google Pay pub ineligible_reason: Option<IssuingCardGooglePayIneligibleReason>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardGooglePayBuilder { + eligible: Option<bool>, + ineligible_reason: Option<Option<IssuingCardGooglePayIneligibleReason>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardGooglePay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardGooglePay>, + builder: IssuingCardGooglePayBuilder, + } + + impl Visitor for Place<IssuingCardGooglePay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardGooglePayBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardGooglePayBuilder { + type Out = IssuingCardGooglePay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "eligible" => Deserialize::begin(&mut self.eligible), + "ineligible_reason" => Deserialize::begin(&mut self.ineligible_reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eligible: Deserialize::default(), ineligible_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let eligible = self.eligible.take()?; + let ineligible_reason = self.ineligible_reason.take()?; + + Some(Self::Out { eligible, ineligible_reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardGooglePay { + type Builder = IssuingCardGooglePayBuilder; + } + + impl FromValueOpt for IssuingCardGooglePay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardGooglePayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "eligible" => b.eligible = Some(FromValueOpt::from_value(v)?), + "ineligible_reason" => b.ineligible_reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason the card is ineligible for Google Pay #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardGooglePayIneligibleReason { @@ -58,8 +150,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardGooglePayIneligibleReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingCardGooglePayIneligibleReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardGooglePayIneligibleReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardGooglePayIneligibleReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardGooglePayIneligibleReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardGooglePayIneligibleReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardGooglePayIneligibleReason); diff --git a/generated/stripe_shared/src/issuing_card_shipping.rs b/generated/stripe_shared/src/issuing_card_shipping.rs index 2abc86aad..1ced090b0 100644 --- a/generated/stripe_shared/src/issuing_card_shipping.rs +++ b/generated/stripe_shared/src/issuing_card_shipping.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardShipping { pub address: stripe_shared::Address, /// The delivery company that shipped a card. @@ -27,9 +29,152 @@ pub struct IssuingCardShipping { /// A link to the shipping carrier's site where you can view detailed information about a card shipment. pub tracking_url: Option<String>, /// Packaging options. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: IssuingCardShippingType, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardShippingBuilder { + address: Option<stripe_shared::Address>, + carrier: Option<Option<IssuingCardShippingCarrier>>, + customs: Option<Option<stripe_shared::IssuingCardShippingCustoms>>, + eta: Option<Option<stripe_types::Timestamp>>, + name: Option<String>, + phone_number: Option<Option<String>>, + require_signature: Option<Option<bool>>, + service: Option<IssuingCardShippingService>, + status: Option<Option<IssuingCardShippingStatus>>, + tracking_number: Option<Option<String>>, + tracking_url: Option<Option<String>>, + type_: Option<IssuingCardShippingType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardShipping { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardShipping>, + builder: IssuingCardShippingBuilder, + } + + impl Visitor for Place<IssuingCardShipping> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardShippingBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardShippingBuilder { + type Out = IssuingCardShipping; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "carrier" => Deserialize::begin(&mut self.carrier), + "customs" => Deserialize::begin(&mut self.customs), + "eta" => Deserialize::begin(&mut self.eta), + "name" => Deserialize::begin(&mut self.name), + "phone_number" => Deserialize::begin(&mut self.phone_number), + "require_signature" => Deserialize::begin(&mut self.require_signature), + "service" => Deserialize::begin(&mut self.service), + "status" => Deserialize::begin(&mut self.status), + "tracking_number" => Deserialize::begin(&mut self.tracking_number), + "tracking_url" => Deserialize::begin(&mut self.tracking_url), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + carrier: Deserialize::default(), + customs: Deserialize::default(), + eta: Deserialize::default(), + name: Deserialize::default(), + phone_number: Deserialize::default(), + require_signature: Deserialize::default(), + service: Deserialize::default(), + status: Deserialize::default(), + tracking_number: Deserialize::default(), + tracking_url: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let carrier = self.carrier.take()?; + let customs = self.customs.take()?; + let eta = self.eta.take()?; + let name = self.name.take()?; + let phone_number = self.phone_number.take()?; + let require_signature = self.require_signature.take()?; + let service = self.service.take()?; + let status = self.status.take()?; + let tracking_number = self.tracking_number.take()?; + let tracking_url = self.tracking_url.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { address, carrier, customs, eta, name, phone_number, require_signature, service, status, tracking_number, tracking_url, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardShipping { + type Builder = IssuingCardShippingBuilder; + } + + impl FromValueOpt for IssuingCardShipping { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardShippingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "carrier" => b.carrier = Some(FromValueOpt::from_value(v)?), + "customs" => b.customs = Some(FromValueOpt::from_value(v)?), + "eta" => b.eta = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "phone_number" => b.phone_number = Some(FromValueOpt::from_value(v)?), + "require_signature" => b.require_signature = Some(FromValueOpt::from_value(v)?), + "service" => b.service = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "tracking_number" => b.tracking_number = Some(FromValueOpt::from_value(v)?), + "tracking_url" => b.tracking_url = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The delivery company that shipped a card. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardShippingCarrier { @@ -86,10 +231,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardShippingCarrier { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingCarrier")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingCarrier")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardShippingCarrier { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardShippingCarrier> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingCarrier::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingCarrier); /// Shipment service, such as `standard` or `express`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardShippingService { @@ -143,10 +305,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardShippingService { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingService")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingService")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardShippingService { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardShippingService> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingService::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingService); /// The delivery status of the card. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardShippingStatus { @@ -209,10 +388,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardShippingStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardShippingStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardShippingStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingStatus); /// Packaging options. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardShippingType { @@ -263,7 +459,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardShippingType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardShippingType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardShippingType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardShippingType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingType); diff --git a/generated/stripe_shared/src/issuing_card_shipping_customs.rs b/generated/stripe_shared/src/issuing_card_shipping_customs.rs index 71c6bc68e..6cc8c1af7 100644 --- a/generated/stripe_shared/src/issuing_card_shipping_customs.rs +++ b/generated/stripe_shared/src/issuing_card_shipping_customs.rs @@ -1,6 +1,94 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardShippingCustoms { /// A registration number used for customs in Europe. /// See [<https://www.gov.uk/eori>](https://www.gov.uk/eori) for the UK and [<https://ec.europa.eu/taxation_customs/business/customs-procedures-import-and-export/customs-procedures/economic-operators-registration-and-identification-number-eori_en>](https://ec.europa.eu/taxation_customs/business/customs-procedures-import-and-export/customs-procedures/economic-operators-registration-and-identification-number-eori_en) for the EU. pub eori_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardShippingCustomsBuilder { + eori_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardShippingCustoms { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardShippingCustoms>, + builder: IssuingCardShippingCustomsBuilder, + } + + impl Visitor for Place<IssuingCardShippingCustoms> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardShippingCustomsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardShippingCustomsBuilder { + type Out = IssuingCardShippingCustoms; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "eori_number" => Deserialize::begin(&mut self.eori_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eori_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let eori_number = self.eori_number.take()?; + + Some(Self::Out { eori_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardShippingCustoms { + type Builder = IssuingCardShippingCustomsBuilder; + } + + impl FromValueOpt for IssuingCardShippingCustoms { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardShippingCustomsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "eori_number" => b.eori_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_card_spending_limit.rs b/generated/stripe_shared/src/issuing_card_spending_limit.rs index a92f4b746..1f888f639 100644 --- a/generated/stripe_shared/src/issuing_card_spending_limit.rs +++ b/generated/stripe_shared/src/issuing_card_spending_limit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardSpendingLimit { /// Maximum amount allowed to spend per interval. /// This amount is in the card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). @@ -9,6 +11,100 @@ pub struct IssuingCardSpendingLimit { /// Interval (or event) to which the amount applies. pub interval: IssuingCardSpendingLimitInterval, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardSpendingLimitBuilder { + amount: Option<i64>, + categories: Option<Option<Vec<IssuingCardSpendingLimitCategories>>>, + interval: Option<IssuingCardSpendingLimitInterval>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardSpendingLimit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardSpendingLimit>, + builder: IssuingCardSpendingLimitBuilder, + } + + impl Visitor for Place<IssuingCardSpendingLimit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardSpendingLimitBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardSpendingLimitBuilder { + type Out = IssuingCardSpendingLimit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "categories" => Deserialize::begin(&mut self.categories), + "interval" => Deserialize::begin(&mut self.interval), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), categories: Deserialize::default(), interval: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let categories = self.categories.take()?; + let interval = self.interval.take()?; + + Some(Self::Out { amount, categories, interval }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardSpendingLimit { + type Builder = IssuingCardSpendingLimitBuilder; + } + + impl FromValueOpt for IssuingCardSpendingLimit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardSpendingLimitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "categories" => b.categories = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) this limit applies to. /// Omitting this field will apply the limit to all categories. #[derive(Copy, Clone, Eq, PartialEq)] @@ -354,9 +450,7 @@ impl IssuingCardSpendingLimitCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -366,9 +460,7 @@ impl IssuingCardSpendingLimitCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -410,9 +502,7 @@ impl IssuingCardSpendingLimitCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -422,14 +512,10 @@ impl IssuingCardSpendingLimitCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -450,18 +536,14 @@ impl IssuingCardSpendingLimitCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -469,12 +551,8 @@ impl IssuingCardSpendingLimitCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -494,9 +572,7 @@ impl IssuingCardSpendingLimitCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -509,14 +585,10 @@ impl IssuingCardSpendingLimitCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -526,9 +598,7 @@ impl IssuingCardSpendingLimitCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -540,9 +610,7 @@ impl IssuingCardSpendingLimitCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -562,18 +630,14 @@ impl IssuingCardSpendingLimitCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -587,9 +651,7 @@ impl IssuingCardSpendingLimitCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -601,21 +663,15 @@ impl IssuingCardSpendingLimitCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -631,13 +687,9 @@ impl IssuingCardSpendingLimitCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -703,9 +755,7 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -715,9 +765,7 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -759,9 +807,7 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -771,14 +817,10 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -799,20 +841,14 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -820,12 +856,8 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -845,9 +877,7 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -860,28 +890,20 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -893,9 +915,7 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -915,18 +935,14 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -940,9 +956,7 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -954,21 +968,15 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -984,13 +992,9 @@ impl std::str::FromStr for IssuingCardSpendingLimitCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1035,9 +1039,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardSpendingLimitCategories { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(IssuingCardSpendingLimitCategories::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardSpendingLimitCategories { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardSpendingLimitCategories> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardSpendingLimitCategories::from_str(s).unwrap_or(IssuingCardSpendingLimitCategories::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardSpendingLimitCategories); /// Interval (or event) to which the amount applies. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardSpendingLimitInterval { @@ -1100,8 +1122,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardSpendingLimitInterval { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingCardSpendingLimitInterval") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardSpendingLimitInterval")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardSpendingLimitInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardSpendingLimitInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardSpendingLimitInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardSpendingLimitInterval); diff --git a/generated/stripe_shared/src/issuing_card_wallets.rs b/generated/stripe_shared/src/issuing_card_wallets.rs index d3a3840df..705ee5f14 100644 --- a/generated/stripe_shared/src/issuing_card_wallets.rs +++ b/generated/stripe_shared/src/issuing_card_wallets.rs @@ -1,7 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardWallets { pub apple_pay: stripe_shared::IssuingCardApplePay, pub google_pay: stripe_shared::IssuingCardGooglePay, /// Unique identifier for a card used with digital wallets pub primary_account_identifier: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardWalletsBuilder { + apple_pay: Option<stripe_shared::IssuingCardApplePay>, + google_pay: Option<stripe_shared::IssuingCardGooglePay>, + primary_account_identifier: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardWallets { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardWallets>, + builder: IssuingCardWalletsBuilder, + } + + impl Visitor for Place<IssuingCardWallets> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardWalletsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardWalletsBuilder { + type Out = IssuingCardWallets; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "apple_pay" => Deserialize::begin(&mut self.apple_pay), + "google_pay" => Deserialize::begin(&mut self.google_pay), + "primary_account_identifier" => Deserialize::begin(&mut self.primary_account_identifier), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { apple_pay: Deserialize::default(), google_pay: Deserialize::default(), primary_account_identifier: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let apple_pay = self.apple_pay.take()?; + let google_pay = self.google_pay.take()?; + let primary_account_identifier = self.primary_account_identifier.take()?; + + Some(Self::Out { apple_pay, google_pay, primary_account_identifier }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardWallets { + type Builder = IssuingCardWalletsBuilder; + } + + impl FromValueOpt for IssuingCardWallets { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardWalletsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "apple_pay" => b.apple_pay = Some(FromValueOpt::from_value(v)?), + "google_pay" => b.google_pay = Some(FromValueOpt::from_value(v)?), + "primary_account_identifier" => b.primary_account_identifier = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder.rs b/generated/stripe_shared/src/issuing_cardholder.rs index 241ef69fe..20bf5980b 100644 --- a/generated/stripe_shared/src/issuing_cardholder.rs +++ b/generated/stripe_shared/src/issuing_cardholder.rs @@ -3,7 +3,9 @@ /// Related guide: [How to create a cardholder](https://stripe.com/docs/issuing/cards#create-cardholder). /// /// For more details see <<https://stripe.com/docs/api/issuing/cardholders/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholder { pub billing: stripe_shared::IssuingCardholderAddress, /// Additional information about a `company` cardholder. @@ -39,9 +41,167 @@ pub struct IssuingCardholder { pub status: stripe_shared::IssuingCardholderStatus, /// One of `individual` or `company`. /// See [Choose a cardholder type](https://stripe.com/docs/issuing/other/choose-cardholder) for more details. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_shared::IssuingCardholderType, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderBuilder { + billing: Option<stripe_shared::IssuingCardholderAddress>, + company: Option<Option<stripe_shared::IssuingCardholderCompany>>, + created: Option<stripe_types::Timestamp>, + email: Option<Option<String>>, + id: Option<stripe_shared::IssuingCardholderId>, + individual: Option<Option<stripe_shared::IssuingCardholderIndividual>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + name: Option<String>, + phone_number: Option<Option<String>>, + preferred_locales: Option<Option<Vec<stripe_shared::IssuingCardholderPreferredLocales>>>, + requirements: Option<stripe_shared::IssuingCardholderRequirements>, + spending_controls: Option<Option<stripe_shared::IssuingCardholderAuthorizationControls>>, + status: Option<stripe_shared::IssuingCardholderStatus>, + type_: Option<stripe_shared::IssuingCardholderType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholder { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholder>, + builder: IssuingCardholderBuilder, + } + + impl Visitor for Place<IssuingCardholder> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderBuilder { + type Out = IssuingCardholder; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing" => Deserialize::begin(&mut self.billing), + "company" => Deserialize::begin(&mut self.company), + "created" => Deserialize::begin(&mut self.created), + "email" => Deserialize::begin(&mut self.email), + "id" => Deserialize::begin(&mut self.id), + "individual" => Deserialize::begin(&mut self.individual), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "name" => Deserialize::begin(&mut self.name), + "phone_number" => Deserialize::begin(&mut self.phone_number), + "preferred_locales" => Deserialize::begin(&mut self.preferred_locales), + "requirements" => Deserialize::begin(&mut self.requirements), + "spending_controls" => Deserialize::begin(&mut self.spending_controls), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing: Deserialize::default(), + company: Deserialize::default(), + created: Deserialize::default(), + email: Deserialize::default(), + id: Deserialize::default(), + individual: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + name: Deserialize::default(), + phone_number: Deserialize::default(), + preferred_locales: Deserialize::default(), + requirements: Deserialize::default(), + spending_controls: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing = self.billing.take()?; + let company = self.company.take()?; + let created = self.created.take()?; + let email = self.email.take()?; + let id = self.id.take()?; + let individual = self.individual.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let name = self.name.take()?; + let phone_number = self.phone_number.take()?; + let preferred_locales = self.preferred_locales.take()?; + let requirements = self.requirements.take()?; + let spending_controls = self.spending_controls.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { billing, company, created, email, id, individual, livemode, metadata, name, phone_number, preferred_locales, requirements, spending_controls, status, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholder { + type Builder = IssuingCardholderBuilder; + } + + impl FromValueOpt for IssuingCardholder { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing" => b.billing = Some(FromValueOpt::from_value(v)?), + "company" => b.company = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "individual" => b.individual = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "phone_number" => b.phone_number = Some(FromValueOpt::from_value(v)?), + "preferred_locales" => b.preferred_locales = Some(FromValueOpt::from_value(v)?), + "requirements" => b.requirements = Some(FromValueOpt::from_value(v)?), + "spending_controls" => b.spending_controls = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for IssuingCardholder { type Id = stripe_shared::IssuingCardholderId; fn id(&self) -> &Self::Id { @@ -107,11 +267,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderPreferredLocales { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingCardholderPreferredLocales") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderPreferredLocales")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderPreferredLocales { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderPreferredLocales> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderPreferredLocales::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderPreferredLocales); #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardholderStatus { Active, @@ -164,10 +340,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderStatus); #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardholderType { Company, @@ -217,7 +410,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderType); diff --git a/generated/stripe_shared/src/issuing_cardholder_address.rs b/generated/stripe_shared/src/issuing_cardholder_address.rs index ed0c54052..d194847a9 100644 --- a/generated/stripe_shared/src/issuing_cardholder_address.rs +++ b/generated/stripe_shared/src/issuing_cardholder_address.rs @@ -1,4 +1,92 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderAddress { pub address: stripe_shared::Address, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderAddressBuilder { + address: Option<stripe_shared::Address>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderAddress { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderAddress>, + builder: IssuingCardholderAddressBuilder, + } + + impl Visitor for Place<IssuingCardholderAddress> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderAddressBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderAddressBuilder { + type Out = IssuingCardholderAddress; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + + Some(Self::Out { address }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderAddress { + type Builder = IssuingCardholderAddressBuilder; + } + + impl FromValueOpt for IssuingCardholderAddress { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderAddressBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder_authorization_controls.rs b/generated/stripe_shared/src/issuing_cardholder_authorization_controls.rs index 735bb61f0..47d2c7bd6 100644 --- a/generated/stripe_shared/src/issuing_cardholder_authorization_controls.rs +++ b/generated/stripe_shared/src/issuing_cardholder_authorization_controls.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderAuthorizationControls { /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to allow. /// All other categories will be blocked. @@ -13,6 +15,104 @@ pub struct IssuingCardholderAuthorizationControls { /// Currency of the amounts within `spending_limits`. pub spending_limits_currency: Option<stripe_types::Currency>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderAuthorizationControlsBuilder { + allowed_categories: Option<Option<Vec<IssuingCardholderAuthorizationControlsAllowedCategories>>>, + blocked_categories: Option<Option<Vec<IssuingCardholderAuthorizationControlsBlockedCategories>>>, + spending_limits: Option<Option<Vec<stripe_shared::IssuingCardholderSpendingLimit>>>, + spending_limits_currency: Option<Option<stripe_types::Currency>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderAuthorizationControls { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderAuthorizationControls>, + builder: IssuingCardholderAuthorizationControlsBuilder, + } + + impl Visitor for Place<IssuingCardholderAuthorizationControls> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderAuthorizationControlsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderAuthorizationControlsBuilder { + type Out = IssuingCardholderAuthorizationControls; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allowed_categories" => Deserialize::begin(&mut self.allowed_categories), + "blocked_categories" => Deserialize::begin(&mut self.blocked_categories), + "spending_limits" => Deserialize::begin(&mut self.spending_limits), + "spending_limits_currency" => Deserialize::begin(&mut self.spending_limits_currency), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_categories: Deserialize::default(), blocked_categories: Deserialize::default(), spending_limits: Deserialize::default(), spending_limits_currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allowed_categories = self.allowed_categories.take()?; + let blocked_categories = self.blocked_categories.take()?; + let spending_limits = self.spending_limits.take()?; + let spending_limits_currency = self.spending_limits_currency.take()?; + + Some(Self::Out { allowed_categories, blocked_categories, spending_limits, spending_limits_currency }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderAuthorizationControls { + type Builder = IssuingCardholderAuthorizationControlsBuilder; + } + + impl FromValueOpt for IssuingCardholderAuthorizationControls { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderAuthorizationControlsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allowed_categories" => b.allowed_categories = Some(FromValueOpt::from_value(v)?), + "blocked_categories" => b.blocked_categories = Some(FromValueOpt::from_value(v)?), + "spending_limits" => b.spending_limits = Some(FromValueOpt::from_value(v)?), + "spending_limits_currency" => b.spending_limits_currency = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to allow. /// All other categories will be blocked. /// Cannot be set with `blocked_categories`. @@ -359,9 +459,7 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -371,9 +469,7 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -415,9 +511,7 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -427,14 +521,10 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -455,18 +545,14 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -474,12 +560,8 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -499,9 +581,7 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -514,14 +594,10 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -531,9 +607,7 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -545,9 +619,7 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -567,18 +639,14 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -592,9 +660,7 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -606,21 +672,15 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -636,13 +696,9 @@ impl IssuingCardholderAuthorizationControlsAllowedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -708,9 +764,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -720,9 +774,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -764,9 +816,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -776,14 +826,10 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -804,20 +850,14 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -825,12 +865,8 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -850,9 +886,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -865,28 +899,20 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -898,9 +924,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -920,18 +944,14 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -945,9 +965,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -959,21 +977,15 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -989,13 +1001,9 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsAllowedCategori "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1040,10 +1048,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderAuthorizationControlsAllo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s) - .unwrap_or(IssuingCardholderAuthorizationControlsAllowedCategories::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderAuthorizationControlsAllowedCategories { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderAuthorizationControlsAllowedCategories> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderAuthorizationControlsAllowedCategories::from_str(s).unwrap_or(IssuingCardholderAuthorizationControlsAllowedCategories::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderAuthorizationControlsAllowedCategories); /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to decline. /// All other categories will be allowed. /// Cannot be set with `allowed_categories`. @@ -1390,9 +1415,7 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -1402,9 +1425,7 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -1446,9 +1467,7 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -1458,14 +1477,10 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -1486,18 +1501,14 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -1505,12 +1516,8 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -1530,9 +1537,7 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -1545,14 +1550,10 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -1562,9 +1563,7 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -1576,9 +1575,7 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -1598,18 +1595,14 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -1623,9 +1616,7 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -1637,21 +1628,15 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -1667,13 +1652,9 @@ impl IssuingCardholderAuthorizationControlsBlockedCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -1739,9 +1720,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -1751,9 +1730,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -1795,9 +1772,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -1807,14 +1782,10 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -1835,20 +1806,14 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -1856,12 +1821,8 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -1881,9 +1842,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -1896,28 +1855,20 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -1929,9 +1880,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -1951,18 +1900,14 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -1976,9 +1921,7 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -1990,21 +1933,15 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -2020,13 +1957,9 @@ impl std::str::FromStr for IssuingCardholderAuthorizationControlsBlockedCategori "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -2071,7 +2004,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderAuthorizationControlsBloc fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s) - .unwrap_or(IssuingCardholderAuthorizationControlsBlockedCategories::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderAuthorizationControlsBlockedCategories { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderAuthorizationControlsBlockedCategories> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderAuthorizationControlsBlockedCategories::from_str(s).unwrap_or(IssuingCardholderAuthorizationControlsBlockedCategories::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderAuthorizationControlsBlockedCategories); diff --git a/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs b/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs index bd905a1c8..bc73e0349 100644 --- a/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs +++ b/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs @@ -1,6 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderCardIssuing { - /// Information about cardholder acceptance of Celtic [Authorized User Terms](https://stripe.com/docs/issuing/cards#accept-authorized-user-terms). - /// Required for cards backed by a Celtic program. + /// Information about cardholder acceptance of [Authorized User Terms](https://stripe.com/docs/issuing/cards). pub user_terms_acceptance: Option<stripe_shared::IssuingCardholderUserTermsAcceptance>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderCardIssuingBuilder { + user_terms_acceptance: Option<Option<stripe_shared::IssuingCardholderUserTermsAcceptance>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderCardIssuing { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderCardIssuing>, + builder: IssuingCardholderCardIssuingBuilder, + } + + impl Visitor for Place<IssuingCardholderCardIssuing> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderCardIssuingBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderCardIssuingBuilder { + type Out = IssuingCardholderCardIssuing; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "user_terms_acceptance" => Deserialize::begin(&mut self.user_terms_acceptance), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { user_terms_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let user_terms_acceptance = self.user_terms_acceptance.take()?; + + Some(Self::Out { user_terms_acceptance }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderCardIssuing { + type Builder = IssuingCardholderCardIssuingBuilder; + } + + impl FromValueOpt for IssuingCardholderCardIssuing { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderCardIssuingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "user_terms_acceptance" => b.user_terms_acceptance = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder_company.rs b/generated/stripe_shared/src/issuing_cardholder_company.rs index b6e397d9d..81741b019 100644 --- a/generated/stripe_shared/src/issuing_cardholder_company.rs +++ b/generated/stripe_shared/src/issuing_cardholder_company.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderCompany { /// Whether the company's business ID number was provided. pub tax_id_provided: bool, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderCompanyBuilder { + tax_id_provided: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderCompany { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderCompany>, + builder: IssuingCardholderCompanyBuilder, + } + + impl Visitor for Place<IssuingCardholderCompany> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderCompanyBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderCompanyBuilder { + type Out = IssuingCardholderCompany; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "tax_id_provided" => Deserialize::begin(&mut self.tax_id_provided), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_id_provided: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let tax_id_provided = self.tax_id_provided.take()?; + + Some(Self::Out { tax_id_provided }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderCompany { + type Builder = IssuingCardholderCompanyBuilder; + } + + impl FromValueOpt for IssuingCardholderCompany { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderCompanyBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "tax_id_provided" => b.tax_id_provided = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder_id_document.rs b/generated/stripe_shared/src/issuing_cardholder_id_document.rs index aad29b05d..80817047c 100644 --- a/generated/stripe_shared/src/issuing_cardholder_id_document.rs +++ b/generated/stripe_shared/src/issuing_cardholder_id_document.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderIdDocument { /// The back of a document returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `identity_document`. pub back: Option<stripe_types::Expandable<stripe_shared::File>>, /// The front of a document returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `identity_document`. pub front: Option<stripe_types::Expandable<stripe_shared::File>>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderIdDocumentBuilder { + back: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + front: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderIdDocument { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderIdDocument>, + builder: IssuingCardholderIdDocumentBuilder, + } + + impl Visitor for Place<IssuingCardholderIdDocument> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderIdDocumentBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderIdDocumentBuilder { + type Out = IssuingCardholderIdDocument; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "back" => Deserialize::begin(&mut self.back), + "front" => Deserialize::begin(&mut self.front), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { back: Deserialize::default(), front: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let back = self.back.take()?; + let front = self.front.take()?; + + Some(Self::Out { back, front }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderIdDocument { + type Builder = IssuingCardholderIdDocumentBuilder; + } + + impl FromValueOpt for IssuingCardholderIdDocument { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderIdDocumentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "back" => b.back = Some(FromValueOpt::from_value(v)?), + "front" => b.front = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder_individual.rs b/generated/stripe_shared/src/issuing_cardholder_individual.rs index e674d554e..404f012a4 100644 --- a/generated/stripe_shared/src/issuing_cardholder_individual.rs +++ b/generated/stripe_shared/src/issuing_cardholder_individual.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderIndividual { /// Information related to the card_issuing program for this cardholder. - #[serde(skip_serializing_if = "Option::is_none")] pub card_issuing: Option<stripe_shared::IssuingCardholderCardIssuing>, /// The date of birth of this cardholder. pub dob: Option<stripe_shared::IssuingCardholderIndividualDob>, @@ -16,3 +17,105 @@ pub struct IssuingCardholderIndividual { /// Government-issued ID document for this cardholder. pub verification: Option<stripe_shared::IssuingCardholderVerification>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderIndividualBuilder { + card_issuing: Option<Option<stripe_shared::IssuingCardholderCardIssuing>>, + dob: Option<Option<stripe_shared::IssuingCardholderIndividualDob>>, + first_name: Option<Option<String>>, + last_name: Option<Option<String>>, + verification: Option<Option<stripe_shared::IssuingCardholderVerification>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderIndividual { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderIndividual>, + builder: IssuingCardholderIndividualBuilder, + } + + impl Visitor for Place<IssuingCardholderIndividual> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderIndividualBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderIndividualBuilder { + type Out = IssuingCardholderIndividual; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "card_issuing" => Deserialize::begin(&mut self.card_issuing), + "dob" => Deserialize::begin(&mut self.dob), + "first_name" => Deserialize::begin(&mut self.first_name), + "last_name" => Deserialize::begin(&mut self.last_name), + "verification" => Deserialize::begin(&mut self.verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { card_issuing: Deserialize::default(), dob: Deserialize::default(), first_name: Deserialize::default(), last_name: Deserialize::default(), verification: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let card_issuing = self.card_issuing.take()?; + let dob = self.dob.take()?; + let first_name = self.first_name.take()?; + let last_name = self.last_name.take()?; + let verification = self.verification.take()?; + + Some(Self::Out { card_issuing, dob, first_name, last_name, verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderIndividual { + type Builder = IssuingCardholderIndividualBuilder; + } + + impl FromValueOpt for IssuingCardholderIndividual { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderIndividualBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "card_issuing" => b.card_issuing = Some(FromValueOpt::from_value(v)?), + "dob" => b.dob = Some(FromValueOpt::from_value(v)?), + "first_name" => b.first_name = Some(FromValueOpt::from_value(v)?), + "last_name" => b.last_name = Some(FromValueOpt::from_value(v)?), + "verification" => b.verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder_individual_dob.rs b/generated/stripe_shared/src/issuing_cardholder_individual_dob.rs index 285ff4d68..07d570d60 100644 --- a/generated/stripe_shared/src/issuing_cardholder_individual_dob.rs +++ b/generated/stripe_shared/src/issuing_cardholder_individual_dob.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderIndividualDob { /// The day of birth, between 1 and 31. pub day: Option<i64>, @@ -7,3 +9,97 @@ pub struct IssuingCardholderIndividualDob { /// The four-digit year of birth. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderIndividualDobBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderIndividualDob { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderIndividualDob>, + builder: IssuingCardholderIndividualDobBuilder, + } + + impl Visitor for Place<IssuingCardholderIndividualDob> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderIndividualDobBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderIndividualDobBuilder { + type Out = IssuingCardholderIndividualDob; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderIndividualDob { + type Builder = IssuingCardholderIndividualDobBuilder; + } + + impl FromValueOpt for IssuingCardholderIndividualDob { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderIndividualDobBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder_requirements.rs b/generated/stripe_shared/src/issuing_cardholder_requirements.rs index 68ba85718..fb2269934 100644 --- a/generated/stripe_shared/src/issuing_cardholder_requirements.rs +++ b/generated/stripe_shared/src/issuing_cardholder_requirements.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderRequirements { /// If `disabled_reason` is present, all cards will decline authorizations with `cardholder_verification_required` reason. pub disabled_reason: Option<IssuingCardholderRequirementsDisabledReason>, /// Array of fields that need to be collected in order to verify and re-enable the cardholder. pub past_due: Option<Vec<IssuingCardholderRequirementsPastDue>>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderRequirementsBuilder { + disabled_reason: Option<Option<IssuingCardholderRequirementsDisabledReason>>, + past_due: Option<Option<Vec<IssuingCardholderRequirementsPastDue>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderRequirements>, + builder: IssuingCardholderRequirementsBuilder, + } + + impl Visitor for Place<IssuingCardholderRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderRequirementsBuilder { + type Out = IssuingCardholderRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "disabled_reason" => Deserialize::begin(&mut self.disabled_reason), + "past_due" => Deserialize::begin(&mut self.past_due), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { disabled_reason: Deserialize::default(), past_due: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let disabled_reason = self.disabled_reason.take()?; + let past_due = self.past_due.take()?; + + Some(Self::Out { disabled_reason, past_due }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderRequirements { + type Builder = IssuingCardholderRequirementsBuilder; + } + + impl FromValueOpt for IssuingCardholderRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "disabled_reason" => b.disabled_reason = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// If `disabled_reason` is present, all cards will decline authorizations with `cardholder_verification_required` reason. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardholderRequirementsDisabledReason { @@ -61,13 +153,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderRequirementsDisabledReaso fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingCardholderRequirementsDisabledReason", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderRequirementsDisabledReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderRequirementsDisabledReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderRequirementsDisabledReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderRequirementsDisabledReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderRequirementsDisabledReason); /// Array of fields that need to be collected in order to verify and re-enable the cardholder. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardholderRequirementsPastDue { @@ -86,12 +192,8 @@ impl IssuingCardholderRequirementsPastDue { use IssuingCardholderRequirementsPastDue::*; match self { CompanyTaxId => "company.tax_id", - IndividualCardIssuingUserTermsAcceptanceDate => { - "individual.card_issuing.user_terms_acceptance.date" - } - IndividualCardIssuingUserTermsAcceptanceIp => { - "individual.card_issuing.user_terms_acceptance.ip" - } + IndividualCardIssuingUserTermsAcceptanceDate => "individual.card_issuing.user_terms_acceptance.date", + IndividualCardIssuingUserTermsAcceptanceIp => "individual.card_issuing.user_terms_acceptance.ip", IndividualDobDay => "individual.dob.day", IndividualDobMonth => "individual.dob.month", IndividualDobYear => "individual.dob.year", @@ -108,12 +210,8 @@ impl std::str::FromStr for IssuingCardholderRequirementsPastDue { use IssuingCardholderRequirementsPastDue::*; match s { "company.tax_id" => Ok(CompanyTaxId), - "individual.card_issuing.user_terms_acceptance.date" => { - Ok(IndividualCardIssuingUserTermsAcceptanceDate) - } - "individual.card_issuing.user_terms_acceptance.ip" => { - Ok(IndividualCardIssuingUserTermsAcceptanceIp) - } + "individual.card_issuing.user_terms_acceptance.date" => Ok(IndividualCardIssuingUserTermsAcceptanceDate), + "individual.card_issuing.user_terms_acceptance.ip" => Ok(IndividualCardIssuingUserTermsAcceptanceIp), "individual.dob.day" => Ok(IndividualDobDay), "individual.dob.month" => Ok(IndividualDobMonth), "individual.dob.year" => Ok(IndividualDobYear), @@ -147,8 +245,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderRequirementsPastDue { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingCardholderRequirementsPastDue") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderRequirementsPastDue")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderRequirementsPastDue { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderRequirementsPastDue> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderRequirementsPastDue::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderRequirementsPastDue); diff --git a/generated/stripe_shared/src/issuing_cardholder_spending_limit.rs b/generated/stripe_shared/src/issuing_cardholder_spending_limit.rs index 4ca0340cc..64d40a76f 100644 --- a/generated/stripe_shared/src/issuing_cardholder_spending_limit.rs +++ b/generated/stripe_shared/src/issuing_cardholder_spending_limit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderSpendingLimit { /// Maximum amount allowed to spend per interval. /// This amount is in the card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). @@ -9,6 +11,100 @@ pub struct IssuingCardholderSpendingLimit { /// Interval (or event) to which the amount applies. pub interval: IssuingCardholderSpendingLimitInterval, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderSpendingLimitBuilder { + amount: Option<i64>, + categories: Option<Option<Vec<IssuingCardholderSpendingLimitCategories>>>, + interval: Option<IssuingCardholderSpendingLimitInterval>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderSpendingLimit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderSpendingLimit>, + builder: IssuingCardholderSpendingLimitBuilder, + } + + impl Visitor for Place<IssuingCardholderSpendingLimit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderSpendingLimitBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderSpendingLimitBuilder { + type Out = IssuingCardholderSpendingLimit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "categories" => Deserialize::begin(&mut self.categories), + "interval" => Deserialize::begin(&mut self.interval), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), categories: Deserialize::default(), interval: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let categories = self.categories.take()?; + let interval = self.interval.take()?; + + Some(Self::Out { amount, categories, interval }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderSpendingLimit { + type Builder = IssuingCardholderSpendingLimitBuilder; + } + + impl FromValueOpt for IssuingCardholderSpendingLimit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderSpendingLimitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "categories" => b.categories = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) this limit applies to. /// Omitting this field will apply the limit to all categories. #[derive(Copy, Clone, Eq, PartialEq)] @@ -354,9 +450,7 @@ impl IssuingCardholderSpendingLimitCategories { BusLines => "bus_lines", BusinessSecretarialSchools => "business_secretarial_schools", BuyingShoppingServices => "buying_shopping_services", - CableSatelliteAndOtherPayTelevisionAndRadio => { - "cable_satellite_and_other_pay_television_and_radio" - } + CableSatelliteAndOtherPayTelevisionAndRadio => "cable_satellite_and_other_pay_television_and_radio", CameraAndPhotographicSupplyStores => "camera_and_photographic_supply_stores", CandyNutAndConfectioneryStores => "candy_nut_and_confectionery_stores", CarAndTruckDealersNewUsed => "car_and_truck_dealers_new_used", @@ -366,9 +460,7 @@ impl IssuingCardholderSpendingLimitCategories { CarpentryServices => "carpentry_services", CarpetUpholsteryCleaning => "carpet_upholstery_cleaning", Caterers => "caterers", - CharitableAndSocialServiceOrganizationsFundraising => { - "charitable_and_social_service_organizations_fundraising" - } + CharitableAndSocialServiceOrganizationsFundraising => "charitable_and_social_service_organizations_fundraising", ChemicalsAndAlliedProducts => "chemicals_and_allied_products", ChildCareServices => "child_care_services", ChildrensAndInfantsWearStores => "childrens_and_infants_wear_stores", @@ -410,9 +502,7 @@ impl IssuingCardholderSpendingLimitCategories { DigitalGoodsLargeVolume => "digital_goods_large_volume", DigitalGoodsMedia => "digital_goods_media", DirectMarketingCatalogMerchant => "direct_marketing_catalog_merchant", - DirectMarketingCombinationCatalogAndRetailMerchant => { - "direct_marketing_combination_catalog_and_retail_merchant" - } + DirectMarketingCombinationCatalogAndRetailMerchant => "direct_marketing_combination_catalog_and_retail_merchant", DirectMarketingInboundTelemarketing => "direct_marketing_inbound_telemarketing", DirectMarketingInsuranceServices => "direct_marketing_insurance_services", DirectMarketingOther => "direct_marketing_other", @@ -422,14 +512,10 @@ impl IssuingCardholderSpendingLimitCategories { DiscountStores => "discount_stores", Doctors => "doctors", DoorToDoorSales => "door_to_door_sales", - DraperyWindowCoveringAndUpholsteryStores => { - "drapery_window_covering_and_upholstery_stores" - } + DraperyWindowCoveringAndUpholsteryStores => "drapery_window_covering_and_upholstery_stores", DrinkingPlaces => "drinking_places", DrugStoresAndPharmacies => "drug_stores_and_pharmacies", - DrugsDrugProprietariesAndDruggistSundries => { - "drugs_drug_proprietaries_and_druggist_sundries" - } + DrugsDrugProprietariesAndDruggistSundries => "drugs_drug_proprietaries_and_druggist_sundries", DryCleaners => "dry_cleaners", DurableGoods => "durable_goods", DutyFreeStores => "duty_free_stores", @@ -450,18 +536,14 @@ impl IssuingCardholderSpendingLimitCategories { FastFoodRestaurants => "fast_food_restaurants", FinancialInstitutions => "financial_institutions", FinesGovernmentAdministrativeEntities => "fines_government_administrative_entities", - FireplaceFireplaceScreensAndAccessoriesStores => { - "fireplace_fireplace_screens_and_accessories_stores" - } + FireplaceFireplaceScreensAndAccessoriesStores => "fireplace_fireplace_screens_and_accessories_stores", FloorCoveringStores => "floor_covering_stores", Florists => "florists", FloristsSuppliesNurseryStockAndFlowers => "florists_supplies_nursery_stock_and_flowers", FreezerAndLockerMeatProvisioners => "freezer_and_locker_meat_provisioners", FuelDealersNonAutomotive => "fuel_dealers_non_automotive", FuneralServicesCrematories => "funeral_services_crematories", - FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => { - "furniture_home_furnishings_and_equipment_stores_except_appliances" - } + FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances => "furniture_home_furnishings_and_equipment_stores_except_appliances", FurnitureRepairRefinishing => "furniture_repair_refinishing", FurriersAndFurShops => "furriers_and_fur_shops", GeneralServices => "general_services", @@ -469,12 +551,8 @@ impl IssuingCardholderSpendingLimitCategories { GlassPaintAndWallpaperStores => "glass_paint_and_wallpaper_stores", GlasswareCrystalStores => "glassware_crystal_stores", GolfCoursesPublic => "golf_courses_public", - GovernmentLicensedHorseDogRacingUsRegionOnly => { - "government_licensed_horse_dog_racing_us_region_only" - } - GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => { - "government_licensed_online_casions_online_gambling_us_region_only" - } + GovernmentLicensedHorseDogRacingUsRegionOnly => "government_licensed_horse_dog_racing_us_region_only", + GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly => "government_licensed_online_casions_online_gambling_us_region_only", GovernmentOwnedLotteriesNonUsRegion => "government_owned_lotteries_non_us_region", GovernmentOwnedLotteriesUsRegionOnly => "government_owned_lotteries_us_region_only", GovernmentServices => "government_services", @@ -494,9 +572,7 @@ impl IssuingCardholderSpendingLimitCategories { InsuranceDefault => "insurance_default", InsuranceUnderwritingPremiums => "insurance_underwriting_premiums", IntraCompanyPurchases => "intra_company_purchases", - JewelryStoresWatchesClocksAndSilverwareStores => { - "jewelry_stores_watches_clocks_and_silverware_stores" - } + JewelryStoresWatchesClocksAndSilverwareStores => "jewelry_stores_watches_clocks_and_silverware_stores", LandscapingServices => "landscaping_services", Laundries => "laundries", LaundryCleaningServices => "laundry_cleaning_services", @@ -509,14 +585,10 @@ impl IssuingCardholderSpendingLimitCategories { MasonryStoneworkAndPlaster => "masonry_stonework_and_plaster", MassageParlors => "massage_parlors", MedicalAndDentalLabs => "medical_and_dental_labs", - MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => { - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" - } + MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies => "medical_dental_ophthalmic_and_hospital_equipment_and_supplies", MedicalServices => "medical_services", MembershipOrganizations => "membership_organizations", - MensAndBoysClothingAndAccessoriesStores => { - "mens_and_boys_clothing_and_accessories_stores" - } + MensAndBoysClothingAndAccessoriesStores => "mens_and_boys_clothing_and_accessories_stores", MensWomensClothingStores => "mens_womens_clothing_stores", MetalServiceCenters => "metal_service_centers", Miscellaneous => "miscellaneous", @@ -526,9 +598,7 @@ impl IssuingCardholderSpendingLimitCategories { MiscellaneousFoodStores => "miscellaneous_food_stores", MiscellaneousGeneralMerchandise => "miscellaneous_general_merchandise", MiscellaneousGeneralServices => "miscellaneous_general_services", - MiscellaneousHomeFurnishingSpecialtyStores => { - "miscellaneous_home_furnishing_specialty_stores" - } + MiscellaneousHomeFurnishingSpecialtyStores => "miscellaneous_home_furnishing_specialty_stores", MiscellaneousPublishingAndPrinting => "miscellaneous_publishing_and_printing", MiscellaneousRecreationServices => "miscellaneous_recreation_services", MiscellaneousRepairShops => "miscellaneous_repair_shops", @@ -540,9 +610,7 @@ impl IssuingCardholderSpendingLimitCategories { MotorVehicleSuppliesAndNewParts => "motor_vehicle_supplies_and_new_parts", MotorcycleShopsAndDealers => "motorcycle_shops_and_dealers", MotorcycleShopsDealers => "motorcycle_shops_dealers", - MusicStoresMusicalInstrumentsPianosAndSheetMusic => { - "music_stores_musical_instruments_pianos_and_sheet_music" - } + MusicStoresMusicalInstrumentsPianosAndSheetMusic => "music_stores_musical_instruments_pianos_and_sheet_music", NewsDealersAndNewsstands => "news_dealers_and_newsstands", NonFiMoneyOrders => "non_fi_money_orders", NonFiStoredValueCardPurchaseLoad => "non_fi_stored_value_card_purchase_load", @@ -562,18 +630,14 @@ impl IssuingCardholderSpendingLimitCategories { PetShopsPetFoodAndSupplies => "pet_shops_pet_food_and_supplies", PetroleumAndPetroleumProducts => "petroleum_and_petroleum_products", PhotoDeveloping => "photo_developing", - PhotographicPhotocopyMicrofilmEquipmentAndSupplies => { - "photographic_photocopy_microfilm_equipment_and_supplies" - } + PhotographicPhotocopyMicrofilmEquipmentAndSupplies => "photographic_photocopy_microfilm_equipment_and_supplies", PhotographicStudios => "photographic_studios", PictureVideoProduction => "picture_video_production", PieceGoodsNotionsAndOtherDryGoods => "piece_goods_notions_and_other_dry_goods", PlumbingHeatingEquipmentAndSupplies => "plumbing_heating_equipment_and_supplies", PoliticalOrganizations => "political_organizations", PostalServicesGovernmentOnly => "postal_services_government_only", - PreciousStonesAndMetalsWatchesAndJewelry => { - "precious_stones_and_metals_watches_and_jewelry" - } + PreciousStonesAndMetalsWatchesAndJewelry => "precious_stones_and_metals_watches_and_jewelry", ProfessionalServices => "professional_services", PublicWarehousingAndStorage => "public_warehousing_and_storage", QuickCopyReproAndBlueprint => "quick_copy_repro_and_blueprint", @@ -587,9 +651,7 @@ impl IssuingCardholderSpendingLimitCategories { SecretarialSupportServices => "secretarial_support_services", SecurityBrokersDealers => "security_brokers_dealers", ServiceStations => "service_stations", - SewingNeedleworkFabricAndPieceGoodsStores => { - "sewing_needlework_fabric_and_piece_goods_stores" - } + SewingNeedleworkFabricAndPieceGoodsStores => "sewing_needlework_fabric_and_piece_goods_stores", ShoeRepairHatCleaning => "shoe_repair_hat_cleaning", ShoeStores => "shoe_stores", SmallApplianceRepair => "small_appliance_repair", @@ -601,21 +663,15 @@ impl IssuingCardholderSpendingLimitCategories { SportsAndRidingApparelStores => "sports_and_riding_apparel_stores", SportsClubsFields => "sports_clubs_fields", StampAndCoinStores => "stamp_and_coin_stores", - StationaryOfficeSuppliesPrintingAndWritingPaper => { - "stationary_office_supplies_printing_and_writing_paper" - } - StationeryStoresOfficeAndSchoolSupplyStores => { - "stationery_stores_office_and_school_supply_stores" - } + StationaryOfficeSuppliesPrintingAndWritingPaper => "stationary_office_supplies_printing_and_writing_paper", + StationeryStoresOfficeAndSchoolSupplyStores => "stationery_stores_office_and_school_supply_stores", SwimmingPoolsSales => "swimming_pools_sales", TUiTravelGermany => "t_ui_travel_germany", TailorsAlterations => "tailors_alterations", TaxPaymentsGovernmentAgencies => "tax_payments_government_agencies", TaxPreparationServices => "tax_preparation_services", TaxicabsLimousines => "taxicabs_limousines", - TelecommunicationEquipmentAndTelephoneSales => { - "telecommunication_equipment_and_telephone_sales" - } + TelecommunicationEquipmentAndTelephoneSales => "telecommunication_equipment_and_telephone_sales", TelecommunicationServices => "telecommunication_services", TelegraphServices => "telegraph_services", TentAndAwningShops => "tent_and_awning_shops", @@ -631,13 +687,9 @@ impl IssuingCardholderSpendingLimitCategories { TravelAgenciesTourOperators => "travel_agencies_tour_operators", TruckStopIteration => "truck_stop_iteration", TruckUtilityTrailerRentals => "truck_utility_trailer_rentals", - TypesettingPlateMakingAndRelatedServices => { - "typesetting_plate_making_and_related_services" - } + TypesettingPlateMakingAndRelatedServices => "typesetting_plate_making_and_related_services", TypewriterStores => "typewriter_stores", - USFederalGovernmentAgenciesOrDepartments => { - "u_s_federal_government_agencies_or_departments" - } + USFederalGovernmentAgenciesOrDepartments => "u_s_federal_government_agencies_or_departments", UniformsCommercialClothing => "uniforms_commercial_clothing", UsedMerchandiseAndSecondhandStores => "used_merchandise_and_secondhand_stores", Utilities => "utilities", @@ -703,9 +755,7 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "bus_lines" => Ok(BusLines), "business_secretarial_schools" => Ok(BusinessSecretarialSchools), "buying_shopping_services" => Ok(BuyingShoppingServices), - "cable_satellite_and_other_pay_television_and_radio" => { - Ok(CableSatelliteAndOtherPayTelevisionAndRadio) - } + "cable_satellite_and_other_pay_television_and_radio" => Ok(CableSatelliteAndOtherPayTelevisionAndRadio), "camera_and_photographic_supply_stores" => Ok(CameraAndPhotographicSupplyStores), "candy_nut_and_confectionery_stores" => Ok(CandyNutAndConfectioneryStores), "car_and_truck_dealers_new_used" => Ok(CarAndTruckDealersNewUsed), @@ -715,9 +765,7 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "carpentry_services" => Ok(CarpentryServices), "carpet_upholstery_cleaning" => Ok(CarpetUpholsteryCleaning), "caterers" => Ok(Caterers), - "charitable_and_social_service_organizations_fundraising" => { - Ok(CharitableAndSocialServiceOrganizationsFundraising) - } + "charitable_and_social_service_organizations_fundraising" => Ok(CharitableAndSocialServiceOrganizationsFundraising), "chemicals_and_allied_products" => Ok(ChemicalsAndAlliedProducts), "child_care_services" => Ok(ChildCareServices), "childrens_and_infants_wear_stores" => Ok(ChildrensAndInfantsWearStores), @@ -759,9 +807,7 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "digital_goods_large_volume" => Ok(DigitalGoodsLargeVolume), "digital_goods_media" => Ok(DigitalGoodsMedia), "direct_marketing_catalog_merchant" => Ok(DirectMarketingCatalogMerchant), - "direct_marketing_combination_catalog_and_retail_merchant" => { - Ok(DirectMarketingCombinationCatalogAndRetailMerchant) - } + "direct_marketing_combination_catalog_and_retail_merchant" => Ok(DirectMarketingCombinationCatalogAndRetailMerchant), "direct_marketing_inbound_telemarketing" => Ok(DirectMarketingInboundTelemarketing), "direct_marketing_insurance_services" => Ok(DirectMarketingInsuranceServices), "direct_marketing_other" => Ok(DirectMarketingOther), @@ -771,14 +817,10 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "discount_stores" => Ok(DiscountStores), "doctors" => Ok(Doctors), "door_to_door_sales" => Ok(DoorToDoorSales), - "drapery_window_covering_and_upholstery_stores" => { - Ok(DraperyWindowCoveringAndUpholsteryStores) - } + "drapery_window_covering_and_upholstery_stores" => Ok(DraperyWindowCoveringAndUpholsteryStores), "drinking_places" => Ok(DrinkingPlaces), "drug_stores_and_pharmacies" => Ok(DrugStoresAndPharmacies), - "drugs_drug_proprietaries_and_druggist_sundries" => { - Ok(DrugsDrugProprietariesAndDruggistSundries) - } + "drugs_drug_proprietaries_and_druggist_sundries" => Ok(DrugsDrugProprietariesAndDruggistSundries), "dry_cleaners" => Ok(DryCleaners), "durable_goods" => Ok(DurableGoods), "duty_free_stores" => Ok(DutyFreeStores), @@ -799,20 +841,14 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "fast_food_restaurants" => Ok(FastFoodRestaurants), "financial_institutions" => Ok(FinancialInstitutions), "fines_government_administrative_entities" => Ok(FinesGovernmentAdministrativeEntities), - "fireplace_fireplace_screens_and_accessories_stores" => { - Ok(FireplaceFireplaceScreensAndAccessoriesStores) - } + "fireplace_fireplace_screens_and_accessories_stores" => Ok(FireplaceFireplaceScreensAndAccessoriesStores), "floor_covering_stores" => Ok(FloorCoveringStores), "florists" => Ok(Florists), - "florists_supplies_nursery_stock_and_flowers" => { - Ok(FloristsSuppliesNurseryStockAndFlowers) - } + "florists_supplies_nursery_stock_and_flowers" => Ok(FloristsSuppliesNurseryStockAndFlowers), "freezer_and_locker_meat_provisioners" => Ok(FreezerAndLockerMeatProvisioners), "fuel_dealers_non_automotive" => Ok(FuelDealersNonAutomotive), "funeral_services_crematories" => Ok(FuneralServicesCrematories), - "furniture_home_furnishings_and_equipment_stores_except_appliances" => { - Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances) - } + "furniture_home_furnishings_and_equipment_stores_except_appliances" => Ok(FurnitureHomeFurnishingsAndEquipmentStoresExceptAppliances), "furniture_repair_refinishing" => Ok(FurnitureRepairRefinishing), "furriers_and_fur_shops" => Ok(FurriersAndFurShops), "general_services" => Ok(GeneralServices), @@ -820,12 +856,8 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "glass_paint_and_wallpaper_stores" => Ok(GlassPaintAndWallpaperStores), "glassware_crystal_stores" => Ok(GlasswareCrystalStores), "golf_courses_public" => Ok(GolfCoursesPublic), - "government_licensed_horse_dog_racing_us_region_only" => { - Ok(GovernmentLicensedHorseDogRacingUsRegionOnly) - } - "government_licensed_online_casions_online_gambling_us_region_only" => { - Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly) - } + "government_licensed_horse_dog_racing_us_region_only" => Ok(GovernmentLicensedHorseDogRacingUsRegionOnly), + "government_licensed_online_casions_online_gambling_us_region_only" => Ok(GovernmentLicensedOnlineCasionsOnlineGamblingUsRegionOnly), "government_owned_lotteries_non_us_region" => Ok(GovernmentOwnedLotteriesNonUsRegion), "government_owned_lotteries_us_region_only" => Ok(GovernmentOwnedLotteriesUsRegionOnly), "government_services" => Ok(GovernmentServices), @@ -845,9 +877,7 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "insurance_default" => Ok(InsuranceDefault), "insurance_underwriting_premiums" => Ok(InsuranceUnderwritingPremiums), "intra_company_purchases" => Ok(IntraCompanyPurchases), - "jewelry_stores_watches_clocks_and_silverware_stores" => { - Ok(JewelryStoresWatchesClocksAndSilverwareStores) - } + "jewelry_stores_watches_clocks_and_silverware_stores" => Ok(JewelryStoresWatchesClocksAndSilverwareStores), "landscaping_services" => Ok(LandscapingServices), "laundries" => Ok(Laundries), "laundry_cleaning_services" => Ok(LaundryCleaningServices), @@ -860,28 +890,20 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "masonry_stonework_and_plaster" => Ok(MasonryStoneworkAndPlaster), "massage_parlors" => Ok(MassageParlors), "medical_and_dental_labs" => Ok(MedicalAndDentalLabs), - "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => { - Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies) - } + "medical_dental_ophthalmic_and_hospital_equipment_and_supplies" => Ok(MedicalDentalOphthalmicAndHospitalEquipmentAndSupplies), "medical_services" => Ok(MedicalServices), "membership_organizations" => Ok(MembershipOrganizations), - "mens_and_boys_clothing_and_accessories_stores" => { - Ok(MensAndBoysClothingAndAccessoriesStores) - } + "mens_and_boys_clothing_and_accessories_stores" => Ok(MensAndBoysClothingAndAccessoriesStores), "mens_womens_clothing_stores" => Ok(MensWomensClothingStores), "metal_service_centers" => Ok(MetalServiceCenters), "miscellaneous" => Ok(Miscellaneous), - "miscellaneous_apparel_and_accessory_shops" => { - Ok(MiscellaneousApparelAndAccessoryShops) - } + "miscellaneous_apparel_and_accessory_shops" => Ok(MiscellaneousApparelAndAccessoryShops), "miscellaneous_auto_dealers" => Ok(MiscellaneousAutoDealers), "miscellaneous_business_services" => Ok(MiscellaneousBusinessServices), "miscellaneous_food_stores" => Ok(MiscellaneousFoodStores), "miscellaneous_general_merchandise" => Ok(MiscellaneousGeneralMerchandise), "miscellaneous_general_services" => Ok(MiscellaneousGeneralServices), - "miscellaneous_home_furnishing_specialty_stores" => { - Ok(MiscellaneousHomeFurnishingSpecialtyStores) - } + "miscellaneous_home_furnishing_specialty_stores" => Ok(MiscellaneousHomeFurnishingSpecialtyStores), "miscellaneous_publishing_and_printing" => Ok(MiscellaneousPublishingAndPrinting), "miscellaneous_recreation_services" => Ok(MiscellaneousRecreationServices), "miscellaneous_repair_shops" => Ok(MiscellaneousRepairShops), @@ -893,9 +915,7 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "motor_vehicle_supplies_and_new_parts" => Ok(MotorVehicleSuppliesAndNewParts), "motorcycle_shops_and_dealers" => Ok(MotorcycleShopsAndDealers), "motorcycle_shops_dealers" => Ok(MotorcycleShopsDealers), - "music_stores_musical_instruments_pianos_and_sheet_music" => { - Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic) - } + "music_stores_musical_instruments_pianos_and_sheet_music" => Ok(MusicStoresMusicalInstrumentsPianosAndSheetMusic), "news_dealers_and_newsstands" => Ok(NewsDealersAndNewsstands), "non_fi_money_orders" => Ok(NonFiMoneyOrders), "non_fi_stored_value_card_purchase_load" => Ok(NonFiStoredValueCardPurchaseLoad), @@ -915,18 +935,14 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "pet_shops_pet_food_and_supplies" => Ok(PetShopsPetFoodAndSupplies), "petroleum_and_petroleum_products" => Ok(PetroleumAndPetroleumProducts), "photo_developing" => Ok(PhotoDeveloping), - "photographic_photocopy_microfilm_equipment_and_supplies" => { - Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies) - } + "photographic_photocopy_microfilm_equipment_and_supplies" => Ok(PhotographicPhotocopyMicrofilmEquipmentAndSupplies), "photographic_studios" => Ok(PhotographicStudios), "picture_video_production" => Ok(PictureVideoProduction), "piece_goods_notions_and_other_dry_goods" => Ok(PieceGoodsNotionsAndOtherDryGoods), "plumbing_heating_equipment_and_supplies" => Ok(PlumbingHeatingEquipmentAndSupplies), "political_organizations" => Ok(PoliticalOrganizations), "postal_services_government_only" => Ok(PostalServicesGovernmentOnly), - "precious_stones_and_metals_watches_and_jewelry" => { - Ok(PreciousStonesAndMetalsWatchesAndJewelry) - } + "precious_stones_and_metals_watches_and_jewelry" => Ok(PreciousStonesAndMetalsWatchesAndJewelry), "professional_services" => Ok(ProfessionalServices), "public_warehousing_and_storage" => Ok(PublicWarehousingAndStorage), "quick_copy_repro_and_blueprint" => Ok(QuickCopyReproAndBlueprint), @@ -940,9 +956,7 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "secretarial_support_services" => Ok(SecretarialSupportServices), "security_brokers_dealers" => Ok(SecurityBrokersDealers), "service_stations" => Ok(ServiceStations), - "sewing_needlework_fabric_and_piece_goods_stores" => { - Ok(SewingNeedleworkFabricAndPieceGoodsStores) - } + "sewing_needlework_fabric_and_piece_goods_stores" => Ok(SewingNeedleworkFabricAndPieceGoodsStores), "shoe_repair_hat_cleaning" => Ok(ShoeRepairHatCleaning), "shoe_stores" => Ok(ShoeStores), "small_appliance_repair" => Ok(SmallApplianceRepair), @@ -954,21 +968,15 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "sports_and_riding_apparel_stores" => Ok(SportsAndRidingApparelStores), "sports_clubs_fields" => Ok(SportsClubsFields), "stamp_and_coin_stores" => Ok(StampAndCoinStores), - "stationary_office_supplies_printing_and_writing_paper" => { - Ok(StationaryOfficeSuppliesPrintingAndWritingPaper) - } - "stationery_stores_office_and_school_supply_stores" => { - Ok(StationeryStoresOfficeAndSchoolSupplyStores) - } + "stationary_office_supplies_printing_and_writing_paper" => Ok(StationaryOfficeSuppliesPrintingAndWritingPaper), + "stationery_stores_office_and_school_supply_stores" => Ok(StationeryStoresOfficeAndSchoolSupplyStores), "swimming_pools_sales" => Ok(SwimmingPoolsSales), "t_ui_travel_germany" => Ok(TUiTravelGermany), "tailors_alterations" => Ok(TailorsAlterations), "tax_payments_government_agencies" => Ok(TaxPaymentsGovernmentAgencies), "tax_preparation_services" => Ok(TaxPreparationServices), "taxicabs_limousines" => Ok(TaxicabsLimousines), - "telecommunication_equipment_and_telephone_sales" => { - Ok(TelecommunicationEquipmentAndTelephoneSales) - } + "telecommunication_equipment_and_telephone_sales" => Ok(TelecommunicationEquipmentAndTelephoneSales), "telecommunication_services" => Ok(TelecommunicationServices), "telegraph_services" => Ok(TelegraphServices), "tent_and_awning_shops" => Ok(TentAndAwningShops), @@ -984,13 +992,9 @@ impl std::str::FromStr for IssuingCardholderSpendingLimitCategories { "travel_agencies_tour_operators" => Ok(TravelAgenciesTourOperators), "truck_stop_iteration" => Ok(TruckStopIteration), "truck_utility_trailer_rentals" => Ok(TruckUtilityTrailerRentals), - "typesetting_plate_making_and_related_services" => { - Ok(TypesettingPlateMakingAndRelatedServices) - } + "typesetting_plate_making_and_related_services" => Ok(TypesettingPlateMakingAndRelatedServices), "typewriter_stores" => Ok(TypewriterStores), - "u_s_federal_government_agencies_or_departments" => { - Ok(USFederalGovernmentAgenciesOrDepartments) - } + "u_s_federal_government_agencies_or_departments" => Ok(USFederalGovernmentAgenciesOrDepartments), "uniforms_commercial_clothing" => Ok(UniformsCommercialClothing), "used_merchandise_and_secondhand_stores" => Ok(UsedMerchandiseAndSecondhandStores), "utilities" => Ok(Utilities), @@ -1035,9 +1039,27 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderSpendingLimitCategories { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(IssuingCardholderSpendingLimitCategories::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderSpendingLimitCategories { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderSpendingLimitCategories> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderSpendingLimitCategories::from_str(s).unwrap_or(IssuingCardholderSpendingLimitCategories::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderSpendingLimitCategories); /// Interval (or event) to which the amount applies. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingCardholderSpendingLimitInterval { @@ -1100,8 +1122,24 @@ impl<'de> serde::Deserialize<'de> for IssuingCardholderSpendingLimitInterval { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingCardholderSpendingLimitInterval") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingCardholderSpendingLimitInterval")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingCardholderSpendingLimitInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingCardholderSpendingLimitInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderSpendingLimitInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingCardholderSpendingLimitInterval); diff --git a/generated/stripe_shared/src/issuing_cardholder_user_terms_acceptance.rs b/generated/stripe_shared/src/issuing_cardholder_user_terms_acceptance.rs index b86c849fe..60803a3ca 100644 --- a/generated/stripe_shared/src/issuing_cardholder_user_terms_acceptance.rs +++ b/generated/stripe_shared/src/issuing_cardholder_user_terms_acceptance.rs @@ -1,9 +1,107 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderUserTermsAcceptance { /// The Unix timestamp marking when the cardholder accepted the Authorized User Terms. + /// Required for Celtic Spend Card users. pub date: Option<stripe_types::Timestamp>, /// The IP address from which the cardholder accepted the Authorized User Terms. + /// Required for Celtic Spend Card users. pub ip: Option<String>, /// The user agent of the browser from which the cardholder accepted the Authorized User Terms. pub user_agent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderUserTermsAcceptanceBuilder { + date: Option<Option<stripe_types::Timestamp>>, + ip: Option<Option<String>>, + user_agent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderUserTermsAcceptance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderUserTermsAcceptance>, + builder: IssuingCardholderUserTermsAcceptanceBuilder, + } + + impl Visitor for Place<IssuingCardholderUserTermsAcceptance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderUserTermsAcceptanceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderUserTermsAcceptanceBuilder { + type Out = IssuingCardholderUserTermsAcceptance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "date" => Deserialize::begin(&mut self.date), + "ip" => Deserialize::begin(&mut self.ip), + "user_agent" => Deserialize::begin(&mut self.user_agent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { date: Deserialize::default(), ip: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let date = self.date.take()?; + let ip = self.ip.take()?; + let user_agent = self.user_agent.take()?; + + Some(Self::Out { date, ip, user_agent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderUserTermsAcceptance { + type Builder = IssuingCardholderUserTermsAcceptanceBuilder; + } + + impl FromValueOpt for IssuingCardholderUserTermsAcceptance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderUserTermsAcceptanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "date" => b.date = Some(FromValueOpt::from_value(v)?), + "ip" => b.ip = Some(FromValueOpt::from_value(v)?), + "user_agent" => b.user_agent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_cardholder_verification.rs b/generated/stripe_shared/src/issuing_cardholder_verification.rs index 4fabd9d05..ecfb4e3ee 100644 --- a/generated/stripe_shared/src/issuing_cardholder_verification.rs +++ b/generated/stripe_shared/src/issuing_cardholder_verification.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingCardholderVerification { /// An identifying document, either a passport or local ID card. pub document: Option<stripe_shared::IssuingCardholderIdDocument>, } +#[cfg(feature = "min-ser")] +pub struct IssuingCardholderVerificationBuilder { + document: Option<Option<stripe_shared::IssuingCardholderIdDocument>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingCardholderVerification { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingCardholderVerification>, + builder: IssuingCardholderVerificationBuilder, + } + + impl Visitor for Place<IssuingCardholderVerification> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingCardholderVerificationBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingCardholderVerificationBuilder { + type Out = IssuingCardholderVerification; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "document" => Deserialize::begin(&mut self.document), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let document = self.document.take()?; + + Some(Self::Out { document }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingCardholderVerification { + type Builder = IssuingCardholderVerificationBuilder; + } + + impl FromValueOpt for IssuingCardholderVerification { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingCardholderVerificationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "document" => b.document = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_dispute.rs b/generated/stripe_shared/src/issuing_dispute.rs index 23672233a..098cee7dd 100644 --- a/generated/stripe_shared/src/issuing_dispute.rs +++ b/generated/stripe_shared/src/issuing_dispute.rs @@ -3,7 +3,9 @@ /// Related guide: [Issuing disputes](https://stripe.com/docs/issuing/purchases/disputes) /// /// For more details see <<https://stripe.com/docs/api/issuing/disputes/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDispute { /// Disputed amount in the card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// Usually the amount of the `transaction`, but can differ (usually because of currency fluctuation). @@ -27,9 +29,146 @@ pub struct IssuingDispute { /// The transaction being disputed. pub transaction: stripe_types::Expandable<stripe_shared::IssuingTransaction>, /// [Treasury](https://stripe.com/docs/api/treasury) details related to this dispute if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts. - #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option<stripe_shared::IssuingDisputeTreasury>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeBuilder { + amount: Option<i64>, + balance_transactions: Option<Option<Vec<stripe_shared::BalanceTransaction>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + evidence: Option<stripe_shared::IssuingDisputeEvidence>, + id: Option<stripe_shared::IssuingDisputeId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + status: Option<stripe_shared::IssuingDisputeStatus>, + transaction: Option<stripe_types::Expandable<stripe_shared::IssuingTransaction>>, + treasury: Option<Option<stripe_shared::IssuingDisputeTreasury>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDispute { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDispute>, + builder: IssuingDisputeBuilder, + } + + impl Visitor for Place<IssuingDispute> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeBuilder { + type Out = IssuingDispute; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "balance_transactions" => Deserialize::begin(&mut self.balance_transactions), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "evidence" => Deserialize::begin(&mut self.evidence), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "status" => Deserialize::begin(&mut self.status), + "transaction" => Deserialize::begin(&mut self.transaction), + "treasury" => Deserialize::begin(&mut self.treasury), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + balance_transactions: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + evidence: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + status: Deserialize::default(), + transaction: Deserialize::default(), + treasury: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let balance_transactions = self.balance_transactions.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let evidence = self.evidence.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let status = self.status.take()?; + let transaction = self.transaction.take()?; + let treasury = self.treasury.take()?; + + Some(Self::Out { amount, balance_transactions, created, currency, evidence, id, livemode, metadata, status, transaction, treasury }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDispute { + type Builder = IssuingDisputeBuilder; + } + + impl FromValueOpt for IssuingDispute { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "balance_transactions" => b.balance_transactions = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "evidence" => b.evidence = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + "treasury" => b.treasury = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for IssuingDispute { type Id = stripe_shared::IssuingDisputeId; fn id(&self) -> &Self::Id { @@ -95,7 +234,24 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingDisputeStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingDisputeStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingDisputeStatus); diff --git a/generated/stripe_shared/src/issuing_dispute_canceled_evidence.rs b/generated/stripe_shared/src/issuing_dispute_canceled_evidence.rs index f060bf7a0..5e3b92718 100644 --- a/generated/stripe_shared/src/issuing_dispute_canceled_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_canceled_evidence.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeCanceledEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -21,6 +23,150 @@ pub struct IssuingDisputeCanceledEvidence { /// Date when the product was returned or attempted to be returned. pub returned_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeCanceledEvidenceBuilder { + additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + canceled_at: Option<Option<stripe_types::Timestamp>>, + cancellation_policy_provided: Option<Option<bool>>, + cancellation_reason: Option<Option<String>>, + expected_at: Option<Option<stripe_types::Timestamp>>, + explanation: Option<Option<String>>, + product_description: Option<Option<String>>, + product_type: Option<Option<IssuingDisputeCanceledEvidenceProductType>>, + return_status: Option<Option<IssuingDisputeCanceledEvidenceReturnStatus>>, + returned_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeCanceledEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeCanceledEvidence>, + builder: IssuingDisputeCanceledEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeCanceledEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeCanceledEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeCanceledEvidenceBuilder { + type Out = IssuingDisputeCanceledEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_documentation" => Deserialize::begin(&mut self.additional_documentation), + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "cancellation_policy_provided" => Deserialize::begin(&mut self.cancellation_policy_provided), + "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason), + "expected_at" => Deserialize::begin(&mut self.expected_at), + "explanation" => Deserialize::begin(&mut self.explanation), + "product_description" => Deserialize::begin(&mut self.product_description), + "product_type" => Deserialize::begin(&mut self.product_type), + "return_status" => Deserialize::begin(&mut self.return_status), + "returned_at" => Deserialize::begin(&mut self.returned_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + additional_documentation: Deserialize::default(), + canceled_at: Deserialize::default(), + cancellation_policy_provided: Deserialize::default(), + cancellation_reason: Deserialize::default(), + expected_at: Deserialize::default(), + explanation: Deserialize::default(), + product_description: Deserialize::default(), + product_type: Deserialize::default(), + return_status: Deserialize::default(), + returned_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_documentation = self.additional_documentation.take()?; + let canceled_at = self.canceled_at.take()?; + let cancellation_policy_provided = self.cancellation_policy_provided.take()?; + let cancellation_reason = self.cancellation_reason.take()?; + let expected_at = self.expected_at.take()?; + let explanation = self.explanation.take()?; + let product_description = self.product_description.take()?; + let product_type = self.product_type.take()?; + let return_status = self.return_status.take()?; + let returned_at = self.returned_at.take()?; + + Some(Self::Out { + additional_documentation, + canceled_at, + cancellation_policy_provided, + cancellation_reason, + expected_at, + explanation, + product_description, + product_type, + return_status, + returned_at, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeCanceledEvidence { + type Builder = IssuingDisputeCanceledEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeCanceledEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeCanceledEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_documentation" => b.additional_documentation = Some(FromValueOpt::from_value(v)?), + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "cancellation_policy_provided" => b.cancellation_policy_provided = Some(FromValueOpt::from_value(v)?), + "cancellation_reason" => b.cancellation_reason = Some(FromValueOpt::from_value(v)?), + "expected_at" => b.expected_at = Some(FromValueOpt::from_value(v)?), + "explanation" => b.explanation = Some(FromValueOpt::from_value(v)?), + "product_description" => b.product_description = Some(FromValueOpt::from_value(v)?), + "product_type" => b.product_type = Some(FromValueOpt::from_value(v)?), + "return_status" => b.return_status = Some(FromValueOpt::from_value(v)?), + "returned_at" => b.returned_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether the product was a merchandise or service. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingDisputeCanceledEvidenceProductType { @@ -71,11 +217,27 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeCanceledEvidenceProductType fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingDisputeCanceledEvidenceProductType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeCanceledEvidenceProductType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingDisputeCanceledEvidenceProductType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingDisputeCanceledEvidenceProductType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeCanceledEvidenceProductType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingDisputeCanceledEvidenceProductType); /// Result of cardholder's attempt to return the product. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingDisputeCanceledEvidenceReturnStatus { @@ -126,8 +288,24 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeCanceledEvidenceReturnStatus fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingDisputeCanceledEvidenceReturnStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeCanceledEvidenceReturnStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingDisputeCanceledEvidenceReturnStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingDisputeCanceledEvidenceReturnStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeCanceledEvidenceReturnStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingDisputeCanceledEvidenceReturnStatus); diff --git a/generated/stripe_shared/src/issuing_dispute_duplicate_evidence.rs b/generated/stripe_shared/src/issuing_dispute_duplicate_evidence.rs index 816a47a52..44b602c47 100644 --- a/generated/stripe_shared/src/issuing_dispute_duplicate_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_duplicate_evidence.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeDuplicateEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -14,3 +16,116 @@ pub struct IssuingDisputeDuplicateEvidence { /// Of the two or more transactions that are copies of each other, this is original undisputed one. pub original_transaction: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeDuplicateEvidenceBuilder { + additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + card_statement: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + cash_receipt: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + check_image: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + explanation: Option<Option<String>>, + original_transaction: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeDuplicateEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeDuplicateEvidence>, + builder: IssuingDisputeDuplicateEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeDuplicateEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeDuplicateEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeDuplicateEvidenceBuilder { + type Out = IssuingDisputeDuplicateEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_documentation" => Deserialize::begin(&mut self.additional_documentation), + "card_statement" => Deserialize::begin(&mut self.card_statement), + "cash_receipt" => Deserialize::begin(&mut self.cash_receipt), + "check_image" => Deserialize::begin(&mut self.check_image), + "explanation" => Deserialize::begin(&mut self.explanation), + "original_transaction" => Deserialize::begin(&mut self.original_transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + additional_documentation: Deserialize::default(), + card_statement: Deserialize::default(), + cash_receipt: Deserialize::default(), + check_image: Deserialize::default(), + explanation: Deserialize::default(), + original_transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_documentation = self.additional_documentation.take()?; + let card_statement = self.card_statement.take()?; + let cash_receipt = self.cash_receipt.take()?; + let check_image = self.check_image.take()?; + let explanation = self.explanation.take()?; + let original_transaction = self.original_transaction.take()?; + + Some(Self::Out { additional_documentation, card_statement, cash_receipt, check_image, explanation, original_transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeDuplicateEvidence { + type Builder = IssuingDisputeDuplicateEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeDuplicateEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeDuplicateEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_documentation" => b.additional_documentation = Some(FromValueOpt::from_value(v)?), + "card_statement" => b.card_statement = Some(FromValueOpt::from_value(v)?), + "cash_receipt" => b.cash_receipt = Some(FromValueOpt::from_value(v)?), + "check_image" => b.check_image = Some(FromValueOpt::from_value(v)?), + "explanation" => b.explanation = Some(FromValueOpt::from_value(v)?), + "original_transaction" => b.original_transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_dispute_evidence.rs b/generated/stripe_shared/src/issuing_dispute_evidence.rs index 8435e921b..6f60c4905 100644 --- a/generated/stripe_shared/src/issuing_dispute_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_evidence.rs @@ -1,24 +1,140 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeEvidence { - #[serde(skip_serializing_if = "Option::is_none")] pub canceled: Option<stripe_shared::IssuingDisputeCanceledEvidence>, - #[serde(skip_serializing_if = "Option::is_none")] pub duplicate: Option<stripe_shared::IssuingDisputeDuplicateEvidence>, - #[serde(skip_serializing_if = "Option::is_none")] pub fraudulent: Option<stripe_shared::IssuingDisputeFraudulentEvidence>, - #[serde(skip_serializing_if = "Option::is_none")] - pub merchandise_not_as_described: - Option<stripe_shared::IssuingDisputeMerchandiseNotAsDescribedEvidence>, - #[serde(skip_serializing_if = "Option::is_none")] + pub merchandise_not_as_described: Option<stripe_shared::IssuingDisputeMerchandiseNotAsDescribedEvidence>, pub not_received: Option<stripe_shared::IssuingDisputeNotReceivedEvidence>, - #[serde(skip_serializing_if = "Option::is_none")] pub other: Option<stripe_shared::IssuingDisputeOtherEvidence>, /// The reason for filing the dispute. Its value will match the field containing the evidence. pub reason: IssuingDisputeEvidenceReason, - #[serde(skip_serializing_if = "Option::is_none")] - pub service_not_as_described: - Option<stripe_shared::IssuingDisputeServiceNotAsDescribedEvidence>, + pub service_not_as_described: Option<stripe_shared::IssuingDisputeServiceNotAsDescribedEvidence>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeEvidenceBuilder { + canceled: Option<Option<stripe_shared::IssuingDisputeCanceledEvidence>>, + duplicate: Option<Option<stripe_shared::IssuingDisputeDuplicateEvidence>>, + fraudulent: Option<Option<stripe_shared::IssuingDisputeFraudulentEvidence>>, + merchandise_not_as_described: Option<Option<stripe_shared::IssuingDisputeMerchandiseNotAsDescribedEvidence>>, + not_received: Option<Option<stripe_shared::IssuingDisputeNotReceivedEvidence>>, + other: Option<Option<stripe_shared::IssuingDisputeOtherEvidence>>, + reason: Option<IssuingDisputeEvidenceReason>, + service_not_as_described: Option<Option<stripe_shared::IssuingDisputeServiceNotAsDescribedEvidence>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeEvidence>, + builder: IssuingDisputeEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeEvidenceBuilder { + type Out = IssuingDisputeEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "canceled" => Deserialize::begin(&mut self.canceled), + "duplicate" => Deserialize::begin(&mut self.duplicate), + "fraudulent" => Deserialize::begin(&mut self.fraudulent), + "merchandise_not_as_described" => Deserialize::begin(&mut self.merchandise_not_as_described), + "not_received" => Deserialize::begin(&mut self.not_received), + "other" => Deserialize::begin(&mut self.other), + "reason" => Deserialize::begin(&mut self.reason), + "service_not_as_described" => Deserialize::begin(&mut self.service_not_as_described), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + canceled: Deserialize::default(), + duplicate: Deserialize::default(), + fraudulent: Deserialize::default(), + merchandise_not_as_described: Deserialize::default(), + not_received: Deserialize::default(), + other: Deserialize::default(), + reason: Deserialize::default(), + service_not_as_described: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let canceled = self.canceled.take()?; + let duplicate = self.duplicate.take()?; + let fraudulent = self.fraudulent.take()?; + let merchandise_not_as_described = self.merchandise_not_as_described.take()?; + let not_received = self.not_received.take()?; + let other = self.other.take()?; + let reason = self.reason.take()?; + let service_not_as_described = self.service_not_as_described.take()?; + + Some(Self::Out { canceled, duplicate, fraudulent, merchandise_not_as_described, not_received, other, reason, service_not_as_described }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeEvidence { + type Builder = IssuingDisputeEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "canceled" => b.canceled = Some(FromValueOpt::from_value(v)?), + "duplicate" => b.duplicate = Some(FromValueOpt::from_value(v)?), + "fraudulent" => b.fraudulent = Some(FromValueOpt::from_value(v)?), + "merchandise_not_as_described" => b.merchandise_not_as_described = Some(FromValueOpt::from_value(v)?), + "not_received" => b.not_received = Some(FromValueOpt::from_value(v)?), + "other" => b.other = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "service_not_as_described" => b.service_not_as_described = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reason for filing the dispute. Its value will match the field containing the evidence. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingDisputeEvidenceReason { @@ -84,7 +200,24 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeEvidenceReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeEvidenceReason")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeEvidenceReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingDisputeEvidenceReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingDisputeEvidenceReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeEvidenceReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingDisputeEvidenceReason); diff --git a/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs b/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs index 36058d9c0..498ec0485 100644 --- a/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeFraudulentEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>, /// Explanation of why the cardholder is disputing this transaction. pub explanation: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeFraudulentEvidenceBuilder { + additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + explanation: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeFraudulentEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeFraudulentEvidence>, + builder: IssuingDisputeFraudulentEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeFraudulentEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeFraudulentEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeFraudulentEvidenceBuilder { + type Out = IssuingDisputeFraudulentEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_documentation" => Deserialize::begin(&mut self.additional_documentation), + "explanation" => Deserialize::begin(&mut self.explanation), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { additional_documentation: Deserialize::default(), explanation: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_documentation = self.additional_documentation.take()?; + let explanation = self.explanation.take()?; + + Some(Self::Out { additional_documentation, explanation }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeFraudulentEvidence { + type Builder = IssuingDisputeFraudulentEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeFraudulentEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeFraudulentEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_documentation" => b.additional_documentation = Some(FromValueOpt::from_value(v)?), + "explanation" => b.explanation = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_dispute_merchandise_not_as_described_evidence.rs b/generated/stripe_shared/src/issuing_dispute_merchandise_not_as_described_evidence.rs index 8760b0584..ab4c004f0 100644 --- a/generated/stripe_shared/src/issuing_dispute_merchandise_not_as_described_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_merchandise_not_as_described_evidence.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeMerchandiseNotAsDescribedEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -13,6 +15,119 @@ pub struct IssuingDisputeMerchandiseNotAsDescribedEvidence { /// Date when the product was returned or attempted to be returned. pub returned_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder { + additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + explanation: Option<Option<String>>, + received_at: Option<Option<stripe_types::Timestamp>>, + return_description: Option<Option<String>>, + return_status: Option<Option<IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus>>, + returned_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeMerchandiseNotAsDescribedEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeMerchandiseNotAsDescribedEvidence>, + builder: IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeMerchandiseNotAsDescribedEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder { + type Out = IssuingDisputeMerchandiseNotAsDescribedEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_documentation" => Deserialize::begin(&mut self.additional_documentation), + "explanation" => Deserialize::begin(&mut self.explanation), + "received_at" => Deserialize::begin(&mut self.received_at), + "return_description" => Deserialize::begin(&mut self.return_description), + "return_status" => Deserialize::begin(&mut self.return_status), + "returned_at" => Deserialize::begin(&mut self.returned_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + additional_documentation: Deserialize::default(), + explanation: Deserialize::default(), + received_at: Deserialize::default(), + return_description: Deserialize::default(), + return_status: Deserialize::default(), + returned_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_documentation = self.additional_documentation.take()?; + let explanation = self.explanation.take()?; + let received_at = self.received_at.take()?; + let return_description = self.return_description.take()?; + let return_status = self.return_status.take()?; + let returned_at = self.returned_at.take()?; + + Some(Self::Out { additional_documentation, explanation, received_at, return_description, return_status, returned_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeMerchandiseNotAsDescribedEvidence { + type Builder = IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeMerchandiseNotAsDescribedEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_documentation" => b.additional_documentation = Some(FromValueOpt::from_value(v)?), + "explanation" => b.explanation = Some(FromValueOpt::from_value(v)?), + "received_at" => b.received_at = Some(FromValueOpt::from_value(v)?), + "return_description" => b.return_description = Some(FromValueOpt::from_value(v)?), + "return_status" => b.return_status = Some(FromValueOpt::from_value(v)?), + "returned_at" => b.returned_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Result of cardholder's attempt to return the product. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus { @@ -63,10 +178,24 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeMerchandiseNotAsDescribedEvi fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus); diff --git a/generated/stripe_shared/src/issuing_dispute_not_received_evidence.rs b/generated/stripe_shared/src/issuing_dispute_not_received_evidence.rs index 8ba8e1c1f..d6483baba 100644 --- a/generated/stripe_shared/src/issuing_dispute_not_received_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_not_received_evidence.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeNotReceivedEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -11,6 +13,114 @@ pub struct IssuingDisputeNotReceivedEvidence { /// Whether the product was a merchandise or service. pub product_type: Option<IssuingDisputeNotReceivedEvidenceProductType>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeNotReceivedEvidenceBuilder { + additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + expected_at: Option<Option<stripe_types::Timestamp>>, + explanation: Option<Option<String>>, + product_description: Option<Option<String>>, + product_type: Option<Option<IssuingDisputeNotReceivedEvidenceProductType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeNotReceivedEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeNotReceivedEvidence>, + builder: IssuingDisputeNotReceivedEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeNotReceivedEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeNotReceivedEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeNotReceivedEvidenceBuilder { + type Out = IssuingDisputeNotReceivedEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_documentation" => Deserialize::begin(&mut self.additional_documentation), + "expected_at" => Deserialize::begin(&mut self.expected_at), + "explanation" => Deserialize::begin(&mut self.explanation), + "product_description" => Deserialize::begin(&mut self.product_description), + "product_type" => Deserialize::begin(&mut self.product_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + additional_documentation: Deserialize::default(), + expected_at: Deserialize::default(), + explanation: Deserialize::default(), + product_description: Deserialize::default(), + product_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_documentation = self.additional_documentation.take()?; + let expected_at = self.expected_at.take()?; + let explanation = self.explanation.take()?; + let product_description = self.product_description.take()?; + let product_type = self.product_type.take()?; + + Some(Self::Out { additional_documentation, expected_at, explanation, product_description, product_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeNotReceivedEvidence { + type Builder = IssuingDisputeNotReceivedEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeNotReceivedEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeNotReceivedEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_documentation" => b.additional_documentation = Some(FromValueOpt::from_value(v)?), + "expected_at" => b.expected_at = Some(FromValueOpt::from_value(v)?), + "explanation" => b.explanation = Some(FromValueOpt::from_value(v)?), + "product_description" => b.product_description = Some(FromValueOpt::from_value(v)?), + "product_type" => b.product_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether the product was a merchandise or service. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingDisputeNotReceivedEvidenceProductType { @@ -61,10 +171,24 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeNotReceivedEvidenceProductTy fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingDisputeNotReceivedEvidenceProductType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeNotReceivedEvidenceProductType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingDisputeNotReceivedEvidenceProductType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingDisputeNotReceivedEvidenceProductType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeNotReceivedEvidenceProductType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingDisputeNotReceivedEvidenceProductType); diff --git a/generated/stripe_shared/src/issuing_dispute_other_evidence.rs b/generated/stripe_shared/src/issuing_dispute_other_evidence.rs index 471711d49..4d16dc74d 100644 --- a/generated/stripe_shared/src/issuing_dispute_other_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_other_evidence.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeOtherEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -9,6 +11,104 @@ pub struct IssuingDisputeOtherEvidence { /// Whether the product was a merchandise or service. pub product_type: Option<IssuingDisputeOtherEvidenceProductType>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeOtherEvidenceBuilder { + additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + explanation: Option<Option<String>>, + product_description: Option<Option<String>>, + product_type: Option<Option<IssuingDisputeOtherEvidenceProductType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeOtherEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeOtherEvidence>, + builder: IssuingDisputeOtherEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeOtherEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeOtherEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeOtherEvidenceBuilder { + type Out = IssuingDisputeOtherEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_documentation" => Deserialize::begin(&mut self.additional_documentation), + "explanation" => Deserialize::begin(&mut self.explanation), + "product_description" => Deserialize::begin(&mut self.product_description), + "product_type" => Deserialize::begin(&mut self.product_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { additional_documentation: Deserialize::default(), explanation: Deserialize::default(), product_description: Deserialize::default(), product_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_documentation = self.additional_documentation.take()?; + let explanation = self.explanation.take()?; + let product_description = self.product_description.take()?; + let product_type = self.product_type.take()?; + + Some(Self::Out { additional_documentation, explanation, product_description, product_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeOtherEvidence { + type Builder = IssuingDisputeOtherEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeOtherEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeOtherEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_documentation" => b.additional_documentation = Some(FromValueOpt::from_value(v)?), + "explanation" => b.explanation = Some(FromValueOpt::from_value(v)?), + "product_description" => b.product_description = Some(FromValueOpt::from_value(v)?), + "product_type" => b.product_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether the product was a merchandise or service. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingDisputeOtherEvidenceProductType { @@ -59,8 +159,24 @@ impl<'de> serde::Deserialize<'de> for IssuingDisputeOtherEvidenceProductType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingDisputeOtherEvidenceProductType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingDisputeOtherEvidenceProductType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingDisputeOtherEvidenceProductType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingDisputeOtherEvidenceProductType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeOtherEvidenceProductType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingDisputeOtherEvidenceProductType); diff --git a/generated/stripe_shared/src/issuing_dispute_service_not_as_described_evidence.rs b/generated/stripe_shared/src/issuing_dispute_service_not_as_described_evidence.rs index 1ce6c4f88..bc5c0dfc9 100644 --- a/generated/stripe_shared/src/issuing_dispute_service_not_as_described_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_service_not_as_described_evidence.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeServiceNotAsDescribedEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -11,3 +13,111 @@ pub struct IssuingDisputeServiceNotAsDescribedEvidence { /// Date when the product was received. pub received_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeServiceNotAsDescribedEvidenceBuilder { + additional_documentation: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + canceled_at: Option<Option<stripe_types::Timestamp>>, + cancellation_reason: Option<Option<String>>, + explanation: Option<Option<String>>, + received_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeServiceNotAsDescribedEvidence { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeServiceNotAsDescribedEvidence>, + builder: IssuingDisputeServiceNotAsDescribedEvidenceBuilder, + } + + impl Visitor for Place<IssuingDisputeServiceNotAsDescribedEvidence> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeServiceNotAsDescribedEvidenceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeServiceNotAsDescribedEvidenceBuilder { + type Out = IssuingDisputeServiceNotAsDescribedEvidence; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_documentation" => Deserialize::begin(&mut self.additional_documentation), + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason), + "explanation" => Deserialize::begin(&mut self.explanation), + "received_at" => Deserialize::begin(&mut self.received_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + additional_documentation: Deserialize::default(), + canceled_at: Deserialize::default(), + cancellation_reason: Deserialize::default(), + explanation: Deserialize::default(), + received_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_documentation = self.additional_documentation.take()?; + let canceled_at = self.canceled_at.take()?; + let cancellation_reason = self.cancellation_reason.take()?; + let explanation = self.explanation.take()?; + let received_at = self.received_at.take()?; + + Some(Self::Out { additional_documentation, canceled_at, cancellation_reason, explanation, received_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeServiceNotAsDescribedEvidence { + type Builder = IssuingDisputeServiceNotAsDescribedEvidenceBuilder; + } + + impl FromValueOpt for IssuingDisputeServiceNotAsDescribedEvidence { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeServiceNotAsDescribedEvidenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_documentation" => b.additional_documentation = Some(FromValueOpt::from_value(v)?), + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "cancellation_reason" => b.cancellation_reason = Some(FromValueOpt::from_value(v)?), + "explanation" => b.explanation = Some(FromValueOpt::from_value(v)?), + "received_at" => b.received_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_dispute_treasury.rs b/generated/stripe_shared/src/issuing_dispute_treasury.rs index dcdb0485d..55315a97e 100644 --- a/generated/stripe_shared/src/issuing_dispute_treasury.rs +++ b/generated/stripe_shared/src/issuing_dispute_treasury.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingDisputeTreasury { /// The Treasury [DebitReversal](https://stripe.com/docs/api/treasury/debit_reversals) representing this Issuing dispute. pub debit_reversal: Option<String>, /// The Treasury [ReceivedDebit](https://stripe.com/docs/api/treasury/received_debits) that is being disputed. pub received_debit: String, } +#[cfg(feature = "min-ser")] +pub struct IssuingDisputeTreasuryBuilder { + debit_reversal: Option<Option<String>>, + received_debit: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingDisputeTreasury { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingDisputeTreasury>, + builder: IssuingDisputeTreasuryBuilder, + } + + impl Visitor for Place<IssuingDisputeTreasury> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingDisputeTreasuryBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingDisputeTreasuryBuilder { + type Out = IssuingDisputeTreasury; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "debit_reversal" => Deserialize::begin(&mut self.debit_reversal), + "received_debit" => Deserialize::begin(&mut self.received_debit), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { debit_reversal: Deserialize::default(), received_debit: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let debit_reversal = self.debit_reversal.take()?; + let received_debit = self.received_debit.take()?; + + Some(Self::Out { debit_reversal, received_debit }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingDisputeTreasury { + type Builder = IssuingDisputeTreasuryBuilder; + } + + impl FromValueOpt for IssuingDisputeTreasury { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingDisputeTreasuryBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "debit_reversal" => b.debit_reversal = Some(FromValueOpt::from_value(v)?), + "received_debit" => b.received_debit = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_network_token_address.rs b/generated/stripe_shared/src/issuing_network_token_address.rs index 942291828..d3209127d 100644 --- a/generated/stripe_shared/src/issuing_network_token_address.rs +++ b/generated/stripe_shared/src/issuing_network_token_address.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingNetworkTokenAddress { /// The street address of the cardholder tokenizing the card. pub line1: String, /// The postal code of the cardholder tokenizing the card. pub postal_code: String, } +#[cfg(feature = "min-ser")] +pub struct IssuingNetworkTokenAddressBuilder { + line1: Option<String>, + postal_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingNetworkTokenAddress { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingNetworkTokenAddress>, + builder: IssuingNetworkTokenAddressBuilder, + } + + impl Visitor for Place<IssuingNetworkTokenAddress> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingNetworkTokenAddressBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingNetworkTokenAddressBuilder { + type Out = IssuingNetworkTokenAddress; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "line1" => Deserialize::begin(&mut self.line1), + "postal_code" => Deserialize::begin(&mut self.postal_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { line1: Deserialize::default(), postal_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let line1 = self.line1.take()?; + let postal_code = self.postal_code.take()?; + + Some(Self::Out { line1, postal_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingNetworkTokenAddress { + type Builder = IssuingNetworkTokenAddressBuilder; + } + + impl FromValueOpt for IssuingNetworkTokenAddress { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingNetworkTokenAddressBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "line1" => b.line1 = Some(FromValueOpt::from_value(v)?), + "postal_code" => b.postal_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_network_token_device.rs b/generated/stripe_shared/src/issuing_network_token_device.rs index b241db65d..0c1dad6a2 100644 --- a/generated/stripe_shared/src/issuing_network_token_device.rs +++ b/generated/stripe_shared/src/issuing_network_token_device.rs @@ -1,26 +1,135 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingNetworkTokenDevice { /// An obfuscated ID derived from the device ID. - #[serde(skip_serializing_if = "Option::is_none")] pub device_fingerprint: Option<String>, /// The IP address of the device at provisioning time. - #[serde(skip_serializing_if = "Option::is_none")] pub ip_address: Option<String>, /// The geographic latitude/longitude coordinates of the device at provisioning time. /// The format is [+-]decimal/[+-]decimal. - #[serde(skip_serializing_if = "Option::is_none")] pub location: Option<String>, /// The name of the device used for tokenization. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, /// The phone number of the device used for tokenization. - #[serde(skip_serializing_if = "Option::is_none")] pub phone_number: Option<String>, /// The type of device used for tokenization. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<IssuingNetworkTokenDeviceType>, } +#[cfg(feature = "min-ser")] +pub struct IssuingNetworkTokenDeviceBuilder { + device_fingerprint: Option<Option<String>>, + ip_address: Option<Option<String>>, + location: Option<Option<String>>, + name: Option<Option<String>>, + phone_number: Option<Option<String>>, + type_: Option<Option<IssuingNetworkTokenDeviceType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingNetworkTokenDevice { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingNetworkTokenDevice>, + builder: IssuingNetworkTokenDeviceBuilder, + } + + impl Visitor for Place<IssuingNetworkTokenDevice> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingNetworkTokenDeviceBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingNetworkTokenDeviceBuilder { + type Out = IssuingNetworkTokenDevice; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "device_fingerprint" => Deserialize::begin(&mut self.device_fingerprint), + "ip_address" => Deserialize::begin(&mut self.ip_address), + "location" => Deserialize::begin(&mut self.location), + "name" => Deserialize::begin(&mut self.name), + "phone_number" => Deserialize::begin(&mut self.phone_number), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + device_fingerprint: Deserialize::default(), + ip_address: Deserialize::default(), + location: Deserialize::default(), + name: Deserialize::default(), + phone_number: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let device_fingerprint = self.device_fingerprint.take()?; + let ip_address = self.ip_address.take()?; + let location = self.location.take()?; + let name = self.name.take()?; + let phone_number = self.phone_number.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { device_fingerprint, ip_address, location, name, phone_number, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingNetworkTokenDevice { + type Builder = IssuingNetworkTokenDeviceBuilder; + } + + impl FromValueOpt for IssuingNetworkTokenDevice { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingNetworkTokenDeviceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "device_fingerprint" => b.device_fingerprint = Some(FromValueOpt::from_value(v)?), + "ip_address" => b.ip_address = Some(FromValueOpt::from_value(v)?), + "location" => b.location = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "phone_number" => b.phone_number = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of device used for tokenization. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingNetworkTokenDeviceType { @@ -74,8 +183,24 @@ impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenDeviceType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingNetworkTokenDeviceType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingNetworkTokenDeviceType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingNetworkTokenDeviceType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingNetworkTokenDeviceType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingNetworkTokenDeviceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenDeviceType); diff --git a/generated/stripe_shared/src/issuing_network_token_mastercard.rs b/generated/stripe_shared/src/issuing_network_token_mastercard.rs index a76c0a20c..3e9c29488 100644 --- a/generated/stripe_shared/src/issuing_network_token_mastercard.rs +++ b/generated/stripe_shared/src/issuing_network_token_mastercard.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingNetworkTokenMastercard { /// A unique reference ID from MasterCard to represent the card account number. - #[serde(skip_serializing_if = "Option::is_none")] pub card_reference_id: Option<String>, /// The network-unique identifier for the token. pub token_reference_id: String, @@ -9,6 +10,103 @@ pub struct IssuingNetworkTokenMastercard { pub token_requestor_id: String, /// The name of the entity requesting tokenization, if known. /// This is directly provided from MasterCard. - #[serde(skip_serializing_if = "Option::is_none")] pub token_requestor_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingNetworkTokenMastercardBuilder { + card_reference_id: Option<Option<String>>, + token_reference_id: Option<String>, + token_requestor_id: Option<String>, + token_requestor_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingNetworkTokenMastercard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingNetworkTokenMastercard>, + builder: IssuingNetworkTokenMastercardBuilder, + } + + impl Visitor for Place<IssuingNetworkTokenMastercard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingNetworkTokenMastercardBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingNetworkTokenMastercardBuilder { + type Out = IssuingNetworkTokenMastercard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "card_reference_id" => Deserialize::begin(&mut self.card_reference_id), + "token_reference_id" => Deserialize::begin(&mut self.token_reference_id), + "token_requestor_id" => Deserialize::begin(&mut self.token_requestor_id), + "token_requestor_name" => Deserialize::begin(&mut self.token_requestor_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { card_reference_id: Deserialize::default(), token_reference_id: Deserialize::default(), token_requestor_id: Deserialize::default(), token_requestor_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let card_reference_id = self.card_reference_id.take()?; + let token_reference_id = self.token_reference_id.take()?; + let token_requestor_id = self.token_requestor_id.take()?; + let token_requestor_name = self.token_requestor_name.take()?; + + Some(Self::Out { card_reference_id, token_reference_id, token_requestor_id, token_requestor_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingNetworkTokenMastercard { + type Builder = IssuingNetworkTokenMastercardBuilder; + } + + impl FromValueOpt for IssuingNetworkTokenMastercard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingNetworkTokenMastercardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "card_reference_id" => b.card_reference_id = Some(FromValueOpt::from_value(v)?), + "token_reference_id" => b.token_reference_id = Some(FromValueOpt::from_value(v)?), + "token_requestor_id" => b.token_requestor_id = Some(FromValueOpt::from_value(v)?), + "token_requestor_name" => b.token_requestor_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_network_token_network_data.rs b/generated/stripe_shared/src/issuing_network_token_network_data.rs index acab32015..efd622b87 100644 --- a/generated/stripe_shared/src/issuing_network_token_network_data.rs +++ b/generated/stripe_shared/src/issuing_network_token_network_data.rs @@ -1,18 +1,118 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingNetworkTokenNetworkData { - #[serde(skip_serializing_if = "Option::is_none")] pub device: Option<stripe_shared::IssuingNetworkTokenDevice>, - #[serde(skip_serializing_if = "Option::is_none")] pub mastercard: Option<stripe_shared::IssuingNetworkTokenMastercard>, /// The network that the token is associated with. /// An additional hash is included with a name matching this value, containing tokenization data specific to the card network. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: IssuingNetworkTokenNetworkDataType, - #[serde(skip_serializing_if = "Option::is_none")] pub visa: Option<stripe_shared::IssuingNetworkTokenVisa>, - #[serde(skip_serializing_if = "Option::is_none")] pub wallet_provider: Option<stripe_shared::IssuingNetworkTokenWalletProvider>, } +#[cfg(feature = "min-ser")] +pub struct IssuingNetworkTokenNetworkDataBuilder { + device: Option<Option<stripe_shared::IssuingNetworkTokenDevice>>, + mastercard: Option<Option<stripe_shared::IssuingNetworkTokenMastercard>>, + type_: Option<IssuingNetworkTokenNetworkDataType>, + visa: Option<Option<stripe_shared::IssuingNetworkTokenVisa>>, + wallet_provider: Option<Option<stripe_shared::IssuingNetworkTokenWalletProvider>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingNetworkTokenNetworkData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingNetworkTokenNetworkData>, + builder: IssuingNetworkTokenNetworkDataBuilder, + } + + impl Visitor for Place<IssuingNetworkTokenNetworkData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingNetworkTokenNetworkDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingNetworkTokenNetworkDataBuilder { + type Out = IssuingNetworkTokenNetworkData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "device" => Deserialize::begin(&mut self.device), + "mastercard" => Deserialize::begin(&mut self.mastercard), + "type" => Deserialize::begin(&mut self.type_), + "visa" => Deserialize::begin(&mut self.visa), + "wallet_provider" => Deserialize::begin(&mut self.wallet_provider), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { device: Deserialize::default(), mastercard: Deserialize::default(), type_: Deserialize::default(), visa: Deserialize::default(), wallet_provider: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let device = self.device.take()?; + let mastercard = self.mastercard.take()?; + let type_ = self.type_.take()?; + let visa = self.visa.take()?; + let wallet_provider = self.wallet_provider.take()?; + + Some(Self::Out { device, mastercard, type_, visa, wallet_provider }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingNetworkTokenNetworkData { + type Builder = IssuingNetworkTokenNetworkDataBuilder; + } + + impl FromValueOpt for IssuingNetworkTokenNetworkData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingNetworkTokenNetworkDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "device" => b.device = Some(FromValueOpt::from_value(v)?), + "mastercard" => b.mastercard = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "visa" => b.visa = Some(FromValueOpt::from_value(v)?), + "wallet_provider" => b.wallet_provider = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The network that the token is associated with. /// An additional hash is included with a name matching this value, containing tokenization data specific to the card network. #[derive(Copy, Clone, Eq, PartialEq)] @@ -64,8 +164,24 @@ impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenNetworkDataType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for IssuingNetworkTokenNetworkDataType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingNetworkTokenNetworkDataType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingNetworkTokenNetworkDataType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingNetworkTokenNetworkDataType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingNetworkTokenNetworkDataType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenNetworkDataType); diff --git a/generated/stripe_shared/src/issuing_network_token_visa.rs b/generated/stripe_shared/src/issuing_network_token_visa.rs index a88180197..845fde9df 100644 --- a/generated/stripe_shared/src/issuing_network_token_visa.rs +++ b/generated/stripe_shared/src/issuing_network_token_visa.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingNetworkTokenVisa { /// A unique reference ID from Visa to represent the card account number. pub card_reference_id: String, @@ -8,6 +10,103 @@ pub struct IssuingNetworkTokenVisa { pub token_requestor_id: String, /// Degree of risk associated with the token between `01` and `99`, with higher number indicating higher risk. /// A `00` value indicates the token was not scored by Visa. - #[serde(skip_serializing_if = "Option::is_none")] pub token_risk_score: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingNetworkTokenVisaBuilder { + card_reference_id: Option<String>, + token_reference_id: Option<String>, + token_requestor_id: Option<String>, + token_risk_score: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingNetworkTokenVisa { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingNetworkTokenVisa>, + builder: IssuingNetworkTokenVisaBuilder, + } + + impl Visitor for Place<IssuingNetworkTokenVisa> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingNetworkTokenVisaBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingNetworkTokenVisaBuilder { + type Out = IssuingNetworkTokenVisa; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "card_reference_id" => Deserialize::begin(&mut self.card_reference_id), + "token_reference_id" => Deserialize::begin(&mut self.token_reference_id), + "token_requestor_id" => Deserialize::begin(&mut self.token_requestor_id), + "token_risk_score" => Deserialize::begin(&mut self.token_risk_score), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { card_reference_id: Deserialize::default(), token_reference_id: Deserialize::default(), token_requestor_id: Deserialize::default(), token_risk_score: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let card_reference_id = self.card_reference_id.take()?; + let token_reference_id = self.token_reference_id.take()?; + let token_requestor_id = self.token_requestor_id.take()?; + let token_risk_score = self.token_risk_score.take()?; + + Some(Self::Out { card_reference_id, token_reference_id, token_requestor_id, token_risk_score }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingNetworkTokenVisa { + type Builder = IssuingNetworkTokenVisaBuilder; + } + + impl FromValueOpt for IssuingNetworkTokenVisa { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingNetworkTokenVisaBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "card_reference_id" => b.card_reference_id = Some(FromValueOpt::from_value(v)?), + "token_reference_id" => b.token_reference_id = Some(FromValueOpt::from_value(v)?), + "token_requestor_id" => b.token_requestor_id = Some(FromValueOpt::from_value(v)?), + "token_risk_score" => b.token_risk_score = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_network_token_wallet_provider.rs b/generated/stripe_shared/src/issuing_network_token_wallet_provider.rs index 567fe061a..aa0b5ea2e 100644 --- a/generated/stripe_shared/src/issuing_network_token_wallet_provider.rs +++ b/generated/stripe_shared/src/issuing_network_token_wallet_provider.rs @@ -1,36 +1,172 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingNetworkTokenWalletProvider { /// The wallet provider-given account ID of the digital wallet the token belongs to. - #[serde(skip_serializing_if = "Option::is_none")] pub account_id: Option<String>, /// An evaluation on the trustworthiness of the wallet account between 1 and 5. /// A higher score indicates more trustworthy. - #[serde(skip_serializing_if = "Option::is_none")] pub account_trust_score: Option<i64>, /// The method used for tokenizing a card. - #[serde(skip_serializing_if = "Option::is_none")] pub card_number_source: Option<IssuingNetworkTokenWalletProviderCardNumberSource>, - #[serde(skip_serializing_if = "Option::is_none")] pub cardholder_address: Option<stripe_shared::IssuingNetworkTokenAddress>, /// The name of the cardholder tokenizing the card. - #[serde(skip_serializing_if = "Option::is_none")] pub cardholder_name: Option<String>, /// An evaluation on the trustworthiness of the device. A higher score indicates more trustworthy. - #[serde(skip_serializing_if = "Option::is_none")] pub device_trust_score: Option<i64>, /// The hashed email address of the cardholder's account with the wallet provider. - #[serde(skip_serializing_if = "Option::is_none")] pub hashed_account_email_address: Option<String>, /// The reasons for suggested tokenization given by the card network. - #[serde(skip_serializing_if = "Option::is_none")] pub reason_codes: Option<Vec<IssuingNetworkTokenWalletProviderReasonCodes>>, /// The recommendation on responding to the tokenization request. - #[serde(skip_serializing_if = "Option::is_none")] pub suggested_decision: Option<IssuingNetworkTokenWalletProviderSuggestedDecision>, /// The version of the standard for mapping reason codes followed by the wallet provider. - #[serde(skip_serializing_if = "Option::is_none")] pub suggested_decision_version: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingNetworkTokenWalletProviderBuilder { + account_id: Option<Option<String>>, + account_trust_score: Option<Option<i64>>, + card_number_source: Option<Option<IssuingNetworkTokenWalletProviderCardNumberSource>>, + cardholder_address: Option<Option<stripe_shared::IssuingNetworkTokenAddress>>, + cardholder_name: Option<Option<String>>, + device_trust_score: Option<Option<i64>>, + hashed_account_email_address: Option<Option<String>>, + reason_codes: Option<Option<Vec<IssuingNetworkTokenWalletProviderReasonCodes>>>, + suggested_decision: Option<Option<IssuingNetworkTokenWalletProviderSuggestedDecision>>, + suggested_decision_version: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingNetworkTokenWalletProvider { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingNetworkTokenWalletProvider>, + builder: IssuingNetworkTokenWalletProviderBuilder, + } + + impl Visitor for Place<IssuingNetworkTokenWalletProvider> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingNetworkTokenWalletProviderBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingNetworkTokenWalletProviderBuilder { + type Out = IssuingNetworkTokenWalletProvider; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_id" => Deserialize::begin(&mut self.account_id), + "account_trust_score" => Deserialize::begin(&mut self.account_trust_score), + "card_number_source" => Deserialize::begin(&mut self.card_number_source), + "cardholder_address" => Deserialize::begin(&mut self.cardholder_address), + "cardholder_name" => Deserialize::begin(&mut self.cardholder_name), + "device_trust_score" => Deserialize::begin(&mut self.device_trust_score), + "hashed_account_email_address" => Deserialize::begin(&mut self.hashed_account_email_address), + "reason_codes" => Deserialize::begin(&mut self.reason_codes), + "suggested_decision" => Deserialize::begin(&mut self.suggested_decision), + "suggested_decision_version" => Deserialize::begin(&mut self.suggested_decision_version), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_id: Deserialize::default(), + account_trust_score: Deserialize::default(), + card_number_source: Deserialize::default(), + cardholder_address: Deserialize::default(), + cardholder_name: Deserialize::default(), + device_trust_score: Deserialize::default(), + hashed_account_email_address: Deserialize::default(), + reason_codes: Deserialize::default(), + suggested_decision: Deserialize::default(), + suggested_decision_version: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_id = self.account_id.take()?; + let account_trust_score = self.account_trust_score.take()?; + let card_number_source = self.card_number_source.take()?; + let cardholder_address = self.cardholder_address.take()?; + let cardholder_name = self.cardholder_name.take()?; + let device_trust_score = self.device_trust_score.take()?; + let hashed_account_email_address = self.hashed_account_email_address.take()?; + let reason_codes = self.reason_codes.take()?; + let suggested_decision = self.suggested_decision.take()?; + let suggested_decision_version = self.suggested_decision_version.take()?; + + Some(Self::Out { + account_id, + account_trust_score, + card_number_source, + cardholder_address, + cardholder_name, + device_trust_score, + hashed_account_email_address, + reason_codes, + suggested_decision, + suggested_decision_version, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingNetworkTokenWalletProvider { + type Builder = IssuingNetworkTokenWalletProviderBuilder; + } + + impl FromValueOpt for IssuingNetworkTokenWalletProvider { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingNetworkTokenWalletProviderBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_id" => b.account_id = Some(FromValueOpt::from_value(v)?), + "account_trust_score" => b.account_trust_score = Some(FromValueOpt::from_value(v)?), + "card_number_source" => b.card_number_source = Some(FromValueOpt::from_value(v)?), + "cardholder_address" => b.cardholder_address = Some(FromValueOpt::from_value(v)?), + "cardholder_name" => b.cardholder_name = Some(FromValueOpt::from_value(v)?), + "device_trust_score" => b.device_trust_score = Some(FromValueOpt::from_value(v)?), + "hashed_account_email_address" => b.hashed_account_email_address = Some(FromValueOpt::from_value(v)?), + "reason_codes" => b.reason_codes = Some(FromValueOpt::from_value(v)?), + "suggested_decision" => b.suggested_decision = Some(FromValueOpt::from_value(v)?), + "suggested_decision_version" => b.suggested_decision_version = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The method used for tokenizing a card. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingNetworkTokenWalletProviderCardNumberSource { @@ -87,13 +223,27 @@ impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenWalletProviderCardNumbe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingNetworkTokenWalletProviderCardNumberSource", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingNetworkTokenWalletProviderCardNumberSource")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingNetworkTokenWalletProviderCardNumberSource { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingNetworkTokenWalletProviderCardNumberSource> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingNetworkTokenWalletProviderCardNumberSource::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenWalletProviderCardNumberSource); /// The reasons for suggested tokenization given by the card network. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -152,14 +302,10 @@ impl IssuingNetworkTokenWalletProviderReasonCodes { NetworkServiceError => "network_service_error", OutsideHomeTerritory => "outside_home_territory", ProvisioningCardholderMismatch => "provisioning_cardholder_mismatch", - ProvisioningDeviceAndCardholderMismatch => { - "provisioning_device_and_cardholder_mismatch" - } + ProvisioningDeviceAndCardholderMismatch => "provisioning_device_and_cardholder_mismatch", ProvisioningDeviceMismatch => "provisioning_device_mismatch", SameDeviceNoPriorAuthentication => "same_device_no_prior_authentication", - SameDeviceSuccessfulPriorAuthentication => { - "same_device_successful_prior_authentication" - } + SameDeviceSuccessfulPriorAuthentication => "same_device_successful_prior_authentication", SoftwareUpdate => "software_update", SuspiciousActivity => "suspicious_activity", TooManyDifferentCardholders => "too_many_different_cardholders", @@ -194,14 +340,10 @@ impl std::str::FromStr for IssuingNetworkTokenWalletProviderReasonCodes { "network_service_error" => Ok(NetworkServiceError), "outside_home_territory" => Ok(OutsideHomeTerritory), "provisioning_cardholder_mismatch" => Ok(ProvisioningCardholderMismatch), - "provisioning_device_and_cardholder_mismatch" => { - Ok(ProvisioningDeviceAndCardholderMismatch) - } + "provisioning_device_and_cardholder_mismatch" => Ok(ProvisioningDeviceAndCardholderMismatch), "provisioning_device_mismatch" => Ok(ProvisioningDeviceMismatch), "same_device_no_prior_authentication" => Ok(SameDeviceNoPriorAuthentication), - "same_device_successful_prior_authentication" => { - Ok(SameDeviceSuccessfulPriorAuthentication) - } + "same_device_successful_prior_authentication" => Ok(SameDeviceSuccessfulPriorAuthentication), "software_update" => Ok(SoftwareUpdate), "suspicious_activity" => Ok(SuspiciousActivity), "too_many_different_cardholders" => Ok(TooManyDifferentCardholders), @@ -234,9 +376,27 @@ impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenWalletProviderReasonCod fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(IssuingNetworkTokenWalletProviderReasonCodes::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingNetworkTokenWalletProviderReasonCodes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingNetworkTokenWalletProviderReasonCodes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingNetworkTokenWalletProviderReasonCodes::from_str(s).unwrap_or(IssuingNetworkTokenWalletProviderReasonCodes::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenWalletProviderReasonCodes); /// The recommendation on responding to the tokenization request. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingNetworkTokenWalletProviderSuggestedDecision { @@ -290,10 +450,24 @@ impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenWalletProviderSuggested fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for IssuingNetworkTokenWalletProviderSuggestedDecision", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingNetworkTokenWalletProviderSuggestedDecision")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingNetworkTokenWalletProviderSuggestedDecision { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingNetworkTokenWalletProviderSuggestedDecision> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingNetworkTokenWalletProviderSuggestedDecision::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenWalletProviderSuggestedDecision); diff --git a/generated/stripe_shared/src/issuing_token.rs b/generated/stripe_shared/src/issuing_token.rs index 2867187c1..a88600e9e 100644 --- a/generated/stripe_shared/src/issuing_token.rs +++ b/generated/stripe_shared/src/issuing_token.rs @@ -2,7 +2,9 @@ /// As a [card issuer](https://stripe.com/docs/issuing), you can [view and manage these tokens](https://stripe.com/docs/issuing/controls/token-management) through Stripe. /// /// For more details see <<https://stripe.com/docs/api/issuing/tokens/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingToken { /// Card associated with this token. pub card: stripe_types::Expandable<stripe_shared::IssuingCard>, @@ -13,13 +15,11 @@ pub struct IssuingToken { /// Unique identifier for the object. pub id: stripe_shared::IssuingTokenId, /// The last four digits of the token. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// The token service provider / card network associated with the token. pub network: IssuingTokenNetwork, - #[serde(skip_serializing_if = "Option::is_none")] pub network_data: Option<stripe_shared::IssuingNetworkTokenNetworkData>, /// Time at which the token was last updated by the card network. /// Measured in seconds since the Unix epoch. @@ -27,9 +27,146 @@ pub struct IssuingToken { /// The usage state of the token. pub status: stripe_shared::IssuingTokenStatus, /// The digital wallet for this token, if one was used. - #[serde(skip_serializing_if = "Option::is_none")] pub wallet_provider: Option<IssuingTokenWalletProvider>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTokenBuilder { + card: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>, + created: Option<stripe_types::Timestamp>, + device_fingerprint: Option<Option<String>>, + id: Option<stripe_shared::IssuingTokenId>, + last4: Option<Option<String>>, + livemode: Option<bool>, + network: Option<IssuingTokenNetwork>, + network_data: Option<Option<stripe_shared::IssuingNetworkTokenNetworkData>>, + network_updated_at: Option<stripe_types::Timestamp>, + status: Option<stripe_shared::IssuingTokenStatus>, + wallet_provider: Option<Option<IssuingTokenWalletProvider>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingToken { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingToken>, + builder: IssuingTokenBuilder, + } + + impl Visitor for Place<IssuingToken> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTokenBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTokenBuilder { + type Out = IssuingToken; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "card" => Deserialize::begin(&mut self.card), + "created" => Deserialize::begin(&mut self.created), + "device_fingerprint" => Deserialize::begin(&mut self.device_fingerprint), + "id" => Deserialize::begin(&mut self.id), + "last4" => Deserialize::begin(&mut self.last4), + "livemode" => Deserialize::begin(&mut self.livemode), + "network" => Deserialize::begin(&mut self.network), + "network_data" => Deserialize::begin(&mut self.network_data), + "network_updated_at" => Deserialize::begin(&mut self.network_updated_at), + "status" => Deserialize::begin(&mut self.status), + "wallet_provider" => Deserialize::begin(&mut self.wallet_provider), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + card: Deserialize::default(), + created: Deserialize::default(), + device_fingerprint: Deserialize::default(), + id: Deserialize::default(), + last4: Deserialize::default(), + livemode: Deserialize::default(), + network: Deserialize::default(), + network_data: Deserialize::default(), + network_updated_at: Deserialize::default(), + status: Deserialize::default(), + wallet_provider: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let card = self.card.take()?; + let created = self.created.take()?; + let device_fingerprint = self.device_fingerprint.take()?; + let id = self.id.take()?; + let last4 = self.last4.take()?; + let livemode = self.livemode.take()?; + let network = self.network.take()?; + let network_data = self.network_data.take()?; + let network_updated_at = self.network_updated_at.take()?; + let status = self.status.take()?; + let wallet_provider = self.wallet_provider.take()?; + + Some(Self::Out { card, created, device_fingerprint, id, last4, livemode, network, network_data, network_updated_at, status, wallet_provider }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingToken { + type Builder = IssuingTokenBuilder; + } + + impl FromValueOpt for IssuingToken { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTokenBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "device_fingerprint" => b.device_fingerprint = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "network_data" => b.network_data = Some(FromValueOpt::from_value(v)?), + "network_updated_at" => b.network_updated_at = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "wallet_provider" => b.wallet_provider = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The token service provider / card network associated with the token. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingTokenNetwork { @@ -80,10 +217,27 @@ impl<'de> serde::Deserialize<'de> for IssuingTokenNetwork { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingTokenNetwork")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingTokenNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingTokenNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingTokenNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTokenNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingTokenNetwork); /// The digital wallet for this token, if one was used. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingTokenWalletProvider { @@ -137,10 +291,27 @@ impl<'de> serde::Deserialize<'de> for IssuingTokenWalletProvider { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingTokenWalletProvider")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingTokenWalletProvider")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingTokenWalletProvider { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingTokenWalletProvider> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTokenWalletProvider::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingTokenWalletProvider); impl stripe_types::Object for IssuingToken { type Id = stripe_shared::IssuingTokenId; fn id(&self) -> &Self::Id { @@ -203,7 +374,24 @@ impl<'de> serde::Deserialize<'de> for IssuingTokenStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingTokenStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingTokenStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingTokenStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingTokenStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTokenStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingTokenStatus); diff --git a/generated/stripe_shared/src/issuing_transaction.rs b/generated/stripe_shared/src/issuing_transaction.rs index c7251e7ec..86b511c3f 100644 --- a/generated/stripe_shared/src/issuing_transaction.rs +++ b/generated/stripe_shared/src/issuing_transaction.rs @@ -5,7 +5,9 @@ /// Related guide: [Issued card transactions](https://stripe.com/docs/issuing/purchases/transactions) /// /// For more details see <<https://stripe.com/docs/api/issuing/transactions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransaction { /// The transaction amount, which will be reflected in your balance. /// This amount is in your currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). @@ -47,17 +49,225 @@ pub struct IssuingTransaction { pub purchase_details: Option<stripe_shared::IssuingTransactionPurchaseDetails>, /// [Token](https://stripe.com/docs/api/issuing/tokens/object) object used for this transaction. /// If a network token was not used for this transaction, this field will be null. - #[serde(skip_serializing_if = "Option::is_none")] pub token: Option<stripe_types::Expandable<stripe_shared::IssuingToken>>, /// [Treasury](https://stripe.com/docs/api/treasury) details related to this transaction if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts. - #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option<stripe_shared::IssuingTransactionTreasury>, /// The nature of the transaction. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_shared::IssuingTransactionType, /// The digital wallet used for this transaction. One of `apple_pay`, `google_pay`, or `samsung_pay`. pub wallet: Option<IssuingTransactionWallet>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionBuilder { + amount: Option<i64>, + amount_details: Option<Option<stripe_shared::IssuingTransactionAmountDetails>>, + authorization: Option<Option<stripe_types::Expandable<stripe_shared::IssuingAuthorization>>>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + card: Option<stripe_types::Expandable<stripe_shared::IssuingCard>>, + cardholder: Option<Option<stripe_types::Expandable<stripe_shared::IssuingCardholder>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + dispute: Option<Option<stripe_types::Expandable<stripe_shared::IssuingDispute>>>, + id: Option<stripe_shared::IssuingTransactionId>, + livemode: Option<bool>, + merchant_amount: Option<i64>, + merchant_currency: Option<stripe_types::Currency>, + merchant_data: Option<stripe_shared::IssuingAuthorizationMerchantData>, + metadata: Option<std::collections::HashMap<String, String>>, + network_data: Option<Option<stripe_shared::IssuingTransactionNetworkData>>, + purchase_details: Option<Option<stripe_shared::IssuingTransactionPurchaseDetails>>, + token: Option<Option<stripe_types::Expandable<stripe_shared::IssuingToken>>>, + treasury: Option<Option<stripe_shared::IssuingTransactionTreasury>>, + type_: Option<stripe_shared::IssuingTransactionType>, + wallet: Option<Option<IssuingTransactionWallet>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransaction>, + builder: IssuingTransactionBuilder, + } + + impl Visitor for Place<IssuingTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionBuilder { + type Out = IssuingTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_details" => Deserialize::begin(&mut self.amount_details), + "authorization" => Deserialize::begin(&mut self.authorization), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "card" => Deserialize::begin(&mut self.card), + "cardholder" => Deserialize::begin(&mut self.cardholder), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "dispute" => Deserialize::begin(&mut self.dispute), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "merchant_amount" => Deserialize::begin(&mut self.merchant_amount), + "merchant_currency" => Deserialize::begin(&mut self.merchant_currency), + "merchant_data" => Deserialize::begin(&mut self.merchant_data), + "metadata" => Deserialize::begin(&mut self.metadata), + "network_data" => Deserialize::begin(&mut self.network_data), + "purchase_details" => Deserialize::begin(&mut self.purchase_details), + "token" => Deserialize::begin(&mut self.token), + "treasury" => Deserialize::begin(&mut self.treasury), + "type" => Deserialize::begin(&mut self.type_), + "wallet" => Deserialize::begin(&mut self.wallet), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_details: Deserialize::default(), + authorization: Deserialize::default(), + balance_transaction: Deserialize::default(), + card: Deserialize::default(), + cardholder: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + dispute: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + merchant_amount: Deserialize::default(), + merchant_currency: Deserialize::default(), + merchant_data: Deserialize::default(), + metadata: Deserialize::default(), + network_data: Deserialize::default(), + purchase_details: Deserialize::default(), + token: Deserialize::default(), + treasury: Deserialize::default(), + type_: Deserialize::default(), + wallet: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_details = self.amount_details.take()?; + let authorization = self.authorization.take()?; + let balance_transaction = self.balance_transaction.take()?; + let card = self.card.take()?; + let cardholder = self.cardholder.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let dispute = self.dispute.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let merchant_amount = self.merchant_amount.take()?; + let merchant_currency = self.merchant_currency.take()?; + let merchant_data = self.merchant_data.take()?; + let metadata = self.metadata.take()?; + let network_data = self.network_data.take()?; + let purchase_details = self.purchase_details.take()?; + let token = self.token.take()?; + let treasury = self.treasury.take()?; + let type_ = self.type_.take()?; + let wallet = self.wallet.take()?; + + Some(Self::Out { + amount, + amount_details, + authorization, + balance_transaction, + card, + cardholder, + created, + currency, + dispute, + id, + livemode, + merchant_amount, + merchant_currency, + merchant_data, + metadata, + network_data, + purchase_details, + token, + treasury, + type_, + wallet, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransaction { + type Builder = IssuingTransactionBuilder; + } + + impl FromValueOpt for IssuingTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_details" => b.amount_details = Some(FromValueOpt::from_value(v)?), + "authorization" => b.authorization = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "cardholder" => b.cardholder = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "dispute" => b.dispute = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "merchant_amount" => b.merchant_amount = Some(FromValueOpt::from_value(v)?), + "merchant_currency" => b.merchant_currency = Some(FromValueOpt::from_value(v)?), + "merchant_data" => b.merchant_data = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "network_data" => b.network_data = Some(FromValueOpt::from_value(v)?), + "purchase_details" => b.purchase_details = Some(FromValueOpt::from_value(v)?), + "token" => b.token = Some(FromValueOpt::from_value(v)?), + "treasury" => b.treasury = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "wallet" => b.wallet = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The digital wallet used for this transaction. One of `apple_pay`, `google_pay`, or `samsung_pay`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingTransactionWallet { @@ -111,10 +321,27 @@ impl<'de> serde::Deserialize<'de> for IssuingTransactionWallet { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingTransactionWallet")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingTransactionWallet")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingTransactionWallet { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingTransactionWallet> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTransactionWallet::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingTransactionWallet); impl stripe_types::Object for IssuingTransaction { type Id = stripe_shared::IssuingTransactionId; fn id(&self) -> &Self::Id { @@ -171,7 +398,24 @@ impl<'de> serde::Deserialize<'de> for IssuingTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for IssuingTransactionType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for IssuingTransactionType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for IssuingTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<IssuingTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(IssuingTransactionType); diff --git a/generated/stripe_shared/src/issuing_transaction_amount_details.rs b/generated/stripe_shared/src/issuing_transaction_amount_details.rs index 8c5db148b..bdd01a236 100644 --- a/generated/stripe_shared/src/issuing_transaction_amount_details.rs +++ b/generated/stripe_shared/src/issuing_transaction_amount_details.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionAmountDetails { /// The fee charged by the ATM for the cash withdrawal. pub atm_fee: Option<i64>, /// The amount of cash requested by the cardholder. pub cashback_amount: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionAmountDetailsBuilder { + atm_fee: Option<Option<i64>>, + cashback_amount: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionAmountDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionAmountDetails>, + builder: IssuingTransactionAmountDetailsBuilder, + } + + impl Visitor for Place<IssuingTransactionAmountDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionAmountDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionAmountDetailsBuilder { + type Out = IssuingTransactionAmountDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "atm_fee" => Deserialize::begin(&mut self.atm_fee), + "cashback_amount" => Deserialize::begin(&mut self.cashback_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { atm_fee: Deserialize::default(), cashback_amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let atm_fee = self.atm_fee.take()?; + let cashback_amount = self.cashback_amount.take()?; + + Some(Self::Out { atm_fee, cashback_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionAmountDetails { + type Builder = IssuingTransactionAmountDetailsBuilder; + } + + impl FromValueOpt for IssuingTransactionAmountDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionAmountDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "atm_fee" => b.atm_fee = Some(FromValueOpt::from_value(v)?), + "cashback_amount" => b.cashback_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_flight_data.rs b/generated/stripe_shared/src/issuing_transaction_flight_data.rs index 17c546ad4..2150c2412 100644 --- a/generated/stripe_shared/src/issuing_transaction_flight_data.rs +++ b/generated/stripe_shared/src/issuing_transaction_flight_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionFlightData { /// The time that the flight departed. pub departure_at: Option<i64>, @@ -11,3 +13,111 @@ pub struct IssuingTransactionFlightData { /// The travel agency that issued the ticket. pub travel_agency: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionFlightDataBuilder { + departure_at: Option<Option<i64>>, + passenger_name: Option<Option<String>>, + refundable: Option<Option<bool>>, + segments: Option<Option<Vec<stripe_shared::IssuingTransactionFlightDataLeg>>>, + travel_agency: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionFlightData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionFlightData>, + builder: IssuingTransactionFlightDataBuilder, + } + + impl Visitor for Place<IssuingTransactionFlightData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionFlightDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionFlightDataBuilder { + type Out = IssuingTransactionFlightData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "departure_at" => Deserialize::begin(&mut self.departure_at), + "passenger_name" => Deserialize::begin(&mut self.passenger_name), + "refundable" => Deserialize::begin(&mut self.refundable), + "segments" => Deserialize::begin(&mut self.segments), + "travel_agency" => Deserialize::begin(&mut self.travel_agency), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + departure_at: Deserialize::default(), + passenger_name: Deserialize::default(), + refundable: Deserialize::default(), + segments: Deserialize::default(), + travel_agency: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let departure_at = self.departure_at.take()?; + let passenger_name = self.passenger_name.take()?; + let refundable = self.refundable.take()?; + let segments = self.segments.take()?; + let travel_agency = self.travel_agency.take()?; + + Some(Self::Out { departure_at, passenger_name, refundable, segments, travel_agency }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionFlightData { + type Builder = IssuingTransactionFlightDataBuilder; + } + + impl FromValueOpt for IssuingTransactionFlightData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionFlightDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "departure_at" => b.departure_at = Some(FromValueOpt::from_value(v)?), + "passenger_name" => b.passenger_name = Some(FromValueOpt::from_value(v)?), + "refundable" => b.refundable = Some(FromValueOpt::from_value(v)?), + "segments" => b.segments = Some(FromValueOpt::from_value(v)?), + "travel_agency" => b.travel_agency = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_flight_data_leg.rs b/generated/stripe_shared/src/issuing_transaction_flight_data_leg.rs index 18571a91d..2380b2d61 100644 --- a/generated/stripe_shared/src/issuing_transaction_flight_data_leg.rs +++ b/generated/stripe_shared/src/issuing_transaction_flight_data_leg.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionFlightDataLeg { /// The three-letter IATA airport code of the flight's destination. pub arrival_airport_code: Option<String>, @@ -13,3 +15,116 @@ pub struct IssuingTransactionFlightDataLeg { /// Whether a stopover is allowed on this flight. pub stopover_allowed: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionFlightDataLegBuilder { + arrival_airport_code: Option<Option<String>>, + carrier: Option<Option<String>>, + departure_airport_code: Option<Option<String>>, + flight_number: Option<Option<String>>, + service_class: Option<Option<String>>, + stopover_allowed: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionFlightDataLeg { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionFlightDataLeg>, + builder: IssuingTransactionFlightDataLegBuilder, + } + + impl Visitor for Place<IssuingTransactionFlightDataLeg> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionFlightDataLegBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionFlightDataLegBuilder { + type Out = IssuingTransactionFlightDataLeg; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "arrival_airport_code" => Deserialize::begin(&mut self.arrival_airport_code), + "carrier" => Deserialize::begin(&mut self.carrier), + "departure_airport_code" => Deserialize::begin(&mut self.departure_airport_code), + "flight_number" => Deserialize::begin(&mut self.flight_number), + "service_class" => Deserialize::begin(&mut self.service_class), + "stopover_allowed" => Deserialize::begin(&mut self.stopover_allowed), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + arrival_airport_code: Deserialize::default(), + carrier: Deserialize::default(), + departure_airport_code: Deserialize::default(), + flight_number: Deserialize::default(), + service_class: Deserialize::default(), + stopover_allowed: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let arrival_airport_code = self.arrival_airport_code.take()?; + let carrier = self.carrier.take()?; + let departure_airport_code = self.departure_airport_code.take()?; + let flight_number = self.flight_number.take()?; + let service_class = self.service_class.take()?; + let stopover_allowed = self.stopover_allowed.take()?; + + Some(Self::Out { arrival_airport_code, carrier, departure_airport_code, flight_number, service_class, stopover_allowed }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionFlightDataLeg { + type Builder = IssuingTransactionFlightDataLegBuilder; + } + + impl FromValueOpt for IssuingTransactionFlightDataLeg { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionFlightDataLegBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "arrival_airport_code" => b.arrival_airport_code = Some(FromValueOpt::from_value(v)?), + "carrier" => b.carrier = Some(FromValueOpt::from_value(v)?), + "departure_airport_code" => b.departure_airport_code = Some(FromValueOpt::from_value(v)?), + "flight_number" => b.flight_number = Some(FromValueOpt::from_value(v)?), + "service_class" => b.service_class = Some(FromValueOpt::from_value(v)?), + "stopover_allowed" => b.stopover_allowed = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_fuel_data.rs b/generated/stripe_shared/src/issuing_transaction_fuel_data.rs index cfdece44e..cfdbe8510 100644 --- a/generated/stripe_shared/src/issuing_transaction_fuel_data.rs +++ b/generated/stripe_shared/src/issuing_transaction_fuel_data.rs @@ -1,8 +1,10 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionFuelData { /// The type of fuel that was purchased. /// One of `diesel`, `unleaded_plus`, `unleaded_regular`, `unleaded_super`, or `other`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, /// The units for `volume_decimal`. One of `us_gallon` or `liter`. pub unit: String, @@ -11,3 +13,101 @@ pub struct IssuingTransactionFuelData { /// The volume of the fuel that was pumped, represented as a decimal string with at most 12 decimal places. pub volume_decimal: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionFuelDataBuilder { + type_: Option<String>, + unit: Option<String>, + unit_cost_decimal: Option<String>, + volume_decimal: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionFuelData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionFuelData>, + builder: IssuingTransactionFuelDataBuilder, + } + + impl Visitor for Place<IssuingTransactionFuelData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionFuelDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionFuelDataBuilder { + type Out = IssuingTransactionFuelData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "type" => Deserialize::begin(&mut self.type_), + "unit" => Deserialize::begin(&mut self.unit), + "unit_cost_decimal" => Deserialize::begin(&mut self.unit_cost_decimal), + "volume_decimal" => Deserialize::begin(&mut self.volume_decimal), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), unit: Deserialize::default(), unit_cost_decimal: Deserialize::default(), volume_decimal: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let type_ = self.type_.take()?; + let unit = self.unit.take()?; + let unit_cost_decimal = self.unit_cost_decimal.take()?; + let volume_decimal = self.volume_decimal.take()?; + + Some(Self::Out { type_, unit, unit_cost_decimal, volume_decimal }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionFuelData { + type Builder = IssuingTransactionFuelDataBuilder; + } + + impl FromValueOpt for IssuingTransactionFuelData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionFuelDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "unit" => b.unit = Some(FromValueOpt::from_value(v)?), + "unit_cost_decimal" => b.unit_cost_decimal = Some(FromValueOpt::from_value(v)?), + "volume_decimal" => b.volume_decimal = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_lodging_data.rs b/generated/stripe_shared/src/issuing_transaction_lodging_data.rs index cc69c37f7..984214bb2 100644 --- a/generated/stripe_shared/src/issuing_transaction_lodging_data.rs +++ b/generated/stripe_shared/src/issuing_transaction_lodging_data.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionLodgingData { /// The time of checking into the lodging. pub check_in_at: Option<i64>, /// The number of nights stayed at the lodging. pub nights: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionLodgingDataBuilder { + check_in_at: Option<Option<i64>>, + nights: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionLodgingData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionLodgingData>, + builder: IssuingTransactionLodgingDataBuilder, + } + + impl Visitor for Place<IssuingTransactionLodgingData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionLodgingDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionLodgingDataBuilder { + type Out = IssuingTransactionLodgingData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "check_in_at" => Deserialize::begin(&mut self.check_in_at), + "nights" => Deserialize::begin(&mut self.nights), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { check_in_at: Deserialize::default(), nights: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let check_in_at = self.check_in_at.take()?; + let nights = self.nights.take()?; + + Some(Self::Out { check_in_at, nights }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionLodgingData { + type Builder = IssuingTransactionLodgingDataBuilder; + } + + impl FromValueOpt for IssuingTransactionLodgingData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionLodgingDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "check_in_at" => b.check_in_at = Some(FromValueOpt::from_value(v)?), + "nights" => b.nights = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_network_data.rs b/generated/stripe_shared/src/issuing_transaction_network_data.rs index 4f36934ff..12b9210fe 100644 --- a/generated/stripe_shared/src/issuing_transaction_network_data.rs +++ b/generated/stripe_shared/src/issuing_transaction_network_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionNetworkData { /// A code created by Stripe which is shared with the merchant to validate the authorization. /// This field will be populated if the authorization message was approved. @@ -12,3 +14,97 @@ pub struct IssuingTransactionNetworkData { /// Unique identifier for the authorization assigned by the card network used to match subsequent messages, disputes, and transactions. pub transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionNetworkDataBuilder { + authorization_code: Option<Option<String>>, + processing_date: Option<Option<String>>, + transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionNetworkData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionNetworkData>, + builder: IssuingTransactionNetworkDataBuilder, + } + + impl Visitor for Place<IssuingTransactionNetworkData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionNetworkDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionNetworkDataBuilder { + type Out = IssuingTransactionNetworkData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "authorization_code" => Deserialize::begin(&mut self.authorization_code), + "processing_date" => Deserialize::begin(&mut self.processing_date), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { authorization_code: Deserialize::default(), processing_date: Deserialize::default(), transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let authorization_code = self.authorization_code.take()?; + let processing_date = self.processing_date.take()?; + let transaction_id = self.transaction_id.take()?; + + Some(Self::Out { authorization_code, processing_date, transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionNetworkData { + type Builder = IssuingTransactionNetworkDataBuilder; + } + + impl FromValueOpt for IssuingTransactionNetworkData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionNetworkDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "authorization_code" => b.authorization_code = Some(FromValueOpt::from_value(v)?), + "processing_date" => b.processing_date = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_purchase_details.rs b/generated/stripe_shared/src/issuing_transaction_purchase_details.rs index 354982a88..bb3c6c7ae 100644 --- a/generated/stripe_shared/src/issuing_transaction_purchase_details.rs +++ b/generated/stripe_shared/src/issuing_transaction_purchase_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionPurchaseDetails { /// Information about the flight that was purchased with this transaction. pub flight: Option<stripe_shared::IssuingTransactionFlightData>, @@ -11,3 +13,105 @@ pub struct IssuingTransactionPurchaseDetails { /// A merchant-specific order number. pub reference: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionPurchaseDetailsBuilder { + flight: Option<Option<stripe_shared::IssuingTransactionFlightData>>, + fuel: Option<Option<stripe_shared::IssuingTransactionFuelData>>, + lodging: Option<Option<stripe_shared::IssuingTransactionLodgingData>>, + receipt: Option<Option<Vec<stripe_shared::IssuingTransactionReceiptData>>>, + reference: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionPurchaseDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionPurchaseDetails>, + builder: IssuingTransactionPurchaseDetailsBuilder, + } + + impl Visitor for Place<IssuingTransactionPurchaseDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionPurchaseDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionPurchaseDetailsBuilder { + type Out = IssuingTransactionPurchaseDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "flight" => Deserialize::begin(&mut self.flight), + "fuel" => Deserialize::begin(&mut self.fuel), + "lodging" => Deserialize::begin(&mut self.lodging), + "receipt" => Deserialize::begin(&mut self.receipt), + "reference" => Deserialize::begin(&mut self.reference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { flight: Deserialize::default(), fuel: Deserialize::default(), lodging: Deserialize::default(), receipt: Deserialize::default(), reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let flight = self.flight.take()?; + let fuel = self.fuel.take()?; + let lodging = self.lodging.take()?; + let receipt = self.receipt.take()?; + let reference = self.reference.take()?; + + Some(Self::Out { flight, fuel, lodging, receipt, reference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionPurchaseDetails { + type Builder = IssuingTransactionPurchaseDetailsBuilder; + } + + impl FromValueOpt for IssuingTransactionPurchaseDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionPurchaseDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "flight" => b.flight = Some(FromValueOpt::from_value(v)?), + "fuel" => b.fuel = Some(FromValueOpt::from_value(v)?), + "lodging" => b.lodging = Some(FromValueOpt::from_value(v)?), + "receipt" => b.receipt = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_receipt_data.rs b/generated/stripe_shared/src/issuing_transaction_receipt_data.rs index e16f7d813..d3fe814db 100644 --- a/generated/stripe_shared/src/issuing_transaction_receipt_data.rs +++ b/generated/stripe_shared/src/issuing_transaction_receipt_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionReceiptData { /// The description of the item. The maximum length of this field is 26 characters. pub description: Option<String>, @@ -9,3 +11,101 @@ pub struct IssuingTransactionReceiptData { /// The unit cost of the item in cents. pub unit_cost: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionReceiptDataBuilder { + description: Option<Option<String>>, + quantity: Option<Option<f64>>, + total: Option<Option<i64>>, + unit_cost: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionReceiptData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionReceiptData>, + builder: IssuingTransactionReceiptDataBuilder, + } + + impl Visitor for Place<IssuingTransactionReceiptData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionReceiptDataBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionReceiptDataBuilder { + type Out = IssuingTransactionReceiptData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "description" => Deserialize::begin(&mut self.description), + "quantity" => Deserialize::begin(&mut self.quantity), + "total" => Deserialize::begin(&mut self.total), + "unit_cost" => Deserialize::begin(&mut self.unit_cost), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { description: Deserialize::default(), quantity: Deserialize::default(), total: Deserialize::default(), unit_cost: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let description = self.description.take()?; + let quantity = self.quantity.take()?; + let total = self.total.take()?; + let unit_cost = self.unit_cost.take()?; + + Some(Self::Out { description, quantity, total, unit_cost }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionReceiptData { + type Builder = IssuingTransactionReceiptDataBuilder; + } + + impl FromValueOpt for IssuingTransactionReceiptData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionReceiptDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "total" => b.total = Some(FromValueOpt::from_value(v)?), + "unit_cost" => b.unit_cost = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/issuing_transaction_treasury.rs b/generated/stripe_shared/src/issuing_transaction_treasury.rs index e48dad849..e9faa0eb0 100644 --- a/generated/stripe_shared/src/issuing_transaction_treasury.rs +++ b/generated/stripe_shared/src/issuing_transaction_treasury.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct IssuingTransactionTreasury { /// The Treasury [ReceivedCredit](https://stripe.com/docs/api/treasury/received_credits) representing this Issuing transaction if it is a refund. pub received_credit: Option<String>, /// The Treasury [ReceivedDebit](https://stripe.com/docs/api/treasury/received_debits) representing this Issuing transaction if it is a capture. pub received_debit: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct IssuingTransactionTreasuryBuilder { + received_credit: Option<Option<String>>, + received_debit: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for IssuingTransactionTreasury { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<IssuingTransactionTreasury>, + builder: IssuingTransactionTreasuryBuilder, + } + + impl Visitor for Place<IssuingTransactionTreasury> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: IssuingTransactionTreasuryBuilder::deser_default() })) + } + } + + impl MapBuilder for IssuingTransactionTreasuryBuilder { + type Out = IssuingTransactionTreasury; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "received_credit" => Deserialize::begin(&mut self.received_credit), + "received_debit" => Deserialize::begin(&mut self.received_debit), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { received_credit: Deserialize::default(), received_debit: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let received_credit = self.received_credit.take()?; + let received_debit = self.received_debit.take()?; + + Some(Self::Out { received_credit, received_debit }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for IssuingTransactionTreasury { + type Builder = IssuingTransactionTreasuryBuilder; + } + + impl FromValueOpt for IssuingTransactionTreasury { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = IssuingTransactionTreasuryBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "received_credit" => b.received_credit = Some(FromValueOpt::from_value(v)?), + "received_debit" => b.received_debit = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/legal_entity_company.rs b/generated/stripe_shared/src/legal_entity_company.rs index 34f2221c1..5cf0d7a0e 100644 --- a/generated/stripe_shared/src/legal_entity_company.rs +++ b/generated/stripe_shared/src/legal_entity_company.rs @@ -1,64 +1,240 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityCompany { - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<stripe_shared::Address>, /// The Kana variation of the company's primary address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kana: Option<stripe_shared::LegalEntityJapanAddress>, /// The Kanji variation of the company's primary address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kanji: Option<stripe_shared::LegalEntityJapanAddress>, /// Whether the company's directors have been provided. /// This Boolean will be `true` if you've manually indicated that all directors are provided via [the `directors_provided` parameter](https://stripe.com/docs/api/accounts/update#update_account-company-directors_provided). - #[serde(skip_serializing_if = "Option::is_none")] pub directors_provided: Option<bool>, /// Whether the company's executives have been provided. /// This Boolean will be `true` if you've manually indicated that all executives are provided via [the `executives_provided` parameter](https://stripe.com/docs/api/accounts/update#update_account-company-executives_provided), or if Stripe determined that sufficient executives were provided. - #[serde(skip_serializing_if = "Option::is_none")] pub executives_provided: Option<bool>, /// The export license ID number of the company, also referred as Import Export Code (India only). - #[serde(skip_serializing_if = "Option::is_none")] pub export_license_id: Option<String>, /// The purpose code to use for export transactions (India only). - #[serde(skip_serializing_if = "Option::is_none")] pub export_purpose_code: Option<String>, /// The company's legal name. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, /// The Kana variation of the company's legal name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub name_kana: Option<String>, /// The Kanji variation of the company's legal name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub name_kanji: Option<String>, /// Whether the company's owners have been provided. /// This Boolean will be `true` if you've manually indicated that all owners are provided via [the `owners_provided` parameter](https://stripe.com/docs/api/accounts/update#update_account-company-owners_provided), or if Stripe determined that sufficient owners were provided. /// Stripe determines ownership requirements using both the number of owners provided and their total percent ownership (calculated by adding the `percent_ownership` of each owner together). - #[serde(skip_serializing_if = "Option::is_none")] pub owners_provided: Option<bool>, /// This hash is used to attest that the beneficial owner information provided to Stripe is both current and correct. - #[serde(skip_serializing_if = "Option::is_none")] pub ownership_declaration: Option<stripe_shared::LegalEntityUboDeclaration>, /// The company's phone number (used for verification). - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option<String>, /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. - #[serde(skip_serializing_if = "Option::is_none")] pub structure: Option<LegalEntityCompanyStructure>, /// Whether the company's business ID number was provided. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_id_provided: Option<bool>, /// The jurisdiction in which the `tax_id` is registered (Germany-based companies only). - #[serde(skip_serializing_if = "Option::is_none")] pub tax_id_registrar: Option<String>, /// Whether the company's business VAT number was provided. - #[serde(skip_serializing_if = "Option::is_none")] pub vat_id_provided: Option<bool>, /// Information on the verification state of the company. - #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option<stripe_shared::LegalEntityCompanyVerification>, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityCompanyBuilder { + address: Option<Option<stripe_shared::Address>>, + address_kana: Option<Option<stripe_shared::LegalEntityJapanAddress>>, + address_kanji: Option<Option<stripe_shared::LegalEntityJapanAddress>>, + directors_provided: Option<Option<bool>>, + executives_provided: Option<Option<bool>>, + export_license_id: Option<Option<String>>, + export_purpose_code: Option<Option<String>>, + name: Option<Option<String>>, + name_kana: Option<Option<String>>, + name_kanji: Option<Option<String>>, + owners_provided: Option<Option<bool>>, + ownership_declaration: Option<Option<stripe_shared::LegalEntityUboDeclaration>>, + phone: Option<Option<String>>, + structure: Option<Option<LegalEntityCompanyStructure>>, + tax_id_provided: Option<Option<bool>>, + tax_id_registrar: Option<Option<String>>, + vat_id_provided: Option<Option<bool>>, + verification: Option<Option<stripe_shared::LegalEntityCompanyVerification>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityCompany { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityCompany>, + builder: LegalEntityCompanyBuilder, + } + + impl Visitor for Place<LegalEntityCompany> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityCompanyBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityCompanyBuilder { + type Out = LegalEntityCompany; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "address_kana" => Deserialize::begin(&mut self.address_kana), + "address_kanji" => Deserialize::begin(&mut self.address_kanji), + "directors_provided" => Deserialize::begin(&mut self.directors_provided), + "executives_provided" => Deserialize::begin(&mut self.executives_provided), + "export_license_id" => Deserialize::begin(&mut self.export_license_id), + "export_purpose_code" => Deserialize::begin(&mut self.export_purpose_code), + "name" => Deserialize::begin(&mut self.name), + "name_kana" => Deserialize::begin(&mut self.name_kana), + "name_kanji" => Deserialize::begin(&mut self.name_kanji), + "owners_provided" => Deserialize::begin(&mut self.owners_provided), + "ownership_declaration" => Deserialize::begin(&mut self.ownership_declaration), + "phone" => Deserialize::begin(&mut self.phone), + "structure" => Deserialize::begin(&mut self.structure), + "tax_id_provided" => Deserialize::begin(&mut self.tax_id_provided), + "tax_id_registrar" => Deserialize::begin(&mut self.tax_id_registrar), + "vat_id_provided" => Deserialize::begin(&mut self.vat_id_provided), + "verification" => Deserialize::begin(&mut self.verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + address_kana: Deserialize::default(), + address_kanji: Deserialize::default(), + directors_provided: Deserialize::default(), + executives_provided: Deserialize::default(), + export_license_id: Deserialize::default(), + export_purpose_code: Deserialize::default(), + name: Deserialize::default(), + name_kana: Deserialize::default(), + name_kanji: Deserialize::default(), + owners_provided: Deserialize::default(), + ownership_declaration: Deserialize::default(), + phone: Deserialize::default(), + structure: Deserialize::default(), + tax_id_provided: Deserialize::default(), + tax_id_registrar: Deserialize::default(), + vat_id_provided: Deserialize::default(), + verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let address_kana = self.address_kana.take()?; + let address_kanji = self.address_kanji.take()?; + let directors_provided = self.directors_provided.take()?; + let executives_provided = self.executives_provided.take()?; + let export_license_id = self.export_license_id.take()?; + let export_purpose_code = self.export_purpose_code.take()?; + let name = self.name.take()?; + let name_kana = self.name_kana.take()?; + let name_kanji = self.name_kanji.take()?; + let owners_provided = self.owners_provided.take()?; + let ownership_declaration = self.ownership_declaration.take()?; + let phone = self.phone.take()?; + let structure = self.structure.take()?; + let tax_id_provided = self.tax_id_provided.take()?; + let tax_id_registrar = self.tax_id_registrar.take()?; + let vat_id_provided = self.vat_id_provided.take()?; + let verification = self.verification.take()?; + + Some(Self::Out { + address, + address_kana, + address_kanji, + directors_provided, + executives_provided, + export_license_id, + export_purpose_code, + name, + name_kana, + name_kanji, + owners_provided, + ownership_declaration, + phone, + structure, + tax_id_provided, + tax_id_registrar, + vat_id_provided, + verification, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityCompany { + type Builder = LegalEntityCompanyBuilder; + } + + impl FromValueOpt for LegalEntityCompany { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityCompanyBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "address_kana" => b.address_kana = Some(FromValueOpt::from_value(v)?), + "address_kanji" => b.address_kanji = Some(FromValueOpt::from_value(v)?), + "directors_provided" => b.directors_provided = Some(FromValueOpt::from_value(v)?), + "executives_provided" => b.executives_provided = Some(FromValueOpt::from_value(v)?), + "export_license_id" => b.export_license_id = Some(FromValueOpt::from_value(v)?), + "export_purpose_code" => b.export_purpose_code = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "name_kana" => b.name_kana = Some(FromValueOpt::from_value(v)?), + "name_kanji" => b.name_kanji = Some(FromValueOpt::from_value(v)?), + "owners_provided" => b.owners_provided = Some(FromValueOpt::from_value(v)?), + "ownership_declaration" => b.ownership_declaration = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + "structure" => b.structure = Some(FromValueOpt::from_value(v)?), + "tax_id_provided" => b.tax_id_provided = Some(FromValueOpt::from_value(v)?), + "tax_id_registrar" => b.tax_id_registrar = Some(FromValueOpt::from_value(v)?), + "vat_id_provided" => b.vat_id_provided = Some(FromValueOpt::from_value(v)?), + "verification" => b.verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The category identifying the legal structure of the company or legal entity. /// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details. #[derive(Copy, Clone, Eq, PartialEq)] @@ -79,7 +255,6 @@ pub enum LegalEntityCompanyStructure { PublicCompany, PublicCorporation, PublicPartnership, - RegisteredCharity, SingleMemberLlc, SoleEstablishment, SoleProprietorship, @@ -109,7 +284,6 @@ impl LegalEntityCompanyStructure { PublicCompany => "public_company", PublicCorporation => "public_corporation", PublicPartnership => "public_partnership", - RegisteredCharity => "registered_charity", SingleMemberLlc => "single_member_llc", SoleEstablishment => "sole_establishment", SoleProprietorship => "sole_proprietorship", @@ -142,7 +316,6 @@ impl std::str::FromStr for LegalEntityCompanyStructure { "public_company" => Ok(PublicCompany), "public_corporation" => Ok(PublicCorporation), "public_partnership" => Ok(PublicPartnership), - "registered_charity" => Ok(RegisteredCharity), "single_member_llc" => Ok(SingleMemberLlc), "sole_establishment" => Ok(SoleEstablishment), "sole_proprietorship" => Ok(SoleProprietorship), @@ -177,6 +350,24 @@ impl<'de> serde::Deserialize<'de> for LegalEntityCompanyStructure { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(LegalEntityCompanyStructure::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for LegalEntityCompanyStructure { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<LegalEntityCompanyStructure> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(LegalEntityCompanyStructure::from_str(s).unwrap_or(LegalEntityCompanyStructure::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(LegalEntityCompanyStructure); diff --git a/generated/stripe_shared/src/legal_entity_company_verification.rs b/generated/stripe_shared/src/legal_entity_company_verification.rs index cbe5a09d7..7b741bcd9 100644 --- a/generated/stripe_shared/src/legal_entity_company_verification.rs +++ b/generated/stripe_shared/src/legal_entity_company_verification.rs @@ -1,4 +1,92 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityCompanyVerification { pub document: stripe_shared::LegalEntityCompanyVerificationDocument, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityCompanyVerificationBuilder { + document: Option<stripe_shared::LegalEntityCompanyVerificationDocument>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityCompanyVerification { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityCompanyVerification>, + builder: LegalEntityCompanyVerificationBuilder, + } + + impl Visitor for Place<LegalEntityCompanyVerification> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityCompanyVerificationBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityCompanyVerificationBuilder { + type Out = LegalEntityCompanyVerification; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "document" => Deserialize::begin(&mut self.document), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let document = self.document.take()?; + + Some(Self::Out { document }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityCompanyVerification { + type Builder = LegalEntityCompanyVerificationBuilder; + } + + impl FromValueOpt for LegalEntityCompanyVerification { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityCompanyVerificationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "document" => b.document = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/legal_entity_company_verification_document.rs b/generated/stripe_shared/src/legal_entity_company_verification_document.rs index 6e9e6b843..a7dadf7b8 100644 --- a/generated/stripe_shared/src/legal_entity_company_verification_document.rs +++ b/generated/stripe_shared/src/legal_entity_company_verification_document.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityCompanyVerificationDocument { /// The back of a document returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `additional_verification`. pub back: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -10,3 +12,101 @@ pub struct LegalEntityCompanyVerificationDocument { /// The front of a document returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `additional_verification`. pub front: Option<stripe_types::Expandable<stripe_shared::File>>, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityCompanyVerificationDocumentBuilder { + back: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + details: Option<Option<String>>, + details_code: Option<Option<String>>, + front: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityCompanyVerificationDocument { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityCompanyVerificationDocument>, + builder: LegalEntityCompanyVerificationDocumentBuilder, + } + + impl Visitor for Place<LegalEntityCompanyVerificationDocument> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityCompanyVerificationDocumentBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityCompanyVerificationDocumentBuilder { + type Out = LegalEntityCompanyVerificationDocument; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "back" => Deserialize::begin(&mut self.back), + "details" => Deserialize::begin(&mut self.details), + "details_code" => Deserialize::begin(&mut self.details_code), + "front" => Deserialize::begin(&mut self.front), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { back: Deserialize::default(), details: Deserialize::default(), details_code: Deserialize::default(), front: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let back = self.back.take()?; + let details = self.details.take()?; + let details_code = self.details_code.take()?; + let front = self.front.take()?; + + Some(Self::Out { back, details, details_code, front }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityCompanyVerificationDocument { + type Builder = LegalEntityCompanyVerificationDocumentBuilder; + } + + impl FromValueOpt for LegalEntityCompanyVerificationDocument { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityCompanyVerificationDocumentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "back" => b.back = Some(FromValueOpt::from_value(v)?), + "details" => b.details = Some(FromValueOpt::from_value(v)?), + "details_code" => b.details_code = Some(FromValueOpt::from_value(v)?), + "front" => b.front = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/legal_entity_dob.rs b/generated/stripe_shared/src/legal_entity_dob.rs index 44dc0a314..888513220 100644 --- a/generated/stripe_shared/src/legal_entity_dob.rs +++ b/generated/stripe_shared/src/legal_entity_dob.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityDob { /// The day of birth, between 1 and 31. pub day: Option<i64>, @@ -7,3 +9,97 @@ pub struct LegalEntityDob { /// The four-digit year of birth. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityDobBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityDob { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityDob>, + builder: LegalEntityDobBuilder, + } + + impl Visitor for Place<LegalEntityDob> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityDobBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityDobBuilder { + type Out = LegalEntityDob; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityDob { + type Builder = LegalEntityDobBuilder; + } + + impl FromValueOpt for LegalEntityDob { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityDobBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/legal_entity_japan_address.rs b/generated/stripe_shared/src/legal_entity_japan_address.rs index 38fd816e7..d8785a038 100644 --- a/generated/stripe_shared/src/legal_entity_japan_address.rs +++ b/generated/stripe_shared/src/legal_entity_japan_address.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityJapanAddress { /// City/Ward. pub city: Option<String>, @@ -15,3 +17,121 @@ pub struct LegalEntityJapanAddress { /// Town/cho-me. pub town: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityJapanAddressBuilder { + city: Option<Option<String>>, + country: Option<Option<String>>, + line1: Option<Option<String>>, + line2: Option<Option<String>>, + postal_code: Option<Option<String>>, + state: Option<Option<String>>, + town: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityJapanAddress { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityJapanAddress>, + builder: LegalEntityJapanAddressBuilder, + } + + impl Visitor for Place<LegalEntityJapanAddress> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityJapanAddressBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityJapanAddressBuilder { + type Out = LegalEntityJapanAddress; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "city" => Deserialize::begin(&mut self.city), + "country" => Deserialize::begin(&mut self.country), + "line1" => Deserialize::begin(&mut self.line1), + "line2" => Deserialize::begin(&mut self.line2), + "postal_code" => Deserialize::begin(&mut self.postal_code), + "state" => Deserialize::begin(&mut self.state), + "town" => Deserialize::begin(&mut self.town), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + city: Deserialize::default(), + country: Deserialize::default(), + line1: Deserialize::default(), + line2: Deserialize::default(), + postal_code: Deserialize::default(), + state: Deserialize::default(), + town: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let city = self.city.take()?; + let country = self.country.take()?; + let line1 = self.line1.take()?; + let line2 = self.line2.take()?; + let postal_code = self.postal_code.take()?; + let state = self.state.take()?; + let town = self.town.take()?; + + Some(Self::Out { city, country, line1, line2, postal_code, state, town }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityJapanAddress { + type Builder = LegalEntityJapanAddressBuilder; + } + + impl FromValueOpt for LegalEntityJapanAddress { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityJapanAddressBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "city" => b.city = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "line1" => b.line1 = Some(FromValueOpt::from_value(v)?), + "line2" => b.line2 = Some(FromValueOpt::from_value(v)?), + "postal_code" => b.postal_code = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + "town" => b.town = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/legal_entity_person_verification.rs b/generated/stripe_shared/src/legal_entity_person_verification.rs index ff947c2b5..09366438b 100644 --- a/generated/stripe_shared/src/legal_entity_person_verification.rs +++ b/generated/stripe_shared/src/legal_entity_person_verification.rs @@ -1,19 +1,125 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityPersonVerification { /// A document showing address, either a passport, local ID card, or utility bill from a well-known utility company. - #[serde(skip_serializing_if = "Option::is_none")] pub additional_document: Option<stripe_shared::LegalEntityPersonVerificationDocument>, /// A user-displayable string describing the verification state for the person. /// For example, this may say "Provided identity information could not be verified". - #[serde(skip_serializing_if = "Option::is_none")] pub details: Option<String>, /// One of `document_address_mismatch`, `document_dob_mismatch`, `document_duplicate_type`, `document_id_number_mismatch`, `document_name_mismatch`, `document_nationality_mismatch`, `failed_keyed_identity`, or `failed_other`. /// A machine-readable code specifying the verification state for the person. - #[serde(skip_serializing_if = "Option::is_none")] pub details_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub document: Option<stripe_shared::LegalEntityPersonVerificationDocument>, /// The state of verification for the person. /// Possible values are `unverified`, `pending`, or `verified`. pub status: String, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityPersonVerificationBuilder { + additional_document: Option<Option<stripe_shared::LegalEntityPersonVerificationDocument>>, + details: Option<Option<String>>, + details_code: Option<Option<String>>, + document: Option<Option<stripe_shared::LegalEntityPersonVerificationDocument>>, + status: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityPersonVerification { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityPersonVerification>, + builder: LegalEntityPersonVerificationBuilder, + } + + impl Visitor for Place<LegalEntityPersonVerification> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityPersonVerificationBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityPersonVerificationBuilder { + type Out = LegalEntityPersonVerification; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "additional_document" => Deserialize::begin(&mut self.additional_document), + "details" => Deserialize::begin(&mut self.details), + "details_code" => Deserialize::begin(&mut self.details_code), + "document" => Deserialize::begin(&mut self.document), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + additional_document: Deserialize::default(), + details: Deserialize::default(), + details_code: Deserialize::default(), + document: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let additional_document = self.additional_document.take()?; + let details = self.details.take()?; + let details_code = self.details_code.take()?; + let document = self.document.take()?; + let status = self.status.take()?; + + Some(Self::Out { additional_document, details, details_code, document, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityPersonVerification { + type Builder = LegalEntityPersonVerificationBuilder; + } + + impl FromValueOpt for LegalEntityPersonVerification { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityPersonVerificationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "additional_document" => b.additional_document = Some(FromValueOpt::from_value(v)?), + "details" => b.details = Some(FromValueOpt::from_value(v)?), + "details_code" => b.details_code = Some(FromValueOpt::from_value(v)?), + "document" => b.document = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/legal_entity_person_verification_document.rs b/generated/stripe_shared/src/legal_entity_person_verification_document.rs index 24e4bc03e..ebd8365b1 100644 --- a/generated/stripe_shared/src/legal_entity_person_verification_document.rs +++ b/generated/stripe_shared/src/legal_entity_person_verification_document.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityPersonVerificationDocument { /// The back of an ID returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `identity_document`. pub back: Option<stripe_types::Expandable<stripe_shared::File>>, @@ -11,3 +13,101 @@ pub struct LegalEntityPersonVerificationDocument { /// The front of an ID returned by a [file upload](https://stripe.com/docs/api#create_file) with a `purpose` value of `identity_document`. pub front: Option<stripe_types::Expandable<stripe_shared::File>>, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityPersonVerificationDocumentBuilder { + back: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, + details: Option<Option<String>>, + details_code: Option<Option<String>>, + front: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityPersonVerificationDocument { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityPersonVerificationDocument>, + builder: LegalEntityPersonVerificationDocumentBuilder, + } + + impl Visitor for Place<LegalEntityPersonVerificationDocument> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityPersonVerificationDocumentBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityPersonVerificationDocumentBuilder { + type Out = LegalEntityPersonVerificationDocument; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "back" => Deserialize::begin(&mut self.back), + "details" => Deserialize::begin(&mut self.details), + "details_code" => Deserialize::begin(&mut self.details_code), + "front" => Deserialize::begin(&mut self.front), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { back: Deserialize::default(), details: Deserialize::default(), details_code: Deserialize::default(), front: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let back = self.back.take()?; + let details = self.details.take()?; + let details_code = self.details_code.take()?; + let front = self.front.take()?; + + Some(Self::Out { back, details, details_code, front }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityPersonVerificationDocument { + type Builder = LegalEntityPersonVerificationDocumentBuilder; + } + + impl FromValueOpt for LegalEntityPersonVerificationDocument { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityPersonVerificationDocumentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "back" => b.back = Some(FromValueOpt::from_value(v)?), + "details" => b.details = Some(FromValueOpt::from_value(v)?), + "details_code" => b.details_code = Some(FromValueOpt::from_value(v)?), + "front" => b.front = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/legal_entity_ubo_declaration.rs b/generated/stripe_shared/src/legal_entity_ubo_declaration.rs index 1db87525d..9f816b393 100644 --- a/generated/stripe_shared/src/legal_entity_ubo_declaration.rs +++ b/generated/stripe_shared/src/legal_entity_ubo_declaration.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LegalEntityUboDeclaration { /// The Unix timestamp marking when the beneficial owner attestation was made. pub date: Option<stripe_types::Timestamp>, @@ -7,3 +9,97 @@ pub struct LegalEntityUboDeclaration { /// The user-agent string from the browser where the beneficial owner attestation was made. pub user_agent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct LegalEntityUboDeclarationBuilder { + date: Option<Option<stripe_types::Timestamp>>, + ip: Option<Option<String>>, + user_agent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LegalEntityUboDeclaration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LegalEntityUboDeclaration>, + builder: LegalEntityUboDeclarationBuilder, + } + + impl Visitor for Place<LegalEntityUboDeclaration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LegalEntityUboDeclarationBuilder::deser_default() })) + } + } + + impl MapBuilder for LegalEntityUboDeclarationBuilder { + type Out = LegalEntityUboDeclaration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "date" => Deserialize::begin(&mut self.date), + "ip" => Deserialize::begin(&mut self.ip), + "user_agent" => Deserialize::begin(&mut self.user_agent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { date: Deserialize::default(), ip: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let date = self.date.take()?; + let ip = self.ip.take()?; + let user_agent = self.user_agent.take()?; + + Some(Self::Out { date, ip, user_agent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LegalEntityUboDeclaration { + type Builder = LegalEntityUboDeclarationBuilder; + } + + impl FromValueOpt for LegalEntityUboDeclaration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LegalEntityUboDeclarationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "date" => b.date = Some(FromValueOpt::from_value(v)?), + "ip" => b.ip = Some(FromValueOpt::from_value(v)?), + "user_agent" => b.user_agent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/level3.rs b/generated/stripe_shared/src/level3.rs index d61172c79..d06dd5bbb 100644 --- a/generated/stripe_shared/src/level3.rs +++ b/generated/stripe_shared/src/level3.rs @@ -1,13 +1,124 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Level3 { - #[serde(skip_serializing_if = "Option::is_none")] pub customer_reference: Option<String>, pub line_items: Vec<stripe_shared::Level3LineItems>, pub merchant_reference: String, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_address_zip: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_amount: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_from_zip: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct Level3Builder { + customer_reference: Option<Option<String>>, + line_items: Option<Vec<stripe_shared::Level3LineItems>>, + merchant_reference: Option<String>, + shipping_address_zip: Option<Option<String>>, + shipping_amount: Option<Option<i64>>, + shipping_from_zip: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Level3 { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Level3>, + builder: Level3Builder, + } + + impl Visitor for Place<Level3> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Level3Builder::deser_default() })) + } + } + + impl MapBuilder for Level3Builder { + type Out = Level3; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "customer_reference" => Deserialize::begin(&mut self.customer_reference), + "line_items" => Deserialize::begin(&mut self.line_items), + "merchant_reference" => Deserialize::begin(&mut self.merchant_reference), + "shipping_address_zip" => Deserialize::begin(&mut self.shipping_address_zip), + "shipping_amount" => Deserialize::begin(&mut self.shipping_amount), + "shipping_from_zip" => Deserialize::begin(&mut self.shipping_from_zip), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + customer_reference: Deserialize::default(), + line_items: Deserialize::default(), + merchant_reference: Deserialize::default(), + shipping_address_zip: Deserialize::default(), + shipping_amount: Deserialize::default(), + shipping_from_zip: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let customer_reference = self.customer_reference.take()?; + let line_items = self.line_items.take()?; + let merchant_reference = self.merchant_reference.take()?; + let shipping_address_zip = self.shipping_address_zip.take()?; + let shipping_amount = self.shipping_amount.take()?; + let shipping_from_zip = self.shipping_from_zip.take()?; + + Some(Self::Out { customer_reference, line_items, merchant_reference, shipping_address_zip, shipping_amount, shipping_from_zip }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Level3 { + type Builder = Level3Builder; + } + + impl FromValueOpt for Level3 { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = Level3Builder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "customer_reference" => b.customer_reference = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "merchant_reference" => b.merchant_reference = Some(FromValueOpt::from_value(v)?), + "shipping_address_zip" => b.shipping_address_zip = Some(FromValueOpt::from_value(v)?), + "shipping_amount" => b.shipping_amount = Some(FromValueOpt::from_value(v)?), + "shipping_from_zip" => b.shipping_from_zip = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/level3_line_items.rs b/generated/stripe_shared/src/level3_line_items.rs index 60d0a1321..fb5d24ee2 100644 --- a/generated/stripe_shared/src/level3_line_items.rs +++ b/generated/stripe_shared/src/level3_line_items.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Level3LineItems { pub discount_amount: Option<i64>, pub product_code: String, @@ -7,3 +9,116 @@ pub struct Level3LineItems { pub tax_amount: Option<i64>, pub unit_cost: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct Level3LineItemsBuilder { + discount_amount: Option<Option<i64>>, + product_code: Option<String>, + product_description: Option<String>, + quantity: Option<Option<u64>>, + tax_amount: Option<Option<i64>>, + unit_cost: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Level3LineItems { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Level3LineItems>, + builder: Level3LineItemsBuilder, + } + + impl Visitor for Place<Level3LineItems> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Level3LineItemsBuilder::deser_default() })) + } + } + + impl MapBuilder for Level3LineItemsBuilder { + type Out = Level3LineItems; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "discount_amount" => Deserialize::begin(&mut self.discount_amount), + "product_code" => Deserialize::begin(&mut self.product_code), + "product_description" => Deserialize::begin(&mut self.product_description), + "quantity" => Deserialize::begin(&mut self.quantity), + "tax_amount" => Deserialize::begin(&mut self.tax_amount), + "unit_cost" => Deserialize::begin(&mut self.unit_cost), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + discount_amount: Deserialize::default(), + product_code: Deserialize::default(), + product_description: Deserialize::default(), + quantity: Deserialize::default(), + tax_amount: Deserialize::default(), + unit_cost: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let discount_amount = self.discount_amount.take()?; + let product_code = self.product_code.take()?; + let product_description = self.product_description.take()?; + let quantity = self.quantity.take()?; + let tax_amount = self.tax_amount.take()?; + let unit_cost = self.unit_cost.take()?; + + Some(Self::Out { discount_amount, product_code, product_description, quantity, tax_amount, unit_cost }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Level3LineItems { + type Builder = Level3LineItemsBuilder; + } + + impl FromValueOpt for Level3LineItems { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = Level3LineItemsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "discount_amount" => b.discount_amount = Some(FromValueOpt::from_value(v)?), + "product_code" => b.product_code = Some(FromValueOpt::from_value(v)?), + "product_description" => b.product_description = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "tax_amount" => b.tax_amount = Some(FromValueOpt::from_value(v)?), + "unit_cost" => b.unit_cost = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/line_items_discount_amount.rs b/generated/stripe_shared/src/line_items_discount_amount.rs index a0027caf1..9d67d163c 100644 --- a/generated/stripe_shared/src/line_items_discount_amount.rs +++ b/generated/stripe_shared/src/line_items_discount_amount.rs @@ -1,6 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LineItemsDiscountAmount { /// The amount discounted. pub amount: i64, pub discount: stripe_shared::Discount, } +#[cfg(feature = "min-ser")] +pub struct LineItemsDiscountAmountBuilder { + amount: Option<i64>, + discount: Option<stripe_shared::Discount>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LineItemsDiscountAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LineItemsDiscountAmount>, + builder: LineItemsDiscountAmountBuilder, + } + + impl Visitor for Place<LineItemsDiscountAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LineItemsDiscountAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for LineItemsDiscountAmountBuilder { + type Out = LineItemsDiscountAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "discount" => Deserialize::begin(&mut self.discount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), discount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let discount = self.discount.take()?; + + Some(Self::Out { amount, discount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LineItemsDiscountAmount { + type Builder = LineItemsDiscountAmountBuilder; + } + + impl FromValueOpt for LineItemsDiscountAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LineItemsDiscountAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "discount" => b.discount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/line_items_tax_amount.rs b/generated/stripe_shared/src/line_items_tax_amount.rs index 77f14c659..7c7139b7d 100644 --- a/generated/stripe_shared/src/line_items_tax_amount.rs +++ b/generated/stripe_shared/src/line_items_tax_amount.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LineItemsTaxAmount { /// Amount of tax applied for this rate. pub amount: i64, @@ -9,6 +11,104 @@ pub struct LineItemsTaxAmount { /// The amount on which tax is calculated, in cents (or local equivalent). pub taxable_amount: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct LineItemsTaxAmountBuilder { + amount: Option<i64>, + rate: Option<stripe_shared::TaxRate>, + taxability_reason: Option<Option<LineItemsTaxAmountTaxabilityReason>>, + taxable_amount: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LineItemsTaxAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LineItemsTaxAmount>, + builder: LineItemsTaxAmountBuilder, + } + + impl Visitor for Place<LineItemsTaxAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LineItemsTaxAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for LineItemsTaxAmountBuilder { + type Out = LineItemsTaxAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "rate" => Deserialize::begin(&mut self.rate), + "taxability_reason" => Deserialize::begin(&mut self.taxability_reason), + "taxable_amount" => Deserialize::begin(&mut self.taxable_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), rate: Deserialize::default(), taxability_reason: Deserialize::default(), taxable_amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let rate = self.rate.take()?; + let taxability_reason = self.taxability_reason.take()?; + let taxable_amount = self.taxable_amount.take()?; + + Some(Self::Out { amount, rate, taxability_reason, taxable_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LineItemsTaxAmount { + type Builder = LineItemsTaxAmountBuilder; + } + + impl FromValueOpt for LineItemsTaxAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LineItemsTaxAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "rate" => b.rate = Some(FromValueOpt::from_value(v)?), + "taxability_reason" => b.taxability_reason = Some(FromValueOpt::from_value(v)?), + "taxable_amount" => b.taxable_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reasoning behind this tax, for example, if the product is tax exempt. /// The possible values for this field may be extended as new tax rules are supported. #[derive(Copy, Clone, Eq, PartialEq)] @@ -103,6 +203,24 @@ impl<'de> serde::Deserialize<'de> for LineItemsTaxAmountTaxabilityReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(LineItemsTaxAmountTaxabilityReason::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for LineItemsTaxAmountTaxabilityReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<LineItemsTaxAmountTaxabilityReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(LineItemsTaxAmountTaxabilityReason::from_str(s).unwrap_or(LineItemsTaxAmountTaxabilityReason::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(LineItemsTaxAmountTaxabilityReason); diff --git a/generated/stripe_shared/src/linked_account_options_us_bank_account.rs b/generated/stripe_shared/src/linked_account_options_us_bank_account.rs index e768eec63..314e0a3d5 100644 --- a/generated/stripe_shared/src/linked_account_options_us_bank_account.rs +++ b/generated/stripe_shared/src/linked_account_options_us_bank_account.rs @@ -1,15 +1,109 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct LinkedAccountOptionsUsBankAccount { /// The list of permissions to request. The `payment_method` permission must be included. - #[serde(skip_serializing_if = "Option::is_none")] pub permissions: Option<Vec<LinkedAccountOptionsUsBankAccountPermissions>>, /// Data features requested to be retrieved upon account creation. pub prefetch: Option<Vec<LinkedAccountOptionsUsBankAccountPrefetch>>, /// For webview integrations only. /// Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. - #[serde(skip_serializing_if = "Option::is_none")] pub return_url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct LinkedAccountOptionsUsBankAccountBuilder { + permissions: Option<Option<Vec<LinkedAccountOptionsUsBankAccountPermissions>>>, + prefetch: Option<Option<Vec<LinkedAccountOptionsUsBankAccountPrefetch>>>, + return_url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for LinkedAccountOptionsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<LinkedAccountOptionsUsBankAccount>, + builder: LinkedAccountOptionsUsBankAccountBuilder, + } + + impl Visitor for Place<LinkedAccountOptionsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: LinkedAccountOptionsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for LinkedAccountOptionsUsBankAccountBuilder { + type Out = LinkedAccountOptionsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "permissions" => Deserialize::begin(&mut self.permissions), + "prefetch" => Deserialize::begin(&mut self.prefetch), + "return_url" => Deserialize::begin(&mut self.return_url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { permissions: Deserialize::default(), prefetch: Deserialize::default(), return_url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let permissions = self.permissions.take()?; + let prefetch = self.prefetch.take()?; + let return_url = self.return_url.take()?; + + Some(Self::Out { permissions, prefetch, return_url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for LinkedAccountOptionsUsBankAccount { + type Builder = LinkedAccountOptionsUsBankAccountBuilder; + } + + impl FromValueOpt for LinkedAccountOptionsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = LinkedAccountOptionsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "permissions" => b.permissions = Some(FromValueOpt::from_value(v)?), + "prefetch" => b.prefetch = Some(FromValueOpt::from_value(v)?), + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The list of permissions to request. The `payment_method` permission must be included. #[derive(Copy, Clone, Eq, PartialEq)] pub enum LinkedAccountOptionsUsBankAccountPermissions { @@ -66,25 +160,37 @@ impl<'de> serde::Deserialize<'de> for LinkedAccountOptionsUsBankAccountPermissio fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for LinkedAccountOptionsUsBankAccountPermissions", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for LinkedAccountOptionsUsBankAccountPermissions")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for LinkedAccountOptionsUsBankAccountPermissions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<LinkedAccountOptionsUsBankAccountPermissions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(LinkedAccountOptionsUsBankAccountPermissions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(LinkedAccountOptionsUsBankAccountPermissions); /// Data features requested to be retrieved upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum LinkedAccountOptionsUsBankAccountPrefetch { Balances, - Transactions, } impl LinkedAccountOptionsUsBankAccountPrefetch { pub fn as_str(self) -> &'static str { use LinkedAccountOptionsUsBankAccountPrefetch::*; match self { Balances => "balances", - Transactions => "transactions", } } } @@ -95,7 +201,6 @@ impl std::str::FromStr for LinkedAccountOptionsUsBankAccountPrefetch { use LinkedAccountOptionsUsBankAccountPrefetch::*; match s { "balances" => Ok(Balances), - "transactions" => Ok(Transactions), _ => Err(()), } } @@ -123,8 +228,24 @@ impl<'de> serde::Deserialize<'de> for LinkedAccountOptionsUsBankAccountPrefetch fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for LinkedAccountOptionsUsBankAccountPrefetch") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for LinkedAccountOptionsUsBankAccountPrefetch")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for LinkedAccountOptionsUsBankAccountPrefetch { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<LinkedAccountOptionsUsBankAccountPrefetch> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(LinkedAccountOptionsUsBankAccountPrefetch::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(LinkedAccountOptionsUsBankAccountPrefetch); diff --git a/generated/stripe_shared/src/mandate.rs b/generated/stripe_shared/src/mandate.rs index 362aadcd3..04b0378cb 100644 --- a/generated/stripe_shared/src/mandate.rs +++ b/generated/stripe_shared/src/mandate.rs @@ -1,29 +1,161 @@ /// A Mandate is a record of the permission that your customer gives you to debit their payment method. /// /// For more details see <<https://stripe.com/docs/api/mandates/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Mandate { pub customer_acceptance: stripe_shared::CustomerAcceptance, /// Unique identifier for the object. pub id: stripe_shared::MandateId, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub multi_use: Option<stripe_shared::MandateMultiUse>, /// The account (if any) that the mandate is intended for. - #[serde(skip_serializing_if = "Option::is_none")] pub on_behalf_of: Option<String>, /// ID of the payment method associated with this mandate. pub payment_method: stripe_types::Expandable<stripe_shared::PaymentMethod>, pub payment_method_details: stripe_shared::MandatePaymentMethodDetails, - #[serde(skip_serializing_if = "Option::is_none")] pub single_use: Option<stripe_shared::MandateSingleUse>, /// The mandate status indicates whether or not you can use it to initiate a payment. pub status: MandateStatus, /// The type of the mandate. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: MandateType, } +#[cfg(feature = "min-ser")] +pub struct MandateBuilder { + customer_acceptance: Option<stripe_shared::CustomerAcceptance>, + id: Option<stripe_shared::MandateId>, + livemode: Option<bool>, + multi_use: Option<Option<stripe_shared::MandateMultiUse>>, + on_behalf_of: Option<Option<String>>, + payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>, + payment_method_details: Option<stripe_shared::MandatePaymentMethodDetails>, + single_use: Option<Option<stripe_shared::MandateSingleUse>>, + status: Option<MandateStatus>, + type_: Option<MandateType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Mandate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Mandate>, + builder: MandateBuilder, + } + + impl Visitor for Place<Mandate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateBuilder { + type Out = Mandate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "customer_acceptance" => Deserialize::begin(&mut self.customer_acceptance), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "multi_use" => Deserialize::begin(&mut self.multi_use), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "payment_method" => Deserialize::begin(&mut self.payment_method), + "payment_method_details" => Deserialize::begin(&mut self.payment_method_details), + "single_use" => Deserialize::begin(&mut self.single_use), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + customer_acceptance: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + multi_use: Deserialize::default(), + on_behalf_of: Deserialize::default(), + payment_method: Deserialize::default(), + payment_method_details: Deserialize::default(), + single_use: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let customer_acceptance = self.customer_acceptance.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let multi_use = self.multi_use.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let payment_method = self.payment_method.take()?; + let payment_method_details = self.payment_method_details.take()?; + let single_use = self.single_use.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { customer_acceptance, id, livemode, multi_use, on_behalf_of, payment_method, payment_method_details, single_use, status, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Mandate { + type Builder = MandateBuilder; + } + + impl FromValueOpt for Mandate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "customer_acceptance" => b.customer_acceptance = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "multi_use" => b.multi_use = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "payment_method" => b.payment_method = Some(FromValueOpt::from_value(v)?), + "payment_method_details" => b.payment_method_details = Some(FromValueOpt::from_value(v)?), + "single_use" => b.single_use = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The mandate status indicates whether or not you can use it to initiate a payment. #[derive(Copy, Clone, Eq, PartialEq)] pub enum MandateStatus { @@ -80,6 +212,24 @@ impl<'de> serde::Deserialize<'de> for MandateStatus { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for MandateStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for MandateStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<MandateStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(MandateStatus); /// The type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum MandateType { @@ -133,6 +283,24 @@ impl<'de> serde::Deserialize<'de> for MandateType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for MandateType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for MandateType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<MandateType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(MandateType); impl stripe_types::Object for Mandate { type Id = stripe_shared::MandateId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/mandate_acss_debit.rs b/generated/stripe_shared/src/mandate_acss_debit.rs index c890abade..bfc4fd550 100644 --- a/generated/stripe_shared/src/mandate_acss_debit.rs +++ b/generated/stripe_shared/src/mandate_acss_debit.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateAcssDebit { /// List of Stripe products where this mandate can be selected automatically. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for: Option<Vec<MandateAcssDebitDefaultFor>>, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. @@ -11,6 +12,104 @@ pub struct MandateAcssDebit { /// Transaction type of the mandate. pub transaction_type: MandateAcssDebitTransactionType, } +#[cfg(feature = "min-ser")] +pub struct MandateAcssDebitBuilder { + default_for: Option<Option<Vec<MandateAcssDebitDefaultFor>>>, + interval_description: Option<Option<String>>, + payment_schedule: Option<MandateAcssDebitPaymentSchedule>, + transaction_type: Option<MandateAcssDebitTransactionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateAcssDebit>, + builder: MandateAcssDebitBuilder, + } + + impl Visitor for Place<MandateAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateAcssDebitBuilder { + type Out = MandateAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "default_for" => Deserialize::begin(&mut self.default_for), + "interval_description" => Deserialize::begin(&mut self.interval_description), + "payment_schedule" => Deserialize::begin(&mut self.payment_schedule), + "transaction_type" => Deserialize::begin(&mut self.transaction_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { default_for: Deserialize::default(), interval_description: Deserialize::default(), payment_schedule: Deserialize::default(), transaction_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let default_for = self.default_for.take()?; + let interval_description = self.interval_description.take()?; + let payment_schedule = self.payment_schedule.take()?; + let transaction_type = self.transaction_type.take()?; + + Some(Self::Out { default_for, interval_description, payment_schedule, transaction_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateAcssDebit { + type Builder = MandateAcssDebitBuilder; + } + + impl FromValueOpt for MandateAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "default_for" => b.default_for = Some(FromValueOpt::from_value(v)?), + "interval_description" => b.interval_description = Some(FromValueOpt::from_value(v)?), + "payment_schedule" => b.payment_schedule = Some(FromValueOpt::from_value(v)?), + "transaction_type" => b.transaction_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// List of Stripe products where this mandate can be selected automatically. #[derive(Copy, Clone, Eq, PartialEq)] pub enum MandateAcssDebitDefaultFor { @@ -61,10 +160,27 @@ impl<'de> serde::Deserialize<'de> for MandateAcssDebitDefaultFor { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for MandateAcssDebitDefaultFor")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for MandateAcssDebitDefaultFor")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for MandateAcssDebitDefaultFor { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<MandateAcssDebitDefaultFor> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateAcssDebitDefaultFor::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(MandateAcssDebitDefaultFor); /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum MandateAcssDebitPaymentSchedule { @@ -118,11 +234,27 @@ impl<'de> serde::Deserialize<'de> for MandateAcssDebitPaymentSchedule { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for MandateAcssDebitPaymentSchedule") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for MandateAcssDebitPaymentSchedule")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for MandateAcssDebitPaymentSchedule { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<MandateAcssDebitPaymentSchedule> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateAcssDebitPaymentSchedule::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(MandateAcssDebitPaymentSchedule); /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum MandateAcssDebitTransactionType { @@ -173,8 +305,24 @@ impl<'de> serde::Deserialize<'de> for MandateAcssDebitTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for MandateAcssDebitTransactionType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for MandateAcssDebitTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for MandateAcssDebitTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<MandateAcssDebitTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateAcssDebitTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(MandateAcssDebitTransactionType); diff --git a/generated/stripe_shared/src/mandate_au_becs_debit.rs b/generated/stripe_shared/src/mandate_au_becs_debit.rs index f1e02f406..d91d183fc 100644 --- a/generated/stripe_shared/src/mandate_au_becs_debit.rs +++ b/generated/stripe_shared/src/mandate_au_becs_debit.rs @@ -1,6 +1,94 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateAuBecsDebit { /// The URL of the mandate. /// This URL generally contains sensitive information about the customer and should be shared with them exclusively. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct MandateAuBecsDebitBuilder { + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateAuBecsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateAuBecsDebit>, + builder: MandateAuBecsDebitBuilder, + } + + impl Visitor for Place<MandateAuBecsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateAuBecsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateAuBecsDebitBuilder { + type Out = MandateAuBecsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let url = self.url.take()?; + + Some(Self::Out { url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateAuBecsDebit { + type Builder = MandateAuBecsDebitBuilder; + } + + impl FromValueOpt for MandateAuBecsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateAuBecsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_bacs_debit.rs b/generated/stripe_shared/src/mandate_bacs_debit.rs index b1fda1130..97e6f4e54 100644 --- a/generated/stripe_shared/src/mandate_bacs_debit.rs +++ b/generated/stripe_shared/src/mandate_bacs_debit.rs @@ -1,15 +1,109 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateBacsDebit { /// The status of the mandate on the Bacs network. /// Can be one of `pending`, `revoked`, `refused`, or `accepted`. pub network_status: MandateBacsDebitNetworkStatus, /// The unique reference identifying the mandate on the Bacs network. pub reference: String, - /// When the mandate is revoked on the Bacs network this field displays the reason for the revocation. - pub revocation_reason: Option<MandateBacsDebitRevocationReason>, /// The URL that will contain the mandate that the customer has signed. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct MandateBacsDebitBuilder { + network_status: Option<MandateBacsDebitNetworkStatus>, + reference: Option<String>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateBacsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateBacsDebit>, + builder: MandateBacsDebitBuilder, + } + + impl Visitor for Place<MandateBacsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateBacsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateBacsDebitBuilder { + type Out = MandateBacsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "network_status" => Deserialize::begin(&mut self.network_status), + "reference" => Deserialize::begin(&mut self.reference), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { network_status: Deserialize::default(), reference: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let network_status = self.network_status.take()?; + let reference = self.reference.take()?; + let url = self.url.take()?; + + Some(Self::Out { network_status, reference, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateBacsDebit { + type Builder = MandateBacsDebitBuilder; + } + + impl FromValueOpt for MandateBacsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateBacsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "network_status" => b.network_status = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the mandate on the Bacs network. /// Can be one of `pending`, `revoked`, `refused`, or `accepted`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -67,72 +161,24 @@ impl<'de> serde::Deserialize<'de> for MandateBacsDebitNetworkStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for MandateBacsDebitNetworkStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for MandateBacsDebitNetworkStatus")) } } -/// When the mandate is revoked on the Bacs network this field displays the reason for the revocation. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum MandateBacsDebitRevocationReason { - AccountClosed, - BankAccountRestricted, - BankOwnershipChanged, - CouldNotProcess, - DebitNotAuthorized, -} -impl MandateBacsDebitRevocationReason { - pub fn as_str(self) -> &'static str { - use MandateBacsDebitRevocationReason::*; - match self { - AccountClosed => "account_closed", - BankAccountRestricted => "bank_account_restricted", - BankOwnershipChanged => "bank_ownership_changed", - CouldNotProcess => "could_not_process", - DebitNotAuthorized => "debit_not_authorized", - } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for MandateBacsDebitNetworkStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } -impl std::str::FromStr for MandateBacsDebitRevocationReason { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use MandateBacsDebitRevocationReason::*; - match s { - "account_closed" => Ok(AccountClosed), - "bank_account_restricted" => Ok(BankAccountRestricted), - "bank_ownership_changed" => Ok(BankOwnershipChanged), - "could_not_process" => Ok(CouldNotProcess), - "debit_not_authorized" => Ok(DebitNotAuthorized), - _ => Err(()), - } - } -} -impl std::fmt::Display for MandateBacsDebitRevocationReason { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for MandateBacsDebitRevocationReason { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for MandateBacsDebitRevocationReason { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for MandateBacsDebitRevocationReason { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<MandateBacsDebitNetworkStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for MandateBacsDebitRevocationReason") - }) + self.out = Some(MandateBacsDebitNetworkStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(MandateBacsDebitNetworkStatus); diff --git a/generated/stripe_shared/src/mandate_cashapp.rs b/generated/stripe_shared/src/mandate_cashapp.rs index e28fa9bba..89d540b36 100644 --- a/generated/stripe_shared/src/mandate_cashapp.rs +++ b/generated/stripe_shared/src/mandate_cashapp.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateCashapp {} +#[cfg(feature = "min-ser")] +pub struct MandateCashappBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateCashapp { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateCashapp>, + builder: MandateCashappBuilder, + } + + impl Visitor for Place<MandateCashapp> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateCashappBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateCashappBuilder { + type Out = MandateCashapp; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateCashapp { + type Builder = MandateCashappBuilder; + } + + impl FromValueOpt for MandateCashapp { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateCashappBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_link.rs b/generated/stripe_shared/src/mandate_link.rs index 9b0fc2773..7ea6bf1be 100644 --- a/generated/stripe_shared/src/mandate_link.rs +++ b/generated/stripe_shared/src/mandate_link.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateLink {} +#[cfg(feature = "min-ser")] +pub struct MandateLinkBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateLink>, + builder: MandateLinkBuilder, + } + + impl Visitor for Place<MandateLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateLinkBuilder { + type Out = MandateLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateLink { + type Builder = MandateLinkBuilder; + } + + impl FromValueOpt for MandateLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_multi_use.rs b/generated/stripe_shared/src/mandate_multi_use.rs index f214a7fec..e62f11dc5 100644 --- a/generated/stripe_shared/src/mandate_multi_use.rs +++ b/generated/stripe_shared/src/mandate_multi_use.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateMultiUse {} +#[cfg(feature = "min-ser")] +pub struct MandateMultiUseBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateMultiUse { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateMultiUse>, + builder: MandateMultiUseBuilder, + } + + impl Visitor for Place<MandateMultiUse> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateMultiUseBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateMultiUseBuilder { + type Out = MandateMultiUse; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateMultiUse { + type Builder = MandateMultiUseBuilder; + } + + impl FromValueOpt for MandateMultiUse { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateMultiUseBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_payment_method_details.rs b/generated/stripe_shared/src/mandate_payment_method_details.rs index b930e9867..e226f0671 100644 --- a/generated/stripe_shared/src/mandate_payment_method_details.rs +++ b/generated/stripe_shared/src/mandate_payment_method_details.rs @@ -1,25 +1,151 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandatePaymentMethodDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_shared::MandateAcssDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_shared::MandateAuBecsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_shared::MandateBacsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::CardMandatePaymentMethodDetails>, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option<stripe_shared::MandateCashapp>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::MandateLink>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_shared::MandatePaypal>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_shared::MandateSepaDebit>, /// This mandate corresponds with a specific payment method type. /// The `payment_method_details` includes an additional hash with the same name and contains mandate information that's specific to that payment method. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_shared::MandateUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct MandatePaymentMethodDetailsBuilder { + acss_debit: Option<Option<stripe_shared::MandateAcssDebit>>, + au_becs_debit: Option<Option<stripe_shared::MandateAuBecsDebit>>, + bacs_debit: Option<Option<stripe_shared::MandateBacsDebit>>, + card: Option<Option<stripe_shared::CardMandatePaymentMethodDetails>>, + cashapp: Option<Option<stripe_shared::MandateCashapp>>, + link: Option<Option<stripe_shared::MandateLink>>, + paypal: Option<Option<stripe_shared::MandatePaypal>>, + sepa_debit: Option<Option<stripe_shared::MandateSepaDebit>>, + type_: Option<String>, + us_bank_account: Option<Option<stripe_shared::MandateUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandatePaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandatePaymentMethodDetails>, + builder: MandatePaymentMethodDetailsBuilder, + } + + impl Visitor for Place<MandatePaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandatePaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for MandatePaymentMethodDetailsBuilder { + type Out = MandatePaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "card" => Deserialize::begin(&mut self.card), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "link" => Deserialize::begin(&mut self.link), + "paypal" => Deserialize::begin(&mut self.paypal), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bacs_debit: Deserialize::default(), + card: Deserialize::default(), + cashapp: Deserialize::default(), + link: Deserialize::default(), + paypal: Deserialize::default(), + sepa_debit: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bacs_debit = self.bacs_debit.take()?; + let card = self.card.take()?; + let cashapp = self.cashapp.take()?; + let link = self.link.take()?; + let paypal = self.paypal.take()?; + let sepa_debit = self.sepa_debit.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { acss_debit, au_becs_debit, bacs_debit, card, cashapp, link, paypal, sepa_debit, type_, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandatePaymentMethodDetails { + type Builder = MandatePaymentMethodDetailsBuilder; + } + + impl FromValueOpt for MandatePaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandatePaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_paypal.rs b/generated/stripe_shared/src/mandate_paypal.rs index 82b4a1e93..4f379cb15 100644 --- a/generated/stripe_shared/src/mandate_paypal.rs +++ b/generated/stripe_shared/src/mandate_paypal.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandatePaypal { /// The PayPal Billing Agreement ID (BAID). /// This is an ID generated by PayPal which represents the mandate between the merchant and the customer. @@ -6,3 +8,93 @@ pub struct MandatePaypal { /// PayPal account PayerID. This identifier uniquely identifies the PayPal customer. pub payer_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct MandatePaypalBuilder { + billing_agreement_id: Option<Option<String>>, + payer_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandatePaypal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandatePaypal>, + builder: MandatePaypalBuilder, + } + + impl Visitor for Place<MandatePaypal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandatePaypalBuilder::deser_default() })) + } + } + + impl MapBuilder for MandatePaypalBuilder { + type Out = MandatePaypal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_agreement_id" => Deserialize::begin(&mut self.billing_agreement_id), + "payer_id" => Deserialize::begin(&mut self.payer_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_agreement_id: Deserialize::default(), payer_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_agreement_id = self.billing_agreement_id.take()?; + let payer_id = self.payer_id.take()?; + + Some(Self::Out { billing_agreement_id, payer_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandatePaypal { + type Builder = MandatePaypalBuilder; + } + + impl FromValueOpt for MandatePaypal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandatePaypalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_agreement_id" => b.billing_agreement_id = Some(FromValueOpt::from_value(v)?), + "payer_id" => b.payer_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_sepa_debit.rs b/generated/stripe_shared/src/mandate_sepa_debit.rs index 103e31afb..0d47f1876 100644 --- a/generated/stripe_shared/src/mandate_sepa_debit.rs +++ b/generated/stripe_shared/src/mandate_sepa_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateSepaDebit { /// The unique reference of the mandate. pub reference: String, @@ -6,3 +8,93 @@ pub struct MandateSepaDebit { /// This URL generally contains sensitive information about the customer and should be shared with them exclusively. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct MandateSepaDebitBuilder { + reference: Option<String>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateSepaDebit>, + builder: MandateSepaDebitBuilder, + } + + impl Visitor for Place<MandateSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateSepaDebitBuilder { + type Out = MandateSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reference = self.reference.take()?; + let url = self.url.take()?; + + Some(Self::Out { reference, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateSepaDebit { + type Builder = MandateSepaDebitBuilder; + } + + impl FromValueOpt for MandateSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_single_use.rs b/generated/stripe_shared/src/mandate_single_use.rs index 8cabcb79e..2a7dc9ef1 100644 --- a/generated/stripe_shared/src/mandate_single_use.rs +++ b/generated/stripe_shared/src/mandate_single_use.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct MandateSingleUse { /// The amount of the payment on a single use mandate. pub amount: i64, /// The currency of the payment on a single use mandate. pub currency: stripe_types::Currency, } +#[cfg(feature = "min-ser")] +pub struct MandateSingleUseBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateSingleUse { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<MandateSingleUse>, + builder: MandateSingleUseBuilder, + } + + impl Visitor for Place<MandateSingleUse> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateSingleUseBuilder::deser_default() })) + } + } + + impl MapBuilder for MandateSingleUseBuilder { + type Out = MandateSingleUse; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + + Some(Self::Out { amount, currency }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for MandateSingleUse { + type Builder = MandateSingleUseBuilder; + } + + impl FromValueOpt for MandateSingleUse { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateSingleUseBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/mandate_us_bank_account.rs b/generated/stripe_shared/src/mandate_us_bank_account.rs index 7616c7013..c73a6ea2d 100644 --- a/generated/stripe_shared/src/mandate_us_bank_account.rs +++ b/generated/stripe_shared/src/mandate_us_bank_account.rs @@ -1,58 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct MandateUsBankAccount { - /// Mandate collection method - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: Option<MandateUsBankAccountCollectionMethod>, -} -/// Mandate collection method -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum MandateUsBankAccountCollectionMethod { - Paper, -} -impl MandateUsBankAccountCollectionMethod { - pub fn as_str(self) -> &'static str { - use MandateUsBankAccountCollectionMethod::*; - match self { - Paper => "paper", +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +pub struct MandateUsBankAccount {} +#[cfg(feature = "min-ser")] +pub struct MandateUsBankAccountBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for MandateUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) } } -} -impl std::str::FromStr for MandateUsBankAccountCollectionMethod { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use MandateUsBankAccountCollectionMethod::*; - match s { - "paper" => Ok(Paper), - _ => Err(()), + struct Builder<'a> { + out: &'a mut Option<MandateUsBankAccount>, + builder: MandateUsBankAccountBuilder, + } + + impl Visitor for Place<MandateUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: MandateUsBankAccountBuilder::deser_default() })) } } -} -impl std::fmt::Display for MandateUsBankAccountCollectionMethod { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + + impl MapBuilder for MandateUsBankAccountBuilder { + type Out = MandateUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } } -} -impl std::fmt::Debug for MandateUsBankAccountCollectionMethod { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } } -} -impl serde::Serialize for MandateUsBankAccountCollectionMethod { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) + + impl ObjectDeser for MandateUsBankAccount { + type Builder = MandateUsBankAccountBuilder; } -} -impl<'de> serde::Deserialize<'de> for MandateUsBankAccountCollectionMethod { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for MandateUsBankAccountCollectionMethod") - }) + + impl FromValueOpt for MandateUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } } -} +}; diff --git a/generated/stripe_shared/src/mod.rs b/generated/stripe_shared/src/mod.rs index 5f938b9c6..f6cb3ce3a 100644 --- a/generated/stripe_shared/src/mod.rs +++ b/generated/stripe_shared/src/mod.rs @@ -8,15 +8,14 @@ //! reexported. extern crate self as stripe_shared; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); #[doc(hidden)] pub mod account; #[doc(inline)] pub use account::*; #[doc(hidden)] -pub mod account_annual_revenue; -#[doc(inline)] -pub use account_annual_revenue::*; -#[doc(hidden)] pub mod account_bacs_debit_payments_settings; #[doc(inline)] pub use account_bacs_debit_payments_settings::*; @@ -61,10 +60,6 @@ pub mod account_future_requirements; #[doc(inline)] pub use account_future_requirements::*; #[doc(hidden)] -pub mod account_invoices_settings; -#[doc(inline)] -pub use account_invoices_settings::*; -#[doc(hidden)] pub mod account_monthly_estimated_revenue; #[doc(inline)] pub use account_monthly_estimated_revenue::*; @@ -189,10 +184,6 @@ pub mod charge_transfer_data; #[doc(inline)] pub use charge_transfer_data::*; #[doc(hidden)] -pub mod connect_account_reference; -#[doc(inline)] -pub use connect_account_reference::*; -#[doc(hidden)] pub mod connect_collection_transfer; #[doc(inline)] pub use connect_collection_transfer::*; @@ -277,10 +268,6 @@ pub mod customer_balance_resource_cash_balance_transaction_resource_refunded_fro #[doc(inline)] pub use customer_balance_resource_cash_balance_transaction_resource_refunded_from_payment_transaction::*; #[doc(hidden)] -pub mod customer_balance_resource_cash_balance_transaction_resource_transferred_to_balance; -#[doc(inline)] -pub use customer_balance_resource_cash_balance_transaction_resource_transferred_to_balance::*; -#[doc(hidden)] pub mod customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction; #[doc(inline)] pub use customer_balance_resource_cash_balance_transaction_resource_unapplied_from_payment_transaction::*; @@ -365,10 +352,6 @@ pub mod deleted_test_helpers_test_clock; #[doc(inline)] pub use deleted_test_helpers_test_clock::*; #[doc(hidden)] -pub mod destination_details_unimplemented; -#[doc(inline)] -pub use destination_details_unimplemented::*; -#[doc(hidden)] pub mod discount; #[doc(inline)] pub use discount::*; @@ -1093,14 +1076,6 @@ pub mod payment_intent_next_action_redirect_to_url; #[doc(inline)] pub use payment_intent_next_action_redirect_to_url::*; #[doc(hidden)] -pub mod payment_intent_next_action_swish_handle_redirect_or_display_qr_code; -#[doc(inline)] -pub use payment_intent_next_action_swish_handle_redirect_or_display_qr_code::*; -#[doc(hidden)] -pub mod payment_intent_next_action_swish_qr_code; -#[doc(inline)] -pub use payment_intent_next_action_swish_qr_code::*; -#[doc(hidden)] pub mod payment_intent_next_action_verify_with_microdeposits; #[doc(inline)] pub use payment_intent_next_action_verify_with_microdeposits::*; @@ -1157,10 +1132,6 @@ pub mod payment_intent_payment_method_options_sepa_debit; #[doc(inline)] pub use payment_intent_payment_method_options_sepa_debit::*; #[doc(hidden)] -pub mod payment_intent_payment_method_options_swish; -#[doc(inline)] -pub use payment_intent_payment_method_options_swish::*; -#[doc(hidden)] pub mod payment_intent_payment_method_options_us_bank_account; #[doc(inline)] pub use payment_intent_payment_method_options_us_bank_account::*; @@ -1185,10 +1156,6 @@ pub mod payment_links_resource_automatic_tax; #[doc(inline)] pub use payment_links_resource_automatic_tax::*; #[doc(hidden)] -pub mod payment_links_resource_completed_sessions; -#[doc(inline)] -pub use payment_links_resource_completed_sessions::*; -#[doc(hidden)] pub mod payment_links_resource_completion_behavior_confirmation_page; #[doc(inline)] pub use payment_links_resource_completion_behavior_confirmation_page::*; @@ -1245,18 +1212,10 @@ pub mod payment_links_resource_payment_intent_data; #[doc(inline)] pub use payment_links_resource_payment_intent_data::*; #[doc(hidden)] -pub mod payment_links_resource_payment_method_reuse_agreement; -#[doc(inline)] -pub use payment_links_resource_payment_method_reuse_agreement::*; -#[doc(hidden)] pub mod payment_links_resource_phone_number_collection; #[doc(inline)] pub use payment_links_resource_phone_number_collection::*; #[doc(hidden)] -pub mod payment_links_resource_restrictions; -#[doc(inline)] -pub use payment_links_resource_restrictions::*; -#[doc(hidden)] pub mod payment_links_resource_shipping_address_collection; #[doc(inline)] pub use payment_links_resource_shipping_address_collection::*; @@ -1269,10 +1228,6 @@ pub mod payment_links_resource_subscription_data; #[doc(inline)] pub use payment_links_resource_subscription_data::*; #[doc(hidden)] -pub mod payment_links_resource_subscription_data_invoice_settings; -#[doc(inline)] -pub use payment_links_resource_subscription_data_invoice_settings::*; -#[doc(hidden)] pub mod payment_links_resource_tax_id_collection; #[doc(inline)] pub use payment_links_resource_tax_id_collection::*; @@ -1585,10 +1540,6 @@ pub mod payment_method_details_stripe_account; #[doc(inline)] pub use payment_method_details_stripe_account::*; #[doc(hidden)] -pub mod payment_method_details_swish; -#[doc(inline)] -pub use payment_method_details_swish::*; -#[doc(hidden)] pub mod payment_method_details_us_bank_account; #[doc(inline)] pub use payment_method_details_us_bank_account::*; @@ -1753,10 +1704,6 @@ pub mod payment_method_options_sofort; #[doc(inline)] pub use payment_method_options_sofort::*; #[doc(hidden)] -pub mod payment_method_options_us_bank_account_mandate_options; -#[doc(inline)] -pub use payment_method_options_us_bank_account_mandate_options::*; -#[doc(hidden)] pub mod payment_method_options_wechat_pay; #[doc(inline)] pub use payment_method_options_wechat_pay::*; @@ -1801,10 +1748,6 @@ pub mod payment_method_sofort; #[doc(inline)] pub use payment_method_sofort::*; #[doc(hidden)] -pub mod payment_method_swish; -#[doc(inline)] -pub use payment_method_swish::*; -#[doc(hidden)] pub mod payment_method_us_bank_account; #[doc(inline)] pub use payment_method_us_bank_account::*; @@ -1969,18 +1912,6 @@ pub mod refund; #[doc(inline)] pub use refund::*; #[doc(hidden)] -pub mod refund_destination_details; -#[doc(inline)] -pub use refund_destination_details::*; -#[doc(hidden)] -pub mod refund_destination_details_card; -#[doc(inline)] -pub use refund_destination_details_card::*; -#[doc(hidden)] -pub mod refund_destination_details_generic; -#[doc(inline)] -pub use refund_destination_details_generic::*; -#[doc(hidden)] pub mod refund_next_action; #[doc(inline)] pub use refund_next_action::*; @@ -2357,10 +2288,6 @@ pub mod subscription_transfer_data; #[doc(inline)] pub use subscription_transfer_data::*; #[doc(hidden)] -pub mod subscriptions_resource_billing_cycle_anchor_config; -#[doc(inline)] -pub use subscriptions_resource_billing_cycle_anchor_config::*; -#[doc(hidden)] pub mod subscriptions_resource_pause_collection; #[doc(inline)] pub use subscriptions_resource_pause_collection::*; @@ -2393,10 +2320,6 @@ pub mod tax_deducted_at_source; #[doc(inline)] pub use tax_deducted_at_source::*; #[doc(hidden)] -pub mod tax_i_ds_owner; -#[doc(inline)] -pub use tax_i_ds_owner::*; -#[doc(hidden)] pub mod tax_id; #[doc(inline)] pub use tax_id::*; diff --git a/generated/stripe_shared/src/networks.rs b/generated/stripe_shared/src/networks.rs index 2e272069d..a5047e957 100644 --- a/generated/stripe_shared/src/networks.rs +++ b/generated/stripe_shared/src/networks.rs @@ -1,8 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Networks { /// All available networks for the card. pub available: Vec<String>, - /// The preferred network for co-branded cards. - /// Can be `cartes_bancaires`, `mastercard`, `visa` or `invalid_preference` if requested network is not valid for the card. + /// The preferred network for the card. pub preferred: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct NetworksBuilder { + available: Option<Vec<String>>, + preferred: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Networks { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Networks>, + builder: NetworksBuilder, + } + + impl Visitor for Place<Networks> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: NetworksBuilder::deser_default() })) + } + } + + impl MapBuilder for NetworksBuilder { + type Out = Networks; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available" => Deserialize::begin(&mut self.available), + "preferred" => Deserialize::begin(&mut self.preferred), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default(), preferred: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available = self.available.take()?; + let preferred = self.preferred.take()?; + + Some(Self::Out { available, preferred }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Networks { + type Builder = NetworksBuilder; + } + + impl FromValueOpt for Networks { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = NetworksBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available" => b.available = Some(FromValueOpt::from_value(v)?), + "preferred" => b.preferred = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/notification_event_data.rs b/generated/stripe_shared/src/notification_event_data.rs index b50e482a4..475733957 100644 --- a/generated/stripe_shared/src/notification_event_data.rs +++ b/generated/stripe_shared/src/notification_event_data.rs @@ -1,11 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct NotificationEventData { /// Object containing the API resource relevant to the event. /// For example, an `invoice.created` event will have a full [invoice object](https://stripe.com/docs/api#invoice_object) as the value of the object key. - pub object: serde_json::Value, + pub object: stripe_types::Value, /// Object containing the names of the updated attributes and their values prior to the event (only included in events of type `*.updated`). /// If an array attribute has any updated elements, this object contains the entire array. /// In Stripe API versions 2017-04-06 or earlier, an updated array attribute in this object includes only the updated array elements. - #[serde(skip_serializing_if = "Option::is_none")] - pub previous_attributes: Option<serde_json::Value>, + pub previous_attributes: Option<stripe_types::Value>, } +#[cfg(feature = "min-ser")] +pub struct NotificationEventDataBuilder { + object: Option<stripe_types::Value>, + previous_attributes: Option<Option<stripe_types::Value>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for NotificationEventData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<NotificationEventData>, + builder: NotificationEventDataBuilder, + } + + impl Visitor for Place<NotificationEventData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: NotificationEventDataBuilder::deser_default() })) + } + } + + impl MapBuilder for NotificationEventDataBuilder { + type Out = NotificationEventData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "object" => Deserialize::begin(&mut self.object), + "previous_attributes" => Deserialize::begin(&mut self.previous_attributes), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { object: Deserialize::default(), previous_attributes: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let object = self.object.take()?; + let previous_attributes = self.previous_attributes.take()?; + + Some(Self::Out { object, previous_attributes }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for NotificationEventData { + type Builder = NotificationEventDataBuilder; + } + + impl FromValueOpt for NotificationEventData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = NotificationEventDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "previous_attributes" => b.previous_attributes = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/notification_event_request.rs b/generated/stripe_shared/src/notification_event_request.rs index a4b778196..b35d112d7 100644 --- a/generated/stripe_shared/src/notification_event_request.rs +++ b/generated/stripe_shared/src/notification_event_request.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct NotificationEventRequest { /// ID of the API request that caused the event. /// If null, the event was automatic (e.g., Stripe's automatic subscription handling). @@ -8,3 +10,93 @@ pub struct NotificationEventRequest { /// *Note: This property is populated only for events on or after May 23, 2017*. pub idempotency_key: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct NotificationEventRequestBuilder { + id: Option<Option<String>>, + idempotency_key: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for NotificationEventRequest { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<NotificationEventRequest>, + builder: NotificationEventRequestBuilder, + } + + impl Visitor for Place<NotificationEventRequest> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: NotificationEventRequestBuilder::deser_default() })) + } + } + + impl MapBuilder for NotificationEventRequestBuilder { + type Out = NotificationEventRequest; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "idempotency_key" => Deserialize::begin(&mut self.idempotency_key), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), idempotency_key: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let idempotency_key = self.idempotency_key.take()?; + + Some(Self::Out { id, idempotency_key }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for NotificationEventRequest { + type Builder = NotificationEventRequestBuilder; + } + + impl FromValueOpt for NotificationEventRequest { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = NotificationEventRequestBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "idempotency_key" => b.idempotency_key = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/offline_acceptance.rs b/generated/stripe_shared/src/offline_acceptance.rs index b83820747..3c61e836e 100644 --- a/generated/stripe_shared/src/offline_acceptance.rs +++ b/generated/stripe_shared/src/offline_acceptance.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct OfflineAcceptance {} +#[cfg(feature = "min-ser")] +pub struct OfflineAcceptanceBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for OfflineAcceptance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<OfflineAcceptance>, + builder: OfflineAcceptanceBuilder, + } + + impl Visitor for Place<OfflineAcceptance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: OfflineAcceptanceBuilder::deser_default() })) + } + } + + impl MapBuilder for OfflineAcceptanceBuilder { + type Out = OfflineAcceptance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for OfflineAcceptance { + type Builder = OfflineAcceptanceBuilder; + } + + impl FromValueOpt for OfflineAcceptance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = OfflineAcceptanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/online_acceptance.rs b/generated/stripe_shared/src/online_acceptance.rs index e8a780018..3a24ea111 100644 --- a/generated/stripe_shared/src/online_acceptance.rs +++ b/generated/stripe_shared/src/online_acceptance.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct OnlineAcceptance { /// The customer accepts the mandate from this IP address. pub ip_address: Option<String>, /// The customer accepts the mandate using the user agent of the browser. pub user_agent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct OnlineAcceptanceBuilder { + ip_address: Option<Option<String>>, + user_agent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for OnlineAcceptance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<OnlineAcceptance>, + builder: OnlineAcceptanceBuilder, + } + + impl Visitor for Place<OnlineAcceptance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: OnlineAcceptanceBuilder::deser_default() })) + } + } + + impl MapBuilder for OnlineAcceptanceBuilder { + type Out = OnlineAcceptance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ip_address" => Deserialize::begin(&mut self.ip_address), + "user_agent" => Deserialize::begin(&mut self.user_agent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ip_address: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ip_address = self.ip_address.take()?; + let user_agent = self.user_agent.take()?; + + Some(Self::Out { ip_address, user_agent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for OnlineAcceptance { + type Builder = OnlineAcceptanceBuilder; + } + + impl FromValueOpt for OnlineAcceptance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = OnlineAcceptanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ip_address" => b.ip_address = Some(FromValueOpt::from_value(v)?), + "user_agent" => b.user_agent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/package_dimensions.rs b/generated/stripe_shared/src/package_dimensions.rs index 384074024..7f0600928 100644 --- a/generated/stripe_shared/src/package_dimensions.rs +++ b/generated/stripe_shared/src/package_dimensions.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PackageDimensions { /// Height, in inches. pub height: f64, @@ -9,3 +11,101 @@ pub struct PackageDimensions { /// Width, in inches. pub width: f64, } +#[cfg(feature = "min-ser")] +pub struct PackageDimensionsBuilder { + height: Option<f64>, + length: Option<f64>, + weight: Option<f64>, + width: Option<f64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PackageDimensions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PackageDimensions>, + builder: PackageDimensionsBuilder, + } + + impl Visitor for Place<PackageDimensions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PackageDimensionsBuilder::deser_default() })) + } + } + + impl MapBuilder for PackageDimensionsBuilder { + type Out = PackageDimensions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "height" => Deserialize::begin(&mut self.height), + "length" => Deserialize::begin(&mut self.length), + "weight" => Deserialize::begin(&mut self.weight), + "width" => Deserialize::begin(&mut self.width), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { height: Deserialize::default(), length: Deserialize::default(), weight: Deserialize::default(), width: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let height = self.height.take()?; + let length = self.length.take()?; + let weight = self.weight.take()?; + let width = self.width.take()?; + + Some(Self::Out { height, length, weight, width }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PackageDimensions { + type Builder = PackageDimensionsBuilder; + } + + impl FromValueOpt for PackageDimensions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PackageDimensionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "height" => b.height = Some(FromValueOpt::from_value(v)?), + "length" => b.length = Some(FromValueOpt::from_value(v)?), + "weight" => b.weight = Some(FromValueOpt::from_value(v)?), + "width" => b.width = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_flows_amount_details.rs b/generated/stripe_shared/src/payment_flows_amount_details.rs index 0ba1b5d1e..9ae35fa8b 100644 --- a/generated/stripe_shared/src/payment_flows_amount_details.rs +++ b/generated/stripe_shared/src/payment_flows_amount_details.rs @@ -1,5 +1,92 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsAmountDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub tip: Option<stripe_shared::PaymentFlowsAmountDetailsResourceTip>, } +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsAmountDetailsBuilder { + tip: Option<Option<stripe_shared::PaymentFlowsAmountDetailsResourceTip>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsAmountDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsAmountDetails>, + builder: PaymentFlowsAmountDetailsBuilder, + } + + impl Visitor for Place<PaymentFlowsAmountDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsAmountDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsAmountDetailsBuilder { + type Out = PaymentFlowsAmountDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "tip" => Deserialize::begin(&mut self.tip), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tip: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let tip = self.tip.take()?; + + Some(Self::Out { tip }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsAmountDetails { + type Builder = PaymentFlowsAmountDetailsBuilder; + } + + impl FromValueOpt for PaymentFlowsAmountDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsAmountDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "tip" => b.tip = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_flows_amount_details_resource_tip.rs b/generated/stripe_shared/src/payment_flows_amount_details_resource_tip.rs index 9bb050a35..1675805a0 100644 --- a/generated/stripe_shared/src/payment_flows_amount_details_resource_tip.rs +++ b/generated/stripe_shared/src/payment_flows_amount_details_resource_tip.rs @@ -1,6 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsAmountDetailsResourceTip { /// Portion of the amount that corresponds to a tip. - #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsAmountDetailsResourceTipBuilder { + amount: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsAmountDetailsResourceTip { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsAmountDetailsResourceTip>, + builder: PaymentFlowsAmountDetailsResourceTipBuilder, + } + + impl Visitor for Place<PaymentFlowsAmountDetailsResourceTip> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsAmountDetailsResourceTipBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsAmountDetailsResourceTipBuilder { + type Out = PaymentFlowsAmountDetailsResourceTip; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + + Some(Self::Out { amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsAmountDetailsResourceTip { + type Builder = PaymentFlowsAmountDetailsResourceTipBuilder; + } + + impl FromValueOpt for PaymentFlowsAmountDetailsResourceTip { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsAmountDetailsResourceTipBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_flows_automatic_payment_methods_payment_intent.rs b/generated/stripe_shared/src/payment_flows_automatic_payment_methods_payment_intent.rs index 1c30291e7..8acb75a28 100644 --- a/generated/stripe_shared/src/payment_flows_automatic_payment_methods_payment_intent.rs +++ b/generated/stripe_shared/src/payment_flows_automatic_payment_methods_payment_intent.rs @@ -1,14 +1,105 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsAutomaticPaymentMethodsPaymentIntent { /// Controls whether this PaymentIntent will accept redirect-based payment methods. /// /// Redirect-based payment methods may require your customer to be redirected to a payment method's app or site for authentication or additional steps. /// To [confirm](https://stripe.com/docs/api/payment_intents/confirm) this PaymentIntent, you may be required to provide a `return_url` to redirect customers back to your site after they authenticate or complete the payment. - #[serde(skip_serializing_if = "Option::is_none")] pub allow_redirects: Option<PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects>, /// Automatically calculates compatible payment methods pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder { + allow_redirects: Option<Option<PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects>>, + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsAutomaticPaymentMethodsPaymentIntent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsAutomaticPaymentMethodsPaymentIntent>, + builder: PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder, + } + + impl Visitor for Place<PaymentFlowsAutomaticPaymentMethodsPaymentIntent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder { + type Out = PaymentFlowsAutomaticPaymentMethodsPaymentIntent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allow_redirects" => Deserialize::begin(&mut self.allow_redirects), + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allow_redirects: Deserialize::default(), enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allow_redirects = self.allow_redirects.take()?; + let enabled = self.enabled.take()?; + + Some(Self::Out { allow_redirects, enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsAutomaticPaymentMethodsPaymentIntent { + type Builder = PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder; + } + + impl FromValueOpt for PaymentFlowsAutomaticPaymentMethodsPaymentIntent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allow_redirects" => b.allow_redirects = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls whether this PaymentIntent will accept redirect-based payment methods. /// /// Redirect-based payment methods may require your customer to be redirected to a payment method's app or site for authentication or additional steps. @@ -58,16 +149,28 @@ impl serde::Serialize for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowR serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects -{ +impl<'de> serde::Deserialize<'de> for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects); diff --git a/generated/stripe_shared/src/payment_flows_automatic_payment_methods_setup_intent.rs b/generated/stripe_shared/src/payment_flows_automatic_payment_methods_setup_intent.rs index 07be5f69a..b7abe681b 100644 --- a/generated/stripe_shared/src/payment_flows_automatic_payment_methods_setup_intent.rs +++ b/generated/stripe_shared/src/payment_flows_automatic_payment_methods_setup_intent.rs @@ -1,14 +1,105 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsAutomaticPaymentMethodsSetupIntent { /// Controls whether this SetupIntent will accept redirect-based payment methods. /// /// Redirect-based payment methods may require your customer to be redirected to a payment method's app or site for authentication or additional steps. /// To [confirm](https://stripe.com/docs/api/setup_intents/confirm) this SetupIntent, you may be required to provide a `return_url` to redirect customers back to your site after they authenticate or complete the setup. - #[serde(skip_serializing_if = "Option::is_none")] pub allow_redirects: Option<PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects>, /// Automatically calculates compatible payment methods pub enabled: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder { + allow_redirects: Option<Option<PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects>>, + enabled: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsAutomaticPaymentMethodsSetupIntent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsAutomaticPaymentMethodsSetupIntent>, + builder: PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder, + } + + impl Visitor for Place<PaymentFlowsAutomaticPaymentMethodsSetupIntent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder { + type Out = PaymentFlowsAutomaticPaymentMethodsSetupIntent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allow_redirects" => Deserialize::begin(&mut self.allow_redirects), + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allow_redirects: Deserialize::default(), enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allow_redirects = self.allow_redirects.take()?; + let enabled = self.enabled.take()?; + + Some(Self::Out { allow_redirects, enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsAutomaticPaymentMethodsSetupIntent { + type Builder = PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder; + } + + impl FromValueOpt for PaymentFlowsAutomaticPaymentMethodsSetupIntent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allow_redirects" => b.allow_redirects = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls whether this SetupIntent will accept redirect-based payment methods. /// /// Redirect-based payment methods may require your customer to be redirected to a payment method's app or site for authentication or additional steps. @@ -62,10 +153,24 @@ impl<'de> serde::Deserialize<'de> for PaymentFlowsAutomaticPaymentMethodsSetupIn fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects); diff --git a/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay.rs b/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay.rs index 2262cd443..5e50c3059 100644 --- a/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay.rs +++ b/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsPrivatePaymentMethodsAlipay {} +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsPrivatePaymentMethodsAlipayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsPrivatePaymentMethodsAlipay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsAlipay>, + builder: PaymentFlowsPrivatePaymentMethodsAlipayBuilder, + } + + impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsAlipay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsPrivatePaymentMethodsAlipayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsPrivatePaymentMethodsAlipayBuilder { + type Out = PaymentFlowsPrivatePaymentMethodsAlipay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsAlipay { + type Builder = PaymentFlowsPrivatePaymentMethodsAlipayBuilder; + } + + impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsAlipay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsPrivatePaymentMethodsAlipayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay_details.rs b/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay_details.rs index 01119c284..1248d40ca 100644 --- a/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay_details.rs +++ b/generated/stripe_shared/src/payment_flows_private_payment_methods_alipay_details.rs @@ -1,8 +1,9 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsPrivatePaymentMethodsAlipayDetails { /// Uniquely identifies this particular Alipay account. /// You can use this attribute to check whether two Alipay accounts are the same. - #[serde(skip_serializing_if = "Option::is_none")] pub buyer_id: Option<String>, /// Uniquely identifies this particular Alipay account. /// You can use this attribute to check whether two Alipay accounts are the same. @@ -10,3 +11,97 @@ pub struct PaymentFlowsPrivatePaymentMethodsAlipayDetails { /// Transaction ID of this particular Alipay transaction. pub transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder { + buyer_id: Option<Option<String>>, + fingerprint: Option<Option<String>>, + transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsPrivatePaymentMethodsAlipayDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsAlipayDetails>, + builder: PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder, + } + + impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsAlipayDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder { + type Out = PaymentFlowsPrivatePaymentMethodsAlipayDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "buyer_id" => Deserialize::begin(&mut self.buyer_id), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { buyer_id: Deserialize::default(), fingerprint: Deserialize::default(), transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let buyer_id = self.buyer_id.take()?; + let fingerprint = self.fingerprint.take()?; + let transaction_id = self.transaction_id.take()?; + + Some(Self::Out { buyer_id, fingerprint, transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsAlipayDetails { + type Builder = PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder; + } + + impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsAlipayDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "buyer_id" => b.buyer_id = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_extended_authorization_extended_authorization.rs b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_extended_authorization_extended_authorization.rs index d3055edc0..6a40fab89 100644 --- a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_extended_authorization_extended_authorization.rs +++ b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_extended_authorization_extended_authorization.rs @@ -1,13 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization { /// Indicates whether or not the capture window is extended beyond the standard authorization. -pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus, - + pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus, +} +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder { + status: Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization>, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder, + } + + impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder { + type Out = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let status = self.status.take()?; + + Some(Self::Out { status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization { + type Builder = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder; + } + + impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates whether or not the capture window is extended beyond the standard authorization. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus -{ +pub enum PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus { Disabled, Enabled, } @@ -15,9 +104,8 @@ impl PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesEx pub fn as_str(self) -> &'static str { use PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus::*; match self { -Disabled => "disabled", -Enabled => "enabled", - + Disabled => "disabled", + Enabled => "enabled", } } } @@ -27,10 +115,9 @@ impl std::str::FromStr for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResour fn from_str(s: &str) -> Result<Self, Self::Err> { use PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus::*; match s { - "disabled" => Ok(Disabled), -"enabled" => Ok(Enabled), -_ => Err(()) - + "disabled" => Ok(Disabled), + "enabled" => Ok(Enabled), + _ => Err(()), } } } @@ -46,7 +133,10 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource } } impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } @@ -54,6 +144,25 @@ impl<'de> serde::Deserialize<'de> for PaymentFlowsPrivatePaymentMethodsCardDetai fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus")) + Self::from_str(&s) + .map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus); diff --git a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_incremental_authorization_incremental_authorization.rs b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_incremental_authorization_incremental_authorization.rs index cbdb1896b..340c28e0a 100644 --- a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_incremental_authorization_incremental_authorization.rs +++ b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_incremental_authorization_incremental_authorization.rs @@ -1,13 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization { /// Indicates whether or not the incremental authorization feature is supported. -pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus, - + pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus, +} +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder { + status: Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization>, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder, + } + + impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder { + type Out = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let status = self.status.take()?; + + Some(Self::Out { status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization { + type Builder = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder; + } + + impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates whether or not the incremental authorization feature is supported. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus -{ +pub enum PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus { Available, Unavailable, } @@ -15,9 +104,8 @@ impl PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIn pub fn as_str(self) -> &'static str { use PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus::*; match self { -Available => "available", -Unavailable => "unavailable", - + Available => "available", + Unavailable => "unavailable", } } } @@ -27,10 +115,9 @@ impl std::str::FromStr for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResour fn from_str(s: &str) -> Result<Self, Self::Err> { use PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus::*; match s { - "available" => Ok(Available), -"unavailable" => Ok(Unavailable), -_ => Err(()) - + "available" => Ok(Available), + "unavailable" => Ok(Unavailable), + _ => Err(()), } } } @@ -46,7 +133,10 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource } } impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } @@ -54,6 +144,25 @@ impl<'de> serde::Deserialize<'de> for PaymentFlowsPrivatePaymentMethodsCardDetai fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus")) + Self::from_str(&s) + .map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus); diff --git a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_overcapture_overcapture.rs b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_overcapture_overcapture.rs index 290a2e869..0ae654473 100644 --- a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_overcapture_overcapture.rs +++ b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_enterprise_features_overcapture_overcapture.rs @@ -1,15 +1,105 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture { /// The maximum amount that can be captured. -pub maximum_amount_capturable: i64, + pub maximum_amount_capturable: i64, /// Indicates whether or not the authorized amount can be over-captured. -pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus, - + pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus, +} +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder { + maximum_amount_capturable: Option<i64>, + status: Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture>, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder, + } + + impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder { + type Out = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "maximum_amount_capturable" => Deserialize::begin(&mut self.maximum_amount_capturable), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum_amount_capturable: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let maximum_amount_capturable = self.maximum_amount_capturable.take()?; + let status = self.status.take()?; + + Some(Self::Out { maximum_amount_capturable, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture { + type Builder = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder; + } + + impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "maximum_amount_capturable" => b.maximum_amount_capturable = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates whether or not the authorized amount can be over-captured. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus -{ +pub enum PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus { Available, Unavailable, } @@ -17,9 +107,8 @@ impl PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOv pub fn as_str(self) -> &'static str { use PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus::*; match self { -Available => "available", -Unavailable => "unavailable", - + Available => "available", + Unavailable => "unavailable", } } } @@ -29,10 +118,9 @@ impl std::str::FromStr for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResour fn from_str(s: &str) -> Result<Self, Self::Err> { use PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus::*; match s { - "available" => Ok(Available), -"unavailable" => Ok(Unavailable), -_ => Err(()) - + "available" => Ok(Available), + "unavailable" => Ok(Unavailable), + _ => Err(()), } } } @@ -48,7 +136,10 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource } } impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { serializer.serialize_str(self.as_str()) } } @@ -59,3 +150,21 @@ impl<'de> serde::Deserialize<'de> for PaymentFlowsPrivatePaymentMethodsCardDetai Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus); diff --git a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_multicapture.rs b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_multicapture.rs index 02d9c03bd..f1f4bf7a1 100644 --- a/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_multicapture.rs +++ b/generated/stripe_shared/src/payment_flows_private_payment_methods_card_details_api_resource_multicapture.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture { /// Indicates whether or not multiple captures are supported. pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus, } +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder { + status: Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture>, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder, + } + + impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder { + type Out = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let status = self.status.take()?; + + Some(Self::Out { status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture { + type Builder = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder; + } + + impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates whether or not multiple captures are supported. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { @@ -19,9 +107,7 @@ impl PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { } } -impl std::str::FromStr - for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus -{ +impl std::str::FromStr for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus::*; @@ -32,9 +118,7 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus -{ +impl std::fmt::Display for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } @@ -45,9 +129,7 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource f.write_str(self.as_str()) } } -impl serde::Serialize - for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus -{ +impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -55,12 +137,28 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus -{ +impl<'de> serde::Deserialize<'de> for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus); diff --git a/generated/stripe_shared/src/payment_flows_private_payment_methods_klarna_dob.rs b/generated/stripe_shared/src/payment_flows_private_payment_methods_klarna_dob.rs index fe0a52dbf..eb41183a8 100644 --- a/generated/stripe_shared/src/payment_flows_private_payment_methods_klarna_dob.rs +++ b/generated/stripe_shared/src/payment_flows_private_payment_methods_klarna_dob.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentFlowsPrivatePaymentMethodsKlarnaDob { /// The day of birth, between 1 and 31. pub day: Option<i64>, @@ -7,3 +9,97 @@ pub struct PaymentFlowsPrivatePaymentMethodsKlarnaDob { /// The four-digit year of birth. pub year: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder { + day: Option<Option<i64>>, + month: Option<Option<i64>>, + year: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentFlowsPrivatePaymentMethodsKlarnaDob { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentFlowsPrivatePaymentMethodsKlarnaDob>, + builder: PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder, + } + + impl Visitor for Place<PaymentFlowsPrivatePaymentMethodsKlarnaDob> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder { + type Out = PaymentFlowsPrivatePaymentMethodsKlarnaDob; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day" => Deserialize::begin(&mut self.day), + "month" => Deserialize::begin(&mut self.month), + "year" => Deserialize::begin(&mut self.year), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { day: Deserialize::default(), month: Deserialize::default(), year: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let day = self.day.take()?; + let month = self.month.take()?; + let year = self.year.take()?; + + Some(Self::Out { day, month, year }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentFlowsPrivatePaymentMethodsKlarnaDob { + type Builder = PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder; + } + + impl FromValueOpt for PaymentFlowsPrivatePaymentMethodsKlarnaDob { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day" => b.day = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "year" => b.year = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent.rs b/generated/stripe_shared/src/payment_intent.rs index b89f4ae14..4992e3a78 100644 --- a/generated/stripe_shared/src/payment_intent.rs +++ b/generated/stripe_shared/src/payment_intent.rs @@ -11,7 +11,9 @@ /// Related guide: [Payment Intents API](https://stripe.com/docs/payments/payment-intents) /// /// For more details see <<https://stripe.com/docs/api/payment_intents/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntent { /// Amount intended to be collected by this PaymentIntent. /// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). @@ -20,7 +22,6 @@ pub struct PaymentIntent { pub amount: i64, /// Amount that can be captured from this PaymentIntent. pub amount_capturable: i64, - #[serde(skip_serializing_if = "Option::is_none")] pub amount_details: Option<stripe_shared::PaymentFlowsAmountDetails>, /// Amount that this PaymentIntent collects. pub amount_received: i64, @@ -31,8 +32,7 @@ pub struct PaymentIntent { /// For more information, see the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts). pub application_fee_amount: Option<i64>, /// Settings to configure compatible payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). - pub automatic_payment_methods: - Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>, + pub automatic_payment_methods: Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>, /// Populated when `status` is `canceled`, this is the time at which the PaymentIntent was canceled. /// Measured in seconds since the Unix epoch. pub canceled_at: Option<stripe_types::Timestamp>, @@ -48,7 +48,6 @@ pub struct PaymentIntent { /// /// Refer to our docs to [accept a payment](https://stripe.com/docs/payments/accept-a-payment?ui=elements) and learn about how `client_secret` should be handled. pub client_secret: Option<String>, - /// Describes whether we can confirm this PaymentIntent automatically, or if it requires customer action to confirm the payment. pub confirmation_method: stripe_shared::PaymentIntentConfirmationMethod, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -86,8 +85,7 @@ pub struct PaymentIntent { /// ID of the payment method used in this PaymentIntent. pub payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>, /// Information about the payment method configuration used for this PaymentIntent. - pub payment_method_configuration_details: - Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>, + pub payment_method_configuration_details: Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>, /// Payment-method-specific configuration for this PaymentIntent. pub payment_method_options: Option<stripe_shared::PaymentIntentPaymentMethodOptions>, /// The list of payment method types (e.g. card) that this PaymentIntent is allowed to use. @@ -111,9 +109,8 @@ pub struct PaymentIntent { /// This is a legacy field that will be removed in the future. /// It is the ID of the Source object that is associated with this PaymentIntent, if one was supplied. pub source: Option<stripe_types::Expandable<stripe_shared::PaymentSource>>, - /// For card charges, use [statement_descriptor_suffix](https://stripe.com/docs/payments/account/statement-descriptors#dynamic). - /// Otherwise, you can use this value as the complete description of a charge on your customers' statements. - /// It must contain at least one letter and be 1–22 characters long. + /// For non-card charges, you can use this value as the complete description that appears on your customers’ statements. + /// Must contain at least one letter, maximum 22 characters. pub statement_descriptor: Option<String>, /// Provides information about a card payment that customers see on their statements. /// Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. @@ -129,6 +126,324 @@ pub struct PaymentIntent { /// Learn more about the [use case for connected accounts](https://stripe.com/docs/connect/separate-charges-and-transfers). pub transfer_group: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentBuilder { + amount: Option<i64>, + amount_capturable: Option<i64>, + amount_details: Option<Option<stripe_shared::PaymentFlowsAmountDetails>>, + amount_received: Option<i64>, + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + application_fee_amount: Option<Option<i64>>, + automatic_payment_methods: Option<Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>>, + canceled_at: Option<Option<stripe_types::Timestamp>>, + cancellation_reason: Option<Option<PaymentIntentCancellationReason>>, + capture_method: Option<stripe_shared::PaymentIntentCaptureMethod>, + client_secret: Option<Option<String>>, + confirmation_method: Option<stripe_shared::PaymentIntentConfirmationMethod>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + description: Option<Option<String>>, + id: Option<stripe_shared::PaymentIntentId>, + invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + last_payment_error: Option<Option<Box<stripe_shared::ApiErrors>>>, + latest_charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + next_action: Option<Option<stripe_shared::PaymentIntentNextAction>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + payment_method_configuration_details: Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>, + payment_method_options: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptions>>, + payment_method_types: Option<Vec<String>>, + processing: Option<Option<stripe_shared::PaymentIntentProcessing>>, + receipt_email: Option<Option<String>>, + review: Option<Option<stripe_types::Expandable<stripe_shared::Review>>>, + setup_future_usage: Option<Option<stripe_shared::PaymentIntentSetupFutureUsage>>, + shipping: Option<Option<stripe_shared::Shipping>>, + source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>, + statement_descriptor: Option<Option<String>>, + statement_descriptor_suffix: Option<Option<String>>, + status: Option<PaymentIntentStatus>, + transfer_data: Option<Option<stripe_shared::TransferData>>, + transfer_group: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntent>, + builder: PaymentIntentBuilder, + } + + impl Visitor for Place<PaymentIntent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentBuilder { + type Out = PaymentIntent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_capturable" => Deserialize::begin(&mut self.amount_capturable), + "amount_details" => Deserialize::begin(&mut self.amount_details), + "amount_received" => Deserialize::begin(&mut self.amount_received), + "application" => Deserialize::begin(&mut self.application), + "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount), + "automatic_payment_methods" => Deserialize::begin(&mut self.automatic_payment_methods), + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason), + "capture_method" => Deserialize::begin(&mut self.capture_method), + "client_secret" => Deserialize::begin(&mut self.client_secret), + "confirmation_method" => Deserialize::begin(&mut self.confirmation_method), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "description" => Deserialize::begin(&mut self.description), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "last_payment_error" => Deserialize::begin(&mut self.last_payment_error), + "latest_charge" => Deserialize::begin(&mut self.latest_charge), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "next_action" => Deserialize::begin(&mut self.next_action), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "payment_method" => Deserialize::begin(&mut self.payment_method), + "payment_method_configuration_details" => Deserialize::begin(&mut self.payment_method_configuration_details), + "payment_method_options" => Deserialize::begin(&mut self.payment_method_options), + "payment_method_types" => Deserialize::begin(&mut self.payment_method_types), + "processing" => Deserialize::begin(&mut self.processing), + "receipt_email" => Deserialize::begin(&mut self.receipt_email), + "review" => Deserialize::begin(&mut self.review), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "shipping" => Deserialize::begin(&mut self.shipping), + "source" => Deserialize::begin(&mut self.source), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "statement_descriptor_suffix" => Deserialize::begin(&mut self.statement_descriptor_suffix), + "status" => Deserialize::begin(&mut self.status), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + "transfer_group" => Deserialize::begin(&mut self.transfer_group), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_capturable: Deserialize::default(), + amount_details: Deserialize::default(), + amount_received: Deserialize::default(), + application: Deserialize::default(), + application_fee_amount: Deserialize::default(), + automatic_payment_methods: Deserialize::default(), + canceled_at: Deserialize::default(), + cancellation_reason: Deserialize::default(), + capture_method: Deserialize::default(), + client_secret: Deserialize::default(), + confirmation_method: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + description: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + last_payment_error: Deserialize::default(), + latest_charge: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + next_action: Deserialize::default(), + on_behalf_of: Deserialize::default(), + payment_method: Deserialize::default(), + payment_method_configuration_details: Deserialize::default(), + payment_method_options: Deserialize::default(), + payment_method_types: Deserialize::default(), + processing: Deserialize::default(), + receipt_email: Deserialize::default(), + review: Deserialize::default(), + setup_future_usage: Deserialize::default(), + shipping: Deserialize::default(), + source: Deserialize::default(), + statement_descriptor: Deserialize::default(), + statement_descriptor_suffix: Deserialize::default(), + status: Deserialize::default(), + transfer_data: Deserialize::default(), + transfer_group: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_capturable = self.amount_capturable.take()?; + let amount_details = self.amount_details.take()?; + let amount_received = self.amount_received.take()?; + let application = self.application.take()?; + let application_fee_amount = self.application_fee_amount.take()?; + let automatic_payment_methods = self.automatic_payment_methods.take()?; + let canceled_at = self.canceled_at.take()?; + let cancellation_reason = self.cancellation_reason.take()?; + let capture_method = self.capture_method.take()?; + let client_secret = self.client_secret.take()?; + let confirmation_method = self.confirmation_method.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let description = self.description.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let last_payment_error = self.last_payment_error.take()?; + let latest_charge = self.latest_charge.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let next_action = self.next_action.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let payment_method = self.payment_method.take()?; + let payment_method_configuration_details = self.payment_method_configuration_details.take()?; + let payment_method_options = self.payment_method_options.take()?; + let payment_method_types = self.payment_method_types.take()?; + let processing = self.processing.take()?; + let receipt_email = self.receipt_email.take()?; + let review = self.review.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let shipping = self.shipping.take()?; + let source = self.source.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let statement_descriptor_suffix = self.statement_descriptor_suffix.take()?; + let status = self.status.take()?; + let transfer_data = self.transfer_data.take()?; + let transfer_group = self.transfer_group.take()?; + + Some(Self::Out { + amount, + amount_capturable, + amount_details, + amount_received, + application, + application_fee_amount, + automatic_payment_methods, + canceled_at, + cancellation_reason, + capture_method, + client_secret, + confirmation_method, + created, + currency, + customer, + description, + id, + invoice, + last_payment_error, + latest_charge, + livemode, + metadata, + next_action, + on_behalf_of, + payment_method, + payment_method_configuration_details, + payment_method_options, + payment_method_types, + processing, + receipt_email, + review, + setup_future_usage, + shipping, + source, + statement_descriptor, + statement_descriptor_suffix, + status, + transfer_data, + transfer_group, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntent { + type Builder = PaymentIntentBuilder; + } + + impl FromValueOpt for PaymentIntent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_capturable" => b.amount_capturable = Some(FromValueOpt::from_value(v)?), + "amount_details" => b.amount_details = Some(FromValueOpt::from_value(v)?), + "amount_received" => b.amount_received = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "application_fee_amount" => b.application_fee_amount = Some(FromValueOpt::from_value(v)?), + "automatic_payment_methods" => b.automatic_payment_methods = Some(FromValueOpt::from_value(v)?), + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "cancellation_reason" => b.cancellation_reason = Some(FromValueOpt::from_value(v)?), + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "confirmation_method" => b.confirmation_method = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "last_payment_error" => b.last_payment_error = Some(FromValueOpt::from_value(v)?), + "latest_charge" => b.latest_charge = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "next_action" => b.next_action = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "payment_method" => b.payment_method = Some(FromValueOpt::from_value(v)?), + "payment_method_configuration_details" => b.payment_method_configuration_details = Some(FromValueOpt::from_value(v)?), + "payment_method_options" => b.payment_method_options = Some(FromValueOpt::from_value(v)?), + "payment_method_types" => b.payment_method_types = Some(FromValueOpt::from_value(v)?), + "processing" => b.processing = Some(FromValueOpt::from_value(v)?), + "receipt_email" => b.receipt_email = Some(FromValueOpt::from_value(v)?), + "review" => b.review = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "shipping" => b.shipping = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_suffix" => b.statement_descriptor_suffix = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + "transfer_group" => b.transfer_group = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for cancellation of this PaymentIntent, either user-provided (`duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`) or generated by Stripe internally (`failed_invoice`, `void_invoice`, or `automatic`). #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentCancellationReason { @@ -194,11 +509,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentCancellationReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentIntentCancellationReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentCancellationReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentCancellationReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentCancellationReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentCancellationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentCancellationReason); /// Status of this PaymentIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `requires_capture`, `canceled`, or `succeeded`. /// Read more about each PaymentIntent [status](https://stripe.com/docs/payments/intents#intent-statuses). #[derive(Copy, Clone, Eq, PartialEq)] @@ -265,10 +596,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentStatus); impl stripe_types::Object for PaymentIntent { type Id = stripe_shared::PaymentIntentId; fn id(&self) -> &Self::Id { @@ -328,10 +676,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentCaptureMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentCaptureMethod")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentCaptureMethod); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentConfirmationMethod { Automatic, @@ -381,11 +746,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentConfirmationMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentIntentConfirmationMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentConfirmationMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentConfirmationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentConfirmationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentConfirmationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentConfirmationMethod); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentSetupFutureUsage { OffSession, @@ -435,8 +816,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentSetupFutureUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentIntentSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_intent_card_processing.rs b/generated/stripe_shared/src/payment_intent_card_processing.rs index 1ba024f23..3fdacd221 100644 --- a/generated/stripe_shared/src/payment_intent_card_processing.rs +++ b/generated/stripe_shared/src/payment_intent_card_processing.rs @@ -1,5 +1,92 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentCardProcessing { - #[serde(skip_serializing_if = "Option::is_none")] pub customer_notification: Option<stripe_shared::PaymentIntentProcessingCustomerNotification>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentCardProcessingBuilder { + customer_notification: Option<Option<stripe_shared::PaymentIntentProcessingCustomerNotification>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentCardProcessing { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentCardProcessing>, + builder: PaymentIntentCardProcessingBuilder, + } + + impl Visitor for Place<PaymentIntentCardProcessing> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentCardProcessingBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentCardProcessingBuilder { + type Out = PaymentIntentCardProcessing; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "customer_notification" => Deserialize::begin(&mut self.customer_notification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { customer_notification: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let customer_notification = self.customer_notification.take()?; + + Some(Self::Out { customer_notification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentCardProcessing { + type Builder = PaymentIntentCardProcessingBuilder; + } + + impl FromValueOpt for PaymentIntentCardProcessing { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentCardProcessingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "customer_notification" => b.customer_notification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action.rs b/generated/stripe_shared/src/payment_intent_next_action.rs index d9c5c4112..afadeabed 100644 --- a/generated/stripe_shared/src/payment_intent_next_action.rs +++ b/generated/stripe_shared/src/payment_intent_next_action.rs @@ -1,51 +1,212 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextAction { - #[serde(skip_serializing_if = "Option::is_none")] pub alipay_handle_redirect: Option<stripe_shared::PaymentIntentNextActionAlipayHandleRedirect>, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto_display_details: Option<stripe_shared::PaymentIntentNextActionBoleto>, - #[serde(skip_serializing_if = "Option::is_none")] - pub card_await_notification: - Option<stripe_shared::PaymentIntentNextActionCardAwaitNotification>, - #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp_handle_redirect_or_display_qr_code: - Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>, - #[serde(skip_serializing_if = "Option::is_none")] - pub display_bank_transfer_instructions: - Option<stripe_shared::PaymentIntentNextActionDisplayBankTransferInstructions>, - #[serde(skip_serializing_if = "Option::is_none")] + pub card_await_notification: Option<stripe_shared::PaymentIntentNextActionCardAwaitNotification>, + pub cashapp_handle_redirect_or_display_qr_code: Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>, + pub display_bank_transfer_instructions: Option<stripe_shared::PaymentIntentNextActionDisplayBankTransferInstructions>, pub konbini_display_details: Option<stripe_shared::PaymentIntentNextActionKonbini>, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo_display_details: Option<stripe_shared::PaymentIntentNextActionDisplayOxxoDetails>, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow_display_qr_code: Option<stripe_shared::PaymentIntentNextActionPaynowDisplayQrCode>, - #[serde(skip_serializing_if = "Option::is_none")] pub pix_display_qr_code: Option<stripe_shared::PaymentIntentNextActionPixDisplayQrCode>, - #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay_display_qr_code: - Option<stripe_shared::PaymentIntentNextActionPromptpayDisplayQrCode>, - #[serde(skip_serializing_if = "Option::is_none")] + pub promptpay_display_qr_code: Option<stripe_shared::PaymentIntentNextActionPromptpayDisplayQrCode>, pub redirect_to_url: Option<stripe_shared::PaymentIntentNextActionRedirectToUrl>, - #[serde(skip_serializing_if = "Option::is_none")] - pub swish_handle_redirect_or_display_qr_code: - Option<stripe_shared::PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode>, /// Type of the next action to perform, one of `redirect_to_url`, `use_stripe_sdk`, `alipay_handle_redirect`, `oxxo_display_details`, or `verify_with_microdeposits`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, /// When confirming a PaymentIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows. /// The shape of the contents is subject to change and is only intended to be used by Stripe.js. - #[serde(skip_serializing_if = "Option::is_none")] - pub use_stripe_sdk: Option<serde_json::Value>, - #[serde(skip_serializing_if = "Option::is_none")] - pub verify_with_microdeposits: - Option<stripe_shared::PaymentIntentNextActionVerifyWithMicrodeposits>, - #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay_display_qr_code: - Option<stripe_shared::PaymentIntentNextActionWechatPayDisplayQrCode>, - #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay_redirect_to_android_app: - Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToAndroidApp>, - #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay_redirect_to_ios_app: - Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToIosApp>, + pub use_stripe_sdk: Option<stripe_types::Value>, + pub verify_with_microdeposits: Option<stripe_shared::PaymentIntentNextActionVerifyWithMicrodeposits>, + pub wechat_pay_display_qr_code: Option<stripe_shared::PaymentIntentNextActionWechatPayDisplayQrCode>, + pub wechat_pay_redirect_to_android_app: Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToAndroidApp>, + pub wechat_pay_redirect_to_ios_app: Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToIosApp>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionBuilder { + alipay_handle_redirect: Option<Option<stripe_shared::PaymentIntentNextActionAlipayHandleRedirect>>, + boleto_display_details: Option<Option<stripe_shared::PaymentIntentNextActionBoleto>>, + card_await_notification: Option<Option<stripe_shared::PaymentIntentNextActionCardAwaitNotification>>, + cashapp_handle_redirect_or_display_qr_code: Option<Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>>, + display_bank_transfer_instructions: Option<Option<stripe_shared::PaymentIntentNextActionDisplayBankTransferInstructions>>, + konbini_display_details: Option<Option<stripe_shared::PaymentIntentNextActionKonbini>>, + oxxo_display_details: Option<Option<stripe_shared::PaymentIntentNextActionDisplayOxxoDetails>>, + paynow_display_qr_code: Option<Option<stripe_shared::PaymentIntentNextActionPaynowDisplayQrCode>>, + pix_display_qr_code: Option<Option<stripe_shared::PaymentIntentNextActionPixDisplayQrCode>>, + promptpay_display_qr_code: Option<Option<stripe_shared::PaymentIntentNextActionPromptpayDisplayQrCode>>, + redirect_to_url: Option<Option<stripe_shared::PaymentIntentNextActionRedirectToUrl>>, + type_: Option<String>, + use_stripe_sdk: Option<Option<stripe_types::Value>>, + verify_with_microdeposits: Option<Option<stripe_shared::PaymentIntentNextActionVerifyWithMicrodeposits>>, + wechat_pay_display_qr_code: Option<Option<stripe_shared::PaymentIntentNextActionWechatPayDisplayQrCode>>, + wechat_pay_redirect_to_android_app: Option<Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToAndroidApp>>, + wechat_pay_redirect_to_ios_app: Option<Option<stripe_shared::PaymentIntentNextActionWechatPayRedirectToIosApp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextAction>, + builder: PaymentIntentNextActionBuilder, + } + + impl Visitor for Place<PaymentIntentNextAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionBuilder { + type Out = PaymentIntentNextAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alipay_handle_redirect" => Deserialize::begin(&mut self.alipay_handle_redirect), + "boleto_display_details" => Deserialize::begin(&mut self.boleto_display_details), + "card_await_notification" => Deserialize::begin(&mut self.card_await_notification), + "cashapp_handle_redirect_or_display_qr_code" => Deserialize::begin(&mut self.cashapp_handle_redirect_or_display_qr_code), + "display_bank_transfer_instructions" => Deserialize::begin(&mut self.display_bank_transfer_instructions), + "konbini_display_details" => Deserialize::begin(&mut self.konbini_display_details), + "oxxo_display_details" => Deserialize::begin(&mut self.oxxo_display_details), + "paynow_display_qr_code" => Deserialize::begin(&mut self.paynow_display_qr_code), + "pix_display_qr_code" => Deserialize::begin(&mut self.pix_display_qr_code), + "promptpay_display_qr_code" => Deserialize::begin(&mut self.promptpay_display_qr_code), + "redirect_to_url" => Deserialize::begin(&mut self.redirect_to_url), + "type" => Deserialize::begin(&mut self.type_), + "use_stripe_sdk" => Deserialize::begin(&mut self.use_stripe_sdk), + "verify_with_microdeposits" => Deserialize::begin(&mut self.verify_with_microdeposits), + "wechat_pay_display_qr_code" => Deserialize::begin(&mut self.wechat_pay_display_qr_code), + "wechat_pay_redirect_to_android_app" => Deserialize::begin(&mut self.wechat_pay_redirect_to_android_app), + "wechat_pay_redirect_to_ios_app" => Deserialize::begin(&mut self.wechat_pay_redirect_to_ios_app), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alipay_handle_redirect: Deserialize::default(), + boleto_display_details: Deserialize::default(), + card_await_notification: Deserialize::default(), + cashapp_handle_redirect_or_display_qr_code: Deserialize::default(), + display_bank_transfer_instructions: Deserialize::default(), + konbini_display_details: Deserialize::default(), + oxxo_display_details: Deserialize::default(), + paynow_display_qr_code: Deserialize::default(), + pix_display_qr_code: Deserialize::default(), + promptpay_display_qr_code: Deserialize::default(), + redirect_to_url: Deserialize::default(), + type_: Deserialize::default(), + use_stripe_sdk: Deserialize::default(), + verify_with_microdeposits: Deserialize::default(), + wechat_pay_display_qr_code: Deserialize::default(), + wechat_pay_redirect_to_android_app: Deserialize::default(), + wechat_pay_redirect_to_ios_app: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alipay_handle_redirect = self.alipay_handle_redirect.take()?; + let boleto_display_details = self.boleto_display_details.take()?; + let card_await_notification = self.card_await_notification.take()?; + let cashapp_handle_redirect_or_display_qr_code = self.cashapp_handle_redirect_or_display_qr_code.take()?; + let display_bank_transfer_instructions = self.display_bank_transfer_instructions.take()?; + let konbini_display_details = self.konbini_display_details.take()?; + let oxxo_display_details = self.oxxo_display_details.take()?; + let paynow_display_qr_code = self.paynow_display_qr_code.take()?; + let pix_display_qr_code = self.pix_display_qr_code.take()?; + let promptpay_display_qr_code = self.promptpay_display_qr_code.take()?; + let redirect_to_url = self.redirect_to_url.take()?; + let type_ = self.type_.take()?; + let use_stripe_sdk = self.use_stripe_sdk.take()?; + let verify_with_microdeposits = self.verify_with_microdeposits.take()?; + let wechat_pay_display_qr_code = self.wechat_pay_display_qr_code.take()?; + let wechat_pay_redirect_to_android_app = self.wechat_pay_redirect_to_android_app.take()?; + let wechat_pay_redirect_to_ios_app = self.wechat_pay_redirect_to_ios_app.take()?; + + Some(Self::Out { + alipay_handle_redirect, + boleto_display_details, + card_await_notification, + cashapp_handle_redirect_or_display_qr_code, + display_bank_transfer_instructions, + konbini_display_details, + oxxo_display_details, + paynow_display_qr_code, + pix_display_qr_code, + promptpay_display_qr_code, + redirect_to_url, + type_, + use_stripe_sdk, + verify_with_microdeposits, + wechat_pay_display_qr_code, + wechat_pay_redirect_to_android_app, + wechat_pay_redirect_to_ios_app, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextAction { + type Builder = PaymentIntentNextActionBuilder; + } + + impl FromValueOpt for PaymentIntentNextAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alipay_handle_redirect" => b.alipay_handle_redirect = Some(FromValueOpt::from_value(v)?), + "boleto_display_details" => b.boleto_display_details = Some(FromValueOpt::from_value(v)?), + "card_await_notification" => b.card_await_notification = Some(FromValueOpt::from_value(v)?), + "cashapp_handle_redirect_or_display_qr_code" => b.cashapp_handle_redirect_or_display_qr_code = Some(FromValueOpt::from_value(v)?), + "display_bank_transfer_instructions" => b.display_bank_transfer_instructions = Some(FromValueOpt::from_value(v)?), + "konbini_display_details" => b.konbini_display_details = Some(FromValueOpt::from_value(v)?), + "oxxo_display_details" => b.oxxo_display_details = Some(FromValueOpt::from_value(v)?), + "paynow_display_qr_code" => b.paynow_display_qr_code = Some(FromValueOpt::from_value(v)?), + "pix_display_qr_code" => b.pix_display_qr_code = Some(FromValueOpt::from_value(v)?), + "promptpay_display_qr_code" => b.promptpay_display_qr_code = Some(FromValueOpt::from_value(v)?), + "redirect_to_url" => b.redirect_to_url = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "use_stripe_sdk" => b.use_stripe_sdk = Some(FromValueOpt::from_value(v)?), + "verify_with_microdeposits" => b.verify_with_microdeposits = Some(FromValueOpt::from_value(v)?), + "wechat_pay_display_qr_code" => b.wechat_pay_display_qr_code = Some(FromValueOpt::from_value(v)?), + "wechat_pay_redirect_to_android_app" => b.wechat_pay_redirect_to_android_app = Some(FromValueOpt::from_value(v)?), + "wechat_pay_redirect_to_ios_app" => b.wechat_pay_redirect_to_ios_app = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_alipay_handle_redirect.rs b/generated/stripe_shared/src/payment_intent_next_action_alipay_handle_redirect.rs index 220cc2b67..fc1b91c30 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_alipay_handle_redirect.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_alipay_handle_redirect.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionAlipayHandleRedirect { /// The native data to be used with Alipay SDK you must redirect your customer to in order to authenticate the payment in an Android App. pub native_data: Option<String>, @@ -9,3 +11,101 @@ pub struct PaymentIntentNextActionAlipayHandleRedirect { /// The URL you must redirect your customer to in order to authenticate the payment. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionAlipayHandleRedirectBuilder { + native_data: Option<Option<String>>, + native_url: Option<Option<String>>, + return_url: Option<Option<String>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionAlipayHandleRedirect { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionAlipayHandleRedirect>, + builder: PaymentIntentNextActionAlipayHandleRedirectBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionAlipayHandleRedirect> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionAlipayHandleRedirectBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionAlipayHandleRedirectBuilder { + type Out = PaymentIntentNextActionAlipayHandleRedirect; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "native_data" => Deserialize::begin(&mut self.native_data), + "native_url" => Deserialize::begin(&mut self.native_url), + "return_url" => Deserialize::begin(&mut self.return_url), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { native_data: Deserialize::default(), native_url: Deserialize::default(), return_url: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let native_data = self.native_data.take()?; + let native_url = self.native_url.take()?; + let return_url = self.return_url.take()?; + let url = self.url.take()?; + + Some(Self::Out { native_data, native_url, return_url, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionAlipayHandleRedirect { + type Builder = PaymentIntentNextActionAlipayHandleRedirectBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionAlipayHandleRedirect { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionAlipayHandleRedirectBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "native_data" => b.native_data = Some(FromValueOpt::from_value(v)?), + "native_url" => b.native_url = Some(FromValueOpt::from_value(v)?), + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_boleto.rs b/generated/stripe_shared/src/payment_intent_next_action_boleto.rs index ef085d4d4..22b157dc9 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_boleto.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_boleto.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionBoleto { /// The timestamp after which the boleto expires. pub expires_at: Option<stripe_types::Timestamp>, @@ -9,3 +11,101 @@ pub struct PaymentIntentNextActionBoleto { /// The URL to the downloadable boleto voucher PDF. pub pdf: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionBoletoBuilder { + expires_at: Option<Option<stripe_types::Timestamp>>, + hosted_voucher_url: Option<Option<String>>, + number: Option<Option<String>>, + pdf: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionBoleto { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionBoleto>, + builder: PaymentIntentNextActionBoletoBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionBoleto> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionBoletoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionBoletoBuilder { + type Out = PaymentIntentNextActionBoleto; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_at" => Deserialize::begin(&mut self.expires_at), + "hosted_voucher_url" => Deserialize::begin(&mut self.hosted_voucher_url), + "number" => Deserialize::begin(&mut self.number), + "pdf" => Deserialize::begin(&mut self.pdf), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_at: Deserialize::default(), hosted_voucher_url: Deserialize::default(), number: Deserialize::default(), pdf: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_at = self.expires_at.take()?; + let hosted_voucher_url = self.hosted_voucher_url.take()?; + let number = self.number.take()?; + let pdf = self.pdf.take()?; + + Some(Self::Out { expires_at, hosted_voucher_url, number, pdf }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionBoleto { + type Builder = PaymentIntentNextActionBoletoBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionBoleto { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionBoletoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "hosted_voucher_url" => b.hosted_voucher_url = Some(FromValueOpt::from_value(v)?), + "number" => b.number = Some(FromValueOpt::from_value(v)?), + "pdf" => b.pdf = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_card_await_notification.rs b/generated/stripe_shared/src/payment_intent_next_action_card_await_notification.rs index 531e79d8c..cb7cf886c 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_card_await_notification.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_card_await_notification.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionCardAwaitNotification { /// The time that payment will be attempted. /// If customer approval is required, they need to provide approval before this time. @@ -7,3 +9,93 @@ pub struct PaymentIntentNextActionCardAwaitNotification { /// For payments of lower amount, no customer action is required. pub customer_approval_required: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionCardAwaitNotificationBuilder { + charge_attempt_at: Option<Option<stripe_types::Timestamp>>, + customer_approval_required: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionCardAwaitNotification { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionCardAwaitNotification>, + builder: PaymentIntentNextActionCardAwaitNotificationBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionCardAwaitNotification> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionCardAwaitNotificationBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionCardAwaitNotificationBuilder { + type Out = PaymentIntentNextActionCardAwaitNotification; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "charge_attempt_at" => Deserialize::begin(&mut self.charge_attempt_at), + "customer_approval_required" => Deserialize::begin(&mut self.customer_approval_required), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { charge_attempt_at: Deserialize::default(), customer_approval_required: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let charge_attempt_at = self.charge_attempt_at.take()?; + let customer_approval_required = self.customer_approval_required.take()?; + + Some(Self::Out { charge_attempt_at, customer_approval_required }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionCardAwaitNotification { + type Builder = PaymentIntentNextActionCardAwaitNotificationBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionCardAwaitNotification { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionCardAwaitNotificationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "charge_attempt_at" => b.charge_attempt_at = Some(FromValueOpt::from_value(v)?), + "customer_approval_required" => b.customer_approval_required = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_cashapp_handle_redirect_or_display_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_cashapp_handle_redirect_or_display_qr_code.rs index cfcb58f16..a7ef331f5 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_cashapp_handle_redirect_or_display_qr_code.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_cashapp_handle_redirect_or_display_qr_code.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode { /// The URL to the hosted Cash App Pay instructions page, which allows customers to view the QR code, and supports QR code refreshing on expiration. pub hosted_instructions_url: String, @@ -6,3 +8,97 @@ pub struct PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode { pub mobile_auth_url: String, pub qr_code: stripe_shared::PaymentIntentNextActionCashappQrCode, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder { + hosted_instructions_url: Option<String>, + mobile_auth_url: Option<String>, + qr_code: Option<stripe_shared::PaymentIntentNextActionCashappQrCode>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>, + builder: PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder { + type Out = PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url), + "mobile_auth_url" => Deserialize::begin(&mut self.mobile_auth_url), + "qr_code" => Deserialize::begin(&mut self.qr_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { hosted_instructions_url: Deserialize::default(), mobile_auth_url: Deserialize::default(), qr_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let hosted_instructions_url = self.hosted_instructions_url.take()?; + let mobile_auth_url = self.mobile_auth_url.take()?; + let qr_code = self.qr_code.take()?; + + Some(Self::Out { hosted_instructions_url, mobile_auth_url, qr_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode { + type Builder = PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "hosted_instructions_url" => b.hosted_instructions_url = Some(FromValueOpt::from_value(v)?), + "mobile_auth_url" => b.mobile_auth_url = Some(FromValueOpt::from_value(v)?), + "qr_code" => b.qr_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_cashapp_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_cashapp_qr_code.rs index 0cd66605d..fbbf6e2fb 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_cashapp_qr_code.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_cashapp_qr_code.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionCashappQrCode { /// The date (unix timestamp) when the QR code expires. pub expires_at: stripe_types::Timestamp, @@ -7,3 +9,97 @@ pub struct PaymentIntentNextActionCashappQrCode { /// The image_url_svg string used to render QR code pub image_url_svg: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionCashappQrCodeBuilder { + expires_at: Option<stripe_types::Timestamp>, + image_url_png: Option<String>, + image_url_svg: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionCashappQrCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionCashappQrCode>, + builder: PaymentIntentNextActionCashappQrCodeBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionCashappQrCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionCashappQrCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionCashappQrCodeBuilder { + type Out = PaymentIntentNextActionCashappQrCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_at" => Deserialize::begin(&mut self.expires_at), + "image_url_png" => Deserialize::begin(&mut self.image_url_png), + "image_url_svg" => Deserialize::begin(&mut self.image_url_svg), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_at: Deserialize::default(), image_url_png: Deserialize::default(), image_url_svg: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_at = self.expires_at.take()?; + let image_url_png = self.image_url_png.take()?; + let image_url_svg = self.image_url_svg.take()?; + + Some(Self::Out { expires_at, image_url_png, image_url_svg }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionCashappQrCode { + type Builder = PaymentIntentNextActionCashappQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionCashappQrCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionCashappQrCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "image_url_png" => b.image_url_png = Some(FromValueOpt::from_value(v)?), + "image_url_svg" => b.image_url_svg = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_display_bank_transfer_instructions.rs b/generated/stripe_shared/src/payment_intent_next_action_display_bank_transfer_instructions.rs index 199459e7c..dabae9071 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_display_bank_transfer_instructions.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_display_bank_transfer_instructions.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionDisplayBankTransferInstructions { /// The remaining amount that needs to be transferred to complete the payment. pub amount_remaining: Option<i64>, @@ -6,18 +8,129 @@ pub struct PaymentIntentNextActionDisplayBankTransferInstructions { /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: Option<stripe_types::Currency>, /// A list of financial addresses that can be used to fund the customer balance - #[serde(skip_serializing_if = "Option::is_none")] - pub financial_addresses: - Option<Vec<stripe_shared::FundingInstructionsBankTransferFinancialAddress>>, + pub financial_addresses: Option<Vec<stripe_shared::FundingInstructionsBankTransferFinancialAddress>>, /// A link to a hosted page that guides your customer through completing the transfer. pub hosted_instructions_url: Option<String>, /// A string identifying this payment. /// Instruct your customer to include this code in the reference or memo field of their bank transfer. pub reference: Option<String>, /// Type of bank transfer - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentIntentNextActionDisplayBankTransferInstructionsType, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionDisplayBankTransferInstructionsBuilder { + amount_remaining: Option<Option<i64>>, + currency: Option<Option<stripe_types::Currency>>, + financial_addresses: Option<Option<Vec<stripe_shared::FundingInstructionsBankTransferFinancialAddress>>>, + hosted_instructions_url: Option<Option<String>>, + reference: Option<Option<String>>, + type_: Option<PaymentIntentNextActionDisplayBankTransferInstructionsType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionDisplayBankTransferInstructions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionDisplayBankTransferInstructions>, + builder: PaymentIntentNextActionDisplayBankTransferInstructionsBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionDisplayBankTransferInstructions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionDisplayBankTransferInstructionsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionDisplayBankTransferInstructionsBuilder { + type Out = PaymentIntentNextActionDisplayBankTransferInstructions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_remaining" => Deserialize::begin(&mut self.amount_remaining), + "currency" => Deserialize::begin(&mut self.currency), + "financial_addresses" => Deserialize::begin(&mut self.financial_addresses), + "hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url), + "reference" => Deserialize::begin(&mut self.reference), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_remaining: Deserialize::default(), + currency: Deserialize::default(), + financial_addresses: Deserialize::default(), + hosted_instructions_url: Deserialize::default(), + reference: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_remaining = self.amount_remaining.take()?; + let currency = self.currency.take()?; + let financial_addresses = self.financial_addresses.take()?; + let hosted_instructions_url = self.hosted_instructions_url.take()?; + let reference = self.reference.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { amount_remaining, currency, financial_addresses, hosted_instructions_url, reference, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionDisplayBankTransferInstructions { + type Builder = PaymentIntentNextActionDisplayBankTransferInstructionsBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionDisplayBankTransferInstructions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionDisplayBankTransferInstructionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_remaining" => b.amount_remaining = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "financial_addresses" => b.financial_addresses = Some(FromValueOpt::from_value(v)?), + "hosted_instructions_url" => b.hosted_instructions_url = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of bank transfer #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentNextActionDisplayBankTransferInstructionsType { @@ -77,10 +190,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentNextActionDisplayBankTransfer fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentNextActionDisplayBankTransferInstructionsType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentNextActionDisplayBankTransferInstructionsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentNextActionDisplayBankTransferInstructionsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentNextActionDisplayBankTransferInstructionsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentNextActionDisplayBankTransferInstructionsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentNextActionDisplayBankTransferInstructionsType); diff --git a/generated/stripe_shared/src/payment_intent_next_action_display_oxxo_details.rs b/generated/stripe_shared/src/payment_intent_next_action_display_oxxo_details.rs index f20f9d0a3..fd609751c 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_display_oxxo_details.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_display_oxxo_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionDisplayOxxoDetails { /// The timestamp after which the OXXO voucher expires. pub expires_after: Option<stripe_types::Timestamp>, @@ -7,3 +9,97 @@ pub struct PaymentIntentNextActionDisplayOxxoDetails { /// OXXO reference number. pub number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionDisplayOxxoDetailsBuilder { + expires_after: Option<Option<stripe_types::Timestamp>>, + hosted_voucher_url: Option<Option<String>>, + number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionDisplayOxxoDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionDisplayOxxoDetails>, + builder: PaymentIntentNextActionDisplayOxxoDetailsBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionDisplayOxxoDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionDisplayOxxoDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionDisplayOxxoDetailsBuilder { + type Out = PaymentIntentNextActionDisplayOxxoDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after" => Deserialize::begin(&mut self.expires_after), + "hosted_voucher_url" => Deserialize::begin(&mut self.hosted_voucher_url), + "number" => Deserialize::begin(&mut self.number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after: Deserialize::default(), hosted_voucher_url: Deserialize::default(), number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after = self.expires_after.take()?; + let hosted_voucher_url = self.hosted_voucher_url.take()?; + let number = self.number.take()?; + + Some(Self::Out { expires_after, hosted_voucher_url, number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionDisplayOxxoDetails { + type Builder = PaymentIntentNextActionDisplayOxxoDetailsBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionDisplayOxxoDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionDisplayOxxoDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after" => b.expires_after = Some(FromValueOpt::from_value(v)?), + "hosted_voucher_url" => b.hosted_voucher_url = Some(FromValueOpt::from_value(v)?), + "number" => b.number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_konbini.rs b/generated/stripe_shared/src/payment_intent_next_action_konbini.rs index 10ec732ab..1c9e07644 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_konbini.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_konbini.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionKonbini { /// The timestamp at which the pending Konbini payment expires. pub expires_at: stripe_types::Timestamp, @@ -6,3 +8,97 @@ pub struct PaymentIntentNextActionKonbini { pub hosted_voucher_url: Option<String>, pub stores: stripe_shared::PaymentIntentNextActionKonbiniStores, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionKonbiniBuilder { + expires_at: Option<stripe_types::Timestamp>, + hosted_voucher_url: Option<Option<String>>, + stores: Option<stripe_shared::PaymentIntentNextActionKonbiniStores>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionKonbini { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionKonbini>, + builder: PaymentIntentNextActionKonbiniBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionKonbini> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionKonbiniBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionKonbiniBuilder { + type Out = PaymentIntentNextActionKonbini; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_at" => Deserialize::begin(&mut self.expires_at), + "hosted_voucher_url" => Deserialize::begin(&mut self.hosted_voucher_url), + "stores" => Deserialize::begin(&mut self.stores), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_at: Deserialize::default(), hosted_voucher_url: Deserialize::default(), stores: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_at = self.expires_at.take()?; + let hosted_voucher_url = self.hosted_voucher_url.take()?; + let stores = self.stores.take()?; + + Some(Self::Out { expires_at, hosted_voucher_url, stores }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionKonbini { + type Builder = PaymentIntentNextActionKonbiniBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionKonbini { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionKonbiniBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "hosted_voucher_url" => b.hosted_voucher_url = Some(FromValueOpt::from_value(v)?), + "stores" => b.stores = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_konbini_familymart.rs b/generated/stripe_shared/src/payment_intent_next_action_konbini_familymart.rs index f19a04ed3..2caf81a6f 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_konbini_familymart.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_konbini_familymart.rs @@ -1,8 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionKonbiniFamilymart { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option<String>, /// The payment code. pub payment_code: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionKonbiniFamilymartBuilder { + confirmation_number: Option<Option<String>>, + payment_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionKonbiniFamilymart { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionKonbiniFamilymart>, + builder: PaymentIntentNextActionKonbiniFamilymartBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionKonbiniFamilymart> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionKonbiniFamilymartBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionKonbiniFamilymartBuilder { + type Out = PaymentIntentNextActionKonbiniFamilymart; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "confirmation_number" => Deserialize::begin(&mut self.confirmation_number), + "payment_code" => Deserialize::begin(&mut self.payment_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { confirmation_number: Deserialize::default(), payment_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let confirmation_number = self.confirmation_number.take()?; + let payment_code = self.payment_code.take()?; + + Some(Self::Out { confirmation_number, payment_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionKonbiniFamilymart { + type Builder = PaymentIntentNextActionKonbiniFamilymartBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionKonbiniFamilymart { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionKonbiniFamilymartBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "confirmation_number" => b.confirmation_number = Some(FromValueOpt::from_value(v)?), + "payment_code" => b.payment_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_konbini_lawson.rs b/generated/stripe_shared/src/payment_intent_next_action_konbini_lawson.rs index 17b27bc7d..636cab1ec 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_konbini_lawson.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_konbini_lawson.rs @@ -1,8 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionKonbiniLawson { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option<String>, /// The payment code. pub payment_code: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionKonbiniLawsonBuilder { + confirmation_number: Option<Option<String>>, + payment_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionKonbiniLawson { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionKonbiniLawson>, + builder: PaymentIntentNextActionKonbiniLawsonBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionKonbiniLawson> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionKonbiniLawsonBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionKonbiniLawsonBuilder { + type Out = PaymentIntentNextActionKonbiniLawson; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "confirmation_number" => Deserialize::begin(&mut self.confirmation_number), + "payment_code" => Deserialize::begin(&mut self.payment_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { confirmation_number: Deserialize::default(), payment_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let confirmation_number = self.confirmation_number.take()?; + let payment_code = self.payment_code.take()?; + + Some(Self::Out { confirmation_number, payment_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionKonbiniLawson { + type Builder = PaymentIntentNextActionKonbiniLawsonBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionKonbiniLawson { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionKonbiniLawsonBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "confirmation_number" => b.confirmation_number = Some(FromValueOpt::from_value(v)?), + "payment_code" => b.payment_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_konbini_ministop.rs b/generated/stripe_shared/src/payment_intent_next_action_konbini_ministop.rs index 449a464c8..6fd5315a8 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_konbini_ministop.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_konbini_ministop.rs @@ -1,8 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionKonbiniMinistop { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option<String>, /// The payment code. pub payment_code: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionKonbiniMinistopBuilder { + confirmation_number: Option<Option<String>>, + payment_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionKonbiniMinistop { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionKonbiniMinistop>, + builder: PaymentIntentNextActionKonbiniMinistopBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionKonbiniMinistop> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionKonbiniMinistopBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionKonbiniMinistopBuilder { + type Out = PaymentIntentNextActionKonbiniMinistop; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "confirmation_number" => Deserialize::begin(&mut self.confirmation_number), + "payment_code" => Deserialize::begin(&mut self.payment_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { confirmation_number: Deserialize::default(), payment_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let confirmation_number = self.confirmation_number.take()?; + let payment_code = self.payment_code.take()?; + + Some(Self::Out { confirmation_number, payment_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionKonbiniMinistop { + type Builder = PaymentIntentNextActionKonbiniMinistopBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionKonbiniMinistop { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionKonbiniMinistopBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "confirmation_number" => b.confirmation_number = Some(FromValueOpt::from_value(v)?), + "payment_code" => b.payment_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_konbini_seicomart.rs b/generated/stripe_shared/src/payment_intent_next_action_konbini_seicomart.rs index b9416a59f..98c0ea02a 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_konbini_seicomart.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_konbini_seicomart.rs @@ -1,8 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionKonbiniSeicomart { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option<String>, /// The payment code. pub payment_code: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionKonbiniSeicomartBuilder { + confirmation_number: Option<Option<String>>, + payment_code: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionKonbiniSeicomart { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionKonbiniSeicomart>, + builder: PaymentIntentNextActionKonbiniSeicomartBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionKonbiniSeicomart> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionKonbiniSeicomartBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionKonbiniSeicomartBuilder { + type Out = PaymentIntentNextActionKonbiniSeicomart; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "confirmation_number" => Deserialize::begin(&mut self.confirmation_number), + "payment_code" => Deserialize::begin(&mut self.payment_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { confirmation_number: Deserialize::default(), payment_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let confirmation_number = self.confirmation_number.take()?; + let payment_code = self.payment_code.take()?; + + Some(Self::Out { confirmation_number, payment_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionKonbiniSeicomart { + type Builder = PaymentIntentNextActionKonbiniSeicomartBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionKonbiniSeicomart { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionKonbiniSeicomartBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "confirmation_number" => b.confirmation_number = Some(FromValueOpt::from_value(v)?), + "payment_code" => b.payment_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_konbini_stores.rs b/generated/stripe_shared/src/payment_intent_next_action_konbini_stores.rs index ccfd9ceb3..0e78197af 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_konbini_stores.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_konbini_stores.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionKonbiniStores { /// FamilyMart instruction details. pub familymart: Option<stripe_shared::PaymentIntentNextActionKonbiniFamilymart>, @@ -9,3 +11,101 @@ pub struct PaymentIntentNextActionKonbiniStores { /// Seicomart instruction details. pub seicomart: Option<stripe_shared::PaymentIntentNextActionKonbiniSeicomart>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionKonbiniStoresBuilder { + familymart: Option<Option<stripe_shared::PaymentIntentNextActionKonbiniFamilymart>>, + lawson: Option<Option<stripe_shared::PaymentIntentNextActionKonbiniLawson>>, + ministop: Option<Option<stripe_shared::PaymentIntentNextActionKonbiniMinistop>>, + seicomart: Option<Option<stripe_shared::PaymentIntentNextActionKonbiniSeicomart>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionKonbiniStores { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionKonbiniStores>, + builder: PaymentIntentNextActionKonbiniStoresBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionKonbiniStores> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionKonbiniStoresBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionKonbiniStoresBuilder { + type Out = PaymentIntentNextActionKonbiniStores; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "familymart" => Deserialize::begin(&mut self.familymart), + "lawson" => Deserialize::begin(&mut self.lawson), + "ministop" => Deserialize::begin(&mut self.ministop), + "seicomart" => Deserialize::begin(&mut self.seicomart), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { familymart: Deserialize::default(), lawson: Deserialize::default(), ministop: Deserialize::default(), seicomart: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let familymart = self.familymart.take()?; + let lawson = self.lawson.take()?; + let ministop = self.ministop.take()?; + let seicomart = self.seicomart.take()?; + + Some(Self::Out { familymart, lawson, ministop, seicomart }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionKonbiniStores { + type Builder = PaymentIntentNextActionKonbiniStoresBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionKonbiniStores { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionKonbiniStoresBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "familymart" => b.familymart = Some(FromValueOpt::from_value(v)?), + "lawson" => b.lawson = Some(FromValueOpt::from_value(v)?), + "ministop" => b.ministop = Some(FromValueOpt::from_value(v)?), + "seicomart" => b.seicomart = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_paynow_display_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_paynow_display_qr_code.rs index 913f75180..17b817a97 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_paynow_display_qr_code.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_paynow_display_qr_code.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionPaynowDisplayQrCode { /// The raw data string used to generate QR code, it should be used together with QR code library. pub data: String, @@ -9,3 +11,101 @@ pub struct PaymentIntentNextActionPaynowDisplayQrCode { /// The image_url_svg string used to render QR code pub image_url_svg: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionPaynowDisplayQrCodeBuilder { + data: Option<String>, + hosted_instructions_url: Option<Option<String>>, + image_url_png: Option<String>, + image_url_svg: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionPaynowDisplayQrCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionPaynowDisplayQrCode>, + builder: PaymentIntentNextActionPaynowDisplayQrCodeBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionPaynowDisplayQrCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionPaynowDisplayQrCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionPaynowDisplayQrCodeBuilder { + type Out = PaymentIntentNextActionPaynowDisplayQrCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "data" => Deserialize::begin(&mut self.data), + "hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url), + "image_url_png" => Deserialize::begin(&mut self.image_url_png), + "image_url_svg" => Deserialize::begin(&mut self.image_url_svg), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { data: Deserialize::default(), hosted_instructions_url: Deserialize::default(), image_url_png: Deserialize::default(), image_url_svg: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let data = self.data.take()?; + let hosted_instructions_url = self.hosted_instructions_url.take()?; + let image_url_png = self.image_url_png.take()?; + let image_url_svg = self.image_url_svg.take()?; + + Some(Self::Out { data, hosted_instructions_url, image_url_png, image_url_svg }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionPaynowDisplayQrCode { + type Builder = PaymentIntentNextActionPaynowDisplayQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionPaynowDisplayQrCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionPaynowDisplayQrCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "data" => b.data = Some(FromValueOpt::from_value(v)?), + "hosted_instructions_url" => b.hosted_instructions_url = Some(FromValueOpt::from_value(v)?), + "image_url_png" => b.image_url_png = Some(FromValueOpt::from_value(v)?), + "image_url_svg" => b.image_url_svg = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_pix_display_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_pix_display_qr_code.rs index 91b3cb5bf..95b3c2666 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_pix_display_qr_code.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_pix_display_qr_code.rs @@ -1,18 +1,123 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionPixDisplayQrCode { /// The raw data string used to generate QR code, it should be used together with QR code library. - #[serde(skip_serializing_if = "Option::is_none")] pub data: Option<String>, /// The date (unix timestamp) when the PIX expires. - #[serde(skip_serializing_if = "Option::is_none")] pub expires_at: Option<i64>, /// The URL to the hosted pix instructions page, which allows customers to view the pix QR code. - #[serde(skip_serializing_if = "Option::is_none")] pub hosted_instructions_url: Option<String>, /// The image_url_png string used to render png QR code - #[serde(skip_serializing_if = "Option::is_none")] pub image_url_png: Option<String>, /// The image_url_svg string used to render svg QR code - #[serde(skip_serializing_if = "Option::is_none")] pub image_url_svg: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionPixDisplayQrCodeBuilder { + data: Option<Option<String>>, + expires_at: Option<Option<i64>>, + hosted_instructions_url: Option<Option<String>>, + image_url_png: Option<Option<String>>, + image_url_svg: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionPixDisplayQrCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionPixDisplayQrCode>, + builder: PaymentIntentNextActionPixDisplayQrCodeBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionPixDisplayQrCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionPixDisplayQrCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionPixDisplayQrCodeBuilder { + type Out = PaymentIntentNextActionPixDisplayQrCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "data" => Deserialize::begin(&mut self.data), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url), + "image_url_png" => Deserialize::begin(&mut self.image_url_png), + "image_url_svg" => Deserialize::begin(&mut self.image_url_svg), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + data: Deserialize::default(), + expires_at: Deserialize::default(), + hosted_instructions_url: Deserialize::default(), + image_url_png: Deserialize::default(), + image_url_svg: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let data = self.data.take()?; + let expires_at = self.expires_at.take()?; + let hosted_instructions_url = self.hosted_instructions_url.take()?; + let image_url_png = self.image_url_png.take()?; + let image_url_svg = self.image_url_svg.take()?; + + Some(Self::Out { data, expires_at, hosted_instructions_url, image_url_png, image_url_svg }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionPixDisplayQrCode { + type Builder = PaymentIntentNextActionPixDisplayQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionPixDisplayQrCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionPixDisplayQrCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "data" => b.data = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "hosted_instructions_url" => b.hosted_instructions_url = Some(FromValueOpt::from_value(v)?), + "image_url_png" => b.image_url_png = Some(FromValueOpt::from_value(v)?), + "image_url_svg" => b.image_url_svg = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_promptpay_display_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_promptpay_display_qr_code.rs index a66eeead0..6a69ec375 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_promptpay_display_qr_code.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_promptpay_display_qr_code.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionPromptpayDisplayQrCode { /// The raw data string used to generate QR code, it should be used together with QR code library. pub data: String, @@ -9,3 +11,101 @@ pub struct PaymentIntentNextActionPromptpayDisplayQrCode { /// The SVG path used to render the QR code, can be used as the source in an HTML img tag pub image_url_svg: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionPromptpayDisplayQrCodeBuilder { + data: Option<String>, + hosted_instructions_url: Option<String>, + image_url_png: Option<String>, + image_url_svg: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionPromptpayDisplayQrCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionPromptpayDisplayQrCode>, + builder: PaymentIntentNextActionPromptpayDisplayQrCodeBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionPromptpayDisplayQrCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionPromptpayDisplayQrCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionPromptpayDisplayQrCodeBuilder { + type Out = PaymentIntentNextActionPromptpayDisplayQrCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "data" => Deserialize::begin(&mut self.data), + "hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url), + "image_url_png" => Deserialize::begin(&mut self.image_url_png), + "image_url_svg" => Deserialize::begin(&mut self.image_url_svg), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { data: Deserialize::default(), hosted_instructions_url: Deserialize::default(), image_url_png: Deserialize::default(), image_url_svg: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let data = self.data.take()?; + let hosted_instructions_url = self.hosted_instructions_url.take()?; + let image_url_png = self.image_url_png.take()?; + let image_url_svg = self.image_url_svg.take()?; + + Some(Self::Out { data, hosted_instructions_url, image_url_png, image_url_svg }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionPromptpayDisplayQrCode { + type Builder = PaymentIntentNextActionPromptpayDisplayQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionPromptpayDisplayQrCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionPromptpayDisplayQrCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "data" => b.data = Some(FromValueOpt::from_value(v)?), + "hosted_instructions_url" => b.hosted_instructions_url = Some(FromValueOpt::from_value(v)?), + "image_url_png" => b.image_url_png = Some(FromValueOpt::from_value(v)?), + "image_url_svg" => b.image_url_svg = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_redirect_to_url.rs b/generated/stripe_shared/src/payment_intent_next_action_redirect_to_url.rs index 4dcdf5e6c..4389e4a8a 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_redirect_to_url.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_redirect_to_url.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionRedirectToUrl { /// If the customer does not exit their browser while authenticating, they will be redirected to this specified URL after completion. pub return_url: Option<String>, /// The URL you must redirect your customer to in order to authenticate the payment. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionRedirectToUrlBuilder { + return_url: Option<Option<String>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionRedirectToUrl { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionRedirectToUrl>, + builder: PaymentIntentNextActionRedirectToUrlBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionRedirectToUrl> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionRedirectToUrlBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionRedirectToUrlBuilder { + type Out = PaymentIntentNextActionRedirectToUrl; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "return_url" => Deserialize::begin(&mut self.return_url), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { return_url: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let return_url = self.return_url.take()?; + let url = self.url.take()?; + + Some(Self::Out { return_url, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionRedirectToUrl { + type Builder = PaymentIntentNextActionRedirectToUrlBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionRedirectToUrl { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionRedirectToUrlBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_swish_handle_redirect_or_display_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_swish_handle_redirect_or_display_qr_code.rs deleted file mode 100644 index 0a4692b1a..000000000 --- a/generated/stripe_shared/src/payment_intent_next_action_swish_handle_redirect_or_display_qr_code.rs +++ /dev/null @@ -1,11 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode { - /// The URL to the hosted Swish instructions page, which allows customers to view the QR code. - #[serde(skip_serializing_if = "Option::is_none")] - pub hosted_instructions_url: Option<String>, - /// The url for mobile redirect based auth - #[serde(skip_serializing_if = "Option::is_none")] - pub mobile_auth_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] - pub qr_code: Option<stripe_shared::PaymentIntentNextActionSwishQrCode>, -} diff --git a/generated/stripe_shared/src/payment_intent_next_action_swish_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_swish_qr_code.rs deleted file mode 100644 index 410c69da5..000000000 --- a/generated/stripe_shared/src/payment_intent_next_action_swish_qr_code.rs +++ /dev/null @@ -1,12 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct PaymentIntentNextActionSwishQrCode { - /// The raw data string used to generate QR code, it should be used together with QR code library. - #[serde(skip_serializing_if = "Option::is_none")] - pub data: Option<String>, - /// The image_url_png string used to render QR code - #[serde(skip_serializing_if = "Option::is_none")] - pub image_url_png: Option<String>, - /// The image_url_svg string used to render QR code - #[serde(skip_serializing_if = "Option::is_none")] - pub image_url_svg: Option<String>, -} diff --git a/generated/stripe_shared/src/payment_intent_next_action_verify_with_microdeposits.rs b/generated/stripe_shared/src/payment_intent_next_action_verify_with_microdeposits.rs index 135a45185..e097c0e29 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_verify_with_microdeposits.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_verify_with_microdeposits.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionVerifyWithMicrodeposits { /// The timestamp when the microdeposits are expected to land. pub arrival_date: stripe_types::Timestamp, @@ -8,6 +10,100 @@ pub struct PaymentIntentNextActionVerifyWithMicrodeposits { /// Used to distinguish between different verification methods. pub microdeposit_type: Option<PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionVerifyWithMicrodepositsBuilder { + arrival_date: Option<stripe_types::Timestamp>, + hosted_verification_url: Option<String>, + microdeposit_type: Option<Option<PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionVerifyWithMicrodeposits { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionVerifyWithMicrodeposits>, + builder: PaymentIntentNextActionVerifyWithMicrodepositsBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionVerifyWithMicrodeposits> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionVerifyWithMicrodepositsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionVerifyWithMicrodepositsBuilder { + type Out = PaymentIntentNextActionVerifyWithMicrodeposits; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "arrival_date" => Deserialize::begin(&mut self.arrival_date), + "hosted_verification_url" => Deserialize::begin(&mut self.hosted_verification_url), + "microdeposit_type" => Deserialize::begin(&mut self.microdeposit_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { arrival_date: Deserialize::default(), hosted_verification_url: Deserialize::default(), microdeposit_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let arrival_date = self.arrival_date.take()?; + let hosted_verification_url = self.hosted_verification_url.take()?; + let microdeposit_type = self.microdeposit_type.take()?; + + Some(Self::Out { arrival_date, hosted_verification_url, microdeposit_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionVerifyWithMicrodeposits { + type Builder = PaymentIntentNextActionVerifyWithMicrodepositsBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionVerifyWithMicrodeposits { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionVerifyWithMicrodepositsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "arrival_date" => b.arrival_date = Some(FromValueOpt::from_value(v)?), + "hosted_verification_url" => b.hosted_verification_url = Some(FromValueOpt::from_value(v)?), + "microdeposit_type" => b.microdeposit_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the microdeposit sent to the customer. /// Used to distinguish between different verification methods. #[derive(Copy, Clone, Eq, PartialEq)] @@ -55,16 +151,28 @@ impl serde::Serialize for PaymentIntentNextActionVerifyWithMicrodepositsMicrodep serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType); diff --git a/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_display_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_display_qr_code.rs index e40378cc3..54a389054 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_display_qr_code.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_display_qr_code.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionWechatPayDisplayQrCode { /// The data being used to generate QR code pub data: String, @@ -11,3 +13,111 @@ pub struct PaymentIntentNextActionWechatPayDisplayQrCode { /// The image_url_svg string used to render QR code pub image_url_svg: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionWechatPayDisplayQrCodeBuilder { + data: Option<String>, + hosted_instructions_url: Option<String>, + image_data_url: Option<String>, + image_url_png: Option<String>, + image_url_svg: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionWechatPayDisplayQrCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionWechatPayDisplayQrCode>, + builder: PaymentIntentNextActionWechatPayDisplayQrCodeBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionWechatPayDisplayQrCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionWechatPayDisplayQrCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionWechatPayDisplayQrCodeBuilder { + type Out = PaymentIntentNextActionWechatPayDisplayQrCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "data" => Deserialize::begin(&mut self.data), + "hosted_instructions_url" => Deserialize::begin(&mut self.hosted_instructions_url), + "image_data_url" => Deserialize::begin(&mut self.image_data_url), + "image_url_png" => Deserialize::begin(&mut self.image_url_png), + "image_url_svg" => Deserialize::begin(&mut self.image_url_svg), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + data: Deserialize::default(), + hosted_instructions_url: Deserialize::default(), + image_data_url: Deserialize::default(), + image_url_png: Deserialize::default(), + image_url_svg: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let data = self.data.take()?; + let hosted_instructions_url = self.hosted_instructions_url.take()?; + let image_data_url = self.image_data_url.take()?; + let image_url_png = self.image_url_png.take()?; + let image_url_svg = self.image_url_svg.take()?; + + Some(Self::Out { data, hosted_instructions_url, image_data_url, image_url_png, image_url_svg }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionWechatPayDisplayQrCode { + type Builder = PaymentIntentNextActionWechatPayDisplayQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionWechatPayDisplayQrCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionWechatPayDisplayQrCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "data" => b.data = Some(FromValueOpt::from_value(v)?), + "hosted_instructions_url" => b.hosted_instructions_url = Some(FromValueOpt::from_value(v)?), + "image_data_url" => b.image_data_url = Some(FromValueOpt::from_value(v)?), + "image_url_png" => b.image_url_png = Some(FromValueOpt::from_value(v)?), + "image_url_svg" => b.image_url_svg = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_android_app.rs b/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_android_app.rs index 6c7bcc0fe..daf7e536f 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_android_app.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_android_app.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionWechatPayRedirectToAndroidApp { /// app_id is the APP ID registered on WeChat open platform pub app_id: String, @@ -15,3 +17,121 @@ pub struct PaymentIntentNextActionWechatPayRedirectToAndroidApp { /// Specifies the current time in epoch format pub timestamp: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder { + app_id: Option<String>, + nonce_str: Option<String>, + package: Option<String>, + partner_id: Option<String>, + prepay_id: Option<String>, + sign: Option<String>, + timestamp: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionWechatPayRedirectToAndroidApp { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionWechatPayRedirectToAndroidApp>, + builder: PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionWechatPayRedirectToAndroidApp> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder { + type Out = PaymentIntentNextActionWechatPayRedirectToAndroidApp; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "app_id" => Deserialize::begin(&mut self.app_id), + "nonce_str" => Deserialize::begin(&mut self.nonce_str), + "package" => Deserialize::begin(&mut self.package), + "partner_id" => Deserialize::begin(&mut self.partner_id), + "prepay_id" => Deserialize::begin(&mut self.prepay_id), + "sign" => Deserialize::begin(&mut self.sign), + "timestamp" => Deserialize::begin(&mut self.timestamp), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + app_id: Deserialize::default(), + nonce_str: Deserialize::default(), + package: Deserialize::default(), + partner_id: Deserialize::default(), + prepay_id: Deserialize::default(), + sign: Deserialize::default(), + timestamp: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let app_id = self.app_id.take()?; + let nonce_str = self.nonce_str.take()?; + let package = self.package.take()?; + let partner_id = self.partner_id.take()?; + let prepay_id = self.prepay_id.take()?; + let sign = self.sign.take()?; + let timestamp = self.timestamp.take()?; + + Some(Self::Out { app_id, nonce_str, package, partner_id, prepay_id, sign, timestamp }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionWechatPayRedirectToAndroidApp { + type Builder = PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionWechatPayRedirectToAndroidApp { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "app_id" => b.app_id = Some(FromValueOpt::from_value(v)?), + "nonce_str" => b.nonce_str = Some(FromValueOpt::from_value(v)?), + "package" => b.package = Some(FromValueOpt::from_value(v)?), + "partner_id" => b.partner_id = Some(FromValueOpt::from_value(v)?), + "prepay_id" => b.prepay_id = Some(FromValueOpt::from_value(v)?), + "sign" => b.sign = Some(FromValueOpt::from_value(v)?), + "timestamp" => b.timestamp = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_ios_app.rs b/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_ios_app.rs index b216b6392..4f4f8b6d0 100644 --- a/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_ios_app.rs +++ b/generated/stripe_shared/src/payment_intent_next_action_wechat_pay_redirect_to_ios_app.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentNextActionWechatPayRedirectToIosApp { /// An universal link that redirect to WeChat Pay app pub native_url: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentNextActionWechatPayRedirectToIosAppBuilder { + native_url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionWechatPayRedirectToIosApp { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentNextActionWechatPayRedirectToIosApp>, + builder: PaymentIntentNextActionWechatPayRedirectToIosAppBuilder, + } + + impl Visitor for Place<PaymentIntentNextActionWechatPayRedirectToIosApp> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentNextActionWechatPayRedirectToIosAppBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentNextActionWechatPayRedirectToIosAppBuilder { + type Out = PaymentIntentNextActionWechatPayRedirectToIosApp; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "native_url" => Deserialize::begin(&mut self.native_url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { native_url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let native_url = self.native_url.take()?; + + Some(Self::Out { native_url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionWechatPayRedirectToIosApp { + type Builder = PaymentIntentNextActionWechatPayRedirectToIosAppBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionWechatPayRedirectToIosApp { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionWechatPayRedirectToIosAppBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "native_url" => b.native_url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options.rs b/generated/stripe_shared/src/payment_intent_payment_method_options.rs index 0cf03635b..724a3a3c0 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options.rs @@ -1,73 +1,327 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_shared::PaymentIntentPaymentMethodOptionsAcssDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option<stripe_shared::PaymentMethodOptionsAffirm>, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option<stripe_shared::PaymentMethodOptionsAfterpayClearpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option<stripe_shared::PaymentMethodOptionsAlipay>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_shared::PaymentIntentPaymentMethodOptionsAuBecsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_shared::PaymentMethodOptionsBacsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option<stripe_shared::PaymentMethodOptionsBancontact>, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option<stripe_shared::PaymentIntentPaymentMethodOptionsBlik>, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<stripe_shared::PaymentMethodOptionsBoleto>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::PaymentIntentPaymentMethodOptionsCard>, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option<stripe_shared::PaymentMethodOptionsCardPresent>, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option<stripe_shared::PaymentMethodOptionsCashapp>, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option<stripe_shared::PaymentMethodOptionsCustomerBalance>, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option<stripe_shared::PaymentIntentPaymentMethodOptionsEps>, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option<stripe_shared::PaymentMethodOptionsFpx>, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option<stripe_shared::PaymentMethodOptionsGiropay>, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option<stripe_shared::PaymentMethodOptionsGrabpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option<stripe_shared::PaymentMethodOptionsIdeal>, - #[serde(skip_serializing_if = "Option::is_none")] pub interac_present: Option<stripe_shared::PaymentMethodOptionsInteracPresent>, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option<stripe_shared::PaymentMethodOptionsKlarna>, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option<stripe_shared::PaymentMethodOptionsKonbini>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::PaymentIntentPaymentMethodOptionsLink>, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo: Option<stripe_shared::PaymentMethodOptionsOxxo>, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option<stripe_shared::PaymentMethodOptionsP24>, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option<stripe_shared::PaymentMethodOptionsPaynow>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_shared::PaymentMethodOptionsPaypal>, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option<stripe_shared::PaymentMethodOptionsPix>, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option<stripe_shared::PaymentMethodOptionsPromptpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option<stripe_shared::PaymentMethodOptionsRevolutPay>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_shared::PaymentIntentPaymentMethodOptionsSepaDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<stripe_shared::PaymentMethodOptionsSofort>, - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<stripe_shared::PaymentIntentPaymentMethodOptionsSwish>, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_shared::PaymentIntentPaymentMethodOptionsUsBankAccount>, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option<stripe_shared::PaymentMethodOptionsWechatPay>, - #[serde(skip_serializing_if = "Option::is_none")] pub zip: Option<stripe_shared::PaymentMethodOptionsZip>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsBuilder { + acss_debit: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsAcssDebit>>, + affirm: Option<Option<stripe_shared::PaymentMethodOptionsAffirm>>, + afterpay_clearpay: Option<Option<stripe_shared::PaymentMethodOptionsAfterpayClearpay>>, + alipay: Option<Option<stripe_shared::PaymentMethodOptionsAlipay>>, + au_becs_debit: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsAuBecsDebit>>, + bacs_debit: Option<Option<stripe_shared::PaymentMethodOptionsBacsDebit>>, + bancontact: Option<Option<stripe_shared::PaymentMethodOptionsBancontact>>, + blik: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsBlik>>, + boleto: Option<Option<stripe_shared::PaymentMethodOptionsBoleto>>, + card: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsCard>>, + card_present: Option<Option<stripe_shared::PaymentMethodOptionsCardPresent>>, + cashapp: Option<Option<stripe_shared::PaymentMethodOptionsCashapp>>, + customer_balance: Option<Option<stripe_shared::PaymentMethodOptionsCustomerBalance>>, + eps: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsEps>>, + fpx: Option<Option<stripe_shared::PaymentMethodOptionsFpx>>, + giropay: Option<Option<stripe_shared::PaymentMethodOptionsGiropay>>, + grabpay: Option<Option<stripe_shared::PaymentMethodOptionsGrabpay>>, + ideal: Option<Option<stripe_shared::PaymentMethodOptionsIdeal>>, + interac_present: Option<Option<stripe_shared::PaymentMethodOptionsInteracPresent>>, + klarna: Option<Option<stripe_shared::PaymentMethodOptionsKlarna>>, + konbini: Option<Option<stripe_shared::PaymentMethodOptionsKonbini>>, + link: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsLink>>, + oxxo: Option<Option<stripe_shared::PaymentMethodOptionsOxxo>>, + p24: Option<Option<stripe_shared::PaymentMethodOptionsP24>>, + paynow: Option<Option<stripe_shared::PaymentMethodOptionsPaynow>>, + paypal: Option<Option<stripe_shared::PaymentMethodOptionsPaypal>>, + pix: Option<Option<stripe_shared::PaymentMethodOptionsPix>>, + promptpay: Option<Option<stripe_shared::PaymentMethodOptionsPromptpay>>, + revolut_pay: Option<Option<stripe_shared::PaymentMethodOptionsRevolutPay>>, + sepa_debit: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsSepaDebit>>, + sofort: Option<Option<stripe_shared::PaymentMethodOptionsSofort>>, + us_bank_account: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsUsBankAccount>>, + wechat_pay: Option<Option<stripe_shared::PaymentMethodOptionsWechatPay>>, + zip: Option<Option<stripe_shared::PaymentMethodOptionsZip>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptions>, + builder: PaymentIntentPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsBuilder { + type Out = PaymentIntentPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "affirm" => Deserialize::begin(&mut self.affirm), + "afterpay_clearpay" => Deserialize::begin(&mut self.afterpay_clearpay), + "alipay" => Deserialize::begin(&mut self.alipay), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "blik" => Deserialize::begin(&mut self.blik), + "boleto" => Deserialize::begin(&mut self.boleto), + "card" => Deserialize::begin(&mut self.card), + "card_present" => Deserialize::begin(&mut self.card_present), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "customer_balance" => Deserialize::begin(&mut self.customer_balance), + "eps" => Deserialize::begin(&mut self.eps), + "fpx" => Deserialize::begin(&mut self.fpx), + "giropay" => Deserialize::begin(&mut self.giropay), + "grabpay" => Deserialize::begin(&mut self.grabpay), + "ideal" => Deserialize::begin(&mut self.ideal), + "interac_present" => Deserialize::begin(&mut self.interac_present), + "klarna" => Deserialize::begin(&mut self.klarna), + "konbini" => Deserialize::begin(&mut self.konbini), + "link" => Deserialize::begin(&mut self.link), + "oxxo" => Deserialize::begin(&mut self.oxxo), + "p24" => Deserialize::begin(&mut self.p24), + "paynow" => Deserialize::begin(&mut self.paynow), + "paypal" => Deserialize::begin(&mut self.paypal), + "pix" => Deserialize::begin(&mut self.pix), + "promptpay" => Deserialize::begin(&mut self.promptpay), + "revolut_pay" => Deserialize::begin(&mut self.revolut_pay), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "sofort" => Deserialize::begin(&mut self.sofort), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + "wechat_pay" => Deserialize::begin(&mut self.wechat_pay), + "zip" => Deserialize::begin(&mut self.zip), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + affirm: Deserialize::default(), + afterpay_clearpay: Deserialize::default(), + alipay: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bacs_debit: Deserialize::default(), + bancontact: Deserialize::default(), + blik: Deserialize::default(), + boleto: Deserialize::default(), + card: Deserialize::default(), + card_present: Deserialize::default(), + cashapp: Deserialize::default(), + customer_balance: Deserialize::default(), + eps: Deserialize::default(), + fpx: Deserialize::default(), + giropay: Deserialize::default(), + grabpay: Deserialize::default(), + ideal: Deserialize::default(), + interac_present: Deserialize::default(), + klarna: Deserialize::default(), + konbini: Deserialize::default(), + link: Deserialize::default(), + oxxo: Deserialize::default(), + p24: Deserialize::default(), + paynow: Deserialize::default(), + paypal: Deserialize::default(), + pix: Deserialize::default(), + promptpay: Deserialize::default(), + revolut_pay: Deserialize::default(), + sepa_debit: Deserialize::default(), + sofort: Deserialize::default(), + us_bank_account: Deserialize::default(), + wechat_pay: Deserialize::default(), + zip: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let affirm = self.affirm.take()?; + let afterpay_clearpay = self.afterpay_clearpay.take()?; + let alipay = self.alipay.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bacs_debit = self.bacs_debit.take()?; + let bancontact = self.bancontact.take()?; + let blik = self.blik.take()?; + let boleto = self.boleto.take()?; + let card = self.card.take()?; + let card_present = self.card_present.take()?; + let cashapp = self.cashapp.take()?; + let customer_balance = self.customer_balance.take()?; + let eps = self.eps.take()?; + let fpx = self.fpx.take()?; + let giropay = self.giropay.take()?; + let grabpay = self.grabpay.take()?; + let ideal = self.ideal.take()?; + let interac_present = self.interac_present.take()?; + let klarna = self.klarna.take()?; + let konbini = self.konbini.take()?; + let link = self.link.take()?; + let oxxo = self.oxxo.take()?; + let p24 = self.p24.take()?; + let paynow = self.paynow.take()?; + let paypal = self.paypal.take()?; + let pix = self.pix.take()?; + let promptpay = self.promptpay.take()?; + let revolut_pay = self.revolut_pay.take()?; + let sepa_debit = self.sepa_debit.take()?; + let sofort = self.sofort.take()?; + let us_bank_account = self.us_bank_account.take()?; + let wechat_pay = self.wechat_pay.take()?; + let zip = self.zip.take()?; + + Some(Self::Out { + acss_debit, + affirm, + afterpay_clearpay, + alipay, + au_becs_debit, + bacs_debit, + bancontact, + blik, + boleto, + card, + card_present, + cashapp, + customer_balance, + eps, + fpx, + giropay, + grabpay, + ideal, + interac_present, + klarna, + konbini, + link, + oxxo, + p24, + paynow, + paypal, + pix, + promptpay, + revolut_pay, + sepa_debit, + sofort, + us_bank_account, + wechat_pay, + zip, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptions { + type Builder = PaymentIntentPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "affirm" => b.affirm = Some(FromValueOpt::from_value(v)?), + "afterpay_clearpay" => b.afterpay_clearpay = Some(FromValueOpt::from_value(v)?), + "alipay" => b.alipay = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "blik" => b.blik = Some(FromValueOpt::from_value(v)?), + "boleto" => b.boleto = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "card_present" => b.card_present = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "customer_balance" => b.customer_balance = Some(FromValueOpt::from_value(v)?), + "eps" => b.eps = Some(FromValueOpt::from_value(v)?), + "fpx" => b.fpx = Some(FromValueOpt::from_value(v)?), + "giropay" => b.giropay = Some(FromValueOpt::from_value(v)?), + "grabpay" => b.grabpay = Some(FromValueOpt::from_value(v)?), + "ideal" => b.ideal = Some(FromValueOpt::from_value(v)?), + "interac_present" => b.interac_present = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "konbini" => b.konbini = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "oxxo" => b.oxxo = Some(FromValueOpt::from_value(v)?), + "p24" => b.p24 = Some(FromValueOpt::from_value(v)?), + "paynow" => b.paynow = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "pix" => b.pix = Some(FromValueOpt::from_value(v)?), + "promptpay" => b.promptpay = Some(FromValueOpt::from_value(v)?), + "revolut_pay" => b.revolut_pay = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + "wechat_pay" => b.wechat_pay = Some(FromValueOpt::from_value(v)?), + "zip" => b.zip = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_acss_debit.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_acss_debit.rs index 59efe0767..7b76c40c2 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_acss_debit.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_acss_debit.rs @@ -1,20 +1,112 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsAcssDebit { - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>, + pub mandate_options: Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsAcssDebitBuilder { + mandate_options: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>>, + setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage>>, + verification_method: Option<Option<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsAcssDebit>, + builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsAcssDebitBuilder { + type Out = PaymentIntentPaymentMethodOptionsAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { mandate_options: Deserialize::default(), setup_future_usage: Deserialize::default(), verification_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let mandate_options = self.mandate_options.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { mandate_options, setup_future_usage, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsAcssDebit { + type Builder = PaymentIntentPaymentMethodOptionsAcssDebitBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -73,13 +165,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebit fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage); /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -133,10 +239,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebit fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod); diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_au_becs_debit.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_au_becs_debit.rs index 01b55cf62..630853133 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_au_becs_debit.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_au_becs_debit.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsAuBecsDebit { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentIntentPaymentMethodOptionsAuBecsDebit { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder { + setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsAuBecsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsAuBecsDebit>, + builder: PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsAuBecsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder { + type Out = PaymentIntentPaymentMethodOptionsAuBecsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsAuBecsDebit { + type Builder = PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsAuBecsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -67,10 +154,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAuBecsDeb fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_blik.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_blik.rs index 2e09c304f..c7d87cdad 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_blik.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_blik.rs @@ -1,70 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct PaymentIntentPaymentMethodOptionsBlik { - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage>, -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - None, -} -impl PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; - match self { - None => "none", +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +pub struct PaymentIntentPaymentMethodOptionsBlik {} +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsBlikBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsBlik { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) } } -} -impl std::str::FromStr for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::*; - match s { - "none" => Ok(None), - _ => Err(()), + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsBlik>, + builder: PaymentIntentPaymentMethodOptionsBlikBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsBlik> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsBlikBuilder::deser_default() })) } } -} -impl std::fmt::Display for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + + impl MapBuilder for PaymentIntentPaymentMethodOptionsBlikBuilder { + type Out = PaymentIntentPaymentMethodOptionsBlik; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } } -} -impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } } -} -impl serde::Serialize for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsBlik { + type Builder = PaymentIntentPaymentMethodOptionsBlikBuilder; } -} -impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage", - ) - }) + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsBlik { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsBlikBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } } -} +}; diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_card.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_card.rs index 983e53363..14b03e2fb 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_card.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_card.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsCard { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<PaymentIntentPaymentMethodOptionsCardCaptureMethod>, /// Installment details for this payment (Mexico only). /// @@ -14,49 +15,193 @@ pub struct PaymentIntentPaymentMethodOptionsCard { /// Can be only set confirm-time. pub network: Option<PaymentIntentPaymentMethodOptionsCardNetwork>, /// Request ability to [capture beyond the standard authorization validity window](https://stripe.com/docs/payments/extended-authorization) for this PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub request_extended_authorization: - Option<PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, - /// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] - pub request_incremental_authorization: - Option<PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, + pub request_extended_authorization: Option<PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>, + /// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. + pub request_incremental_authorization: Option<PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>, /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] pub request_multicapture: Option<PaymentIntentPaymentMethodOptionsCardRequestMulticapture>, /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] pub request_overcapture: Option<PaymentIntentPaymentMethodOptionsCardRequestOvercapture>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. pub request_three_d_secure: Option<PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>, - /// When enabled, using a card that is attached to a customer will require the CVC to be provided again (i.e. - /// using the cvc_token parameter). - #[serde(skip_serializing_if = "Option::is_none")] - pub require_cvc_recollection: Option<bool>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsCardSetupFutureUsage>, /// Provides information about a card payment that customers see on their statements. /// Concatenated with the Kana prefix (shortened Kana descriptor) or Kana statement descriptor that’s set on the account to form the complete statement descriptor. /// Maximum 22 characters. /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 22 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix_kana: Option<String>, /// Provides information about a card payment that customers see on their statements. /// Concatenated with the Kanji prefix (shortened Kanji descriptor) or Kanji statement descriptor that’s set on the account to form the complete statement descriptor. /// Maximum 17 characters. /// On card statements, the *concatenation* of both prefix and suffix (including separators) will appear truncated to 17 characters. - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor_suffix_kanji: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsCardBuilder { + capture_method: Option<Option<PaymentIntentPaymentMethodOptionsCardCaptureMethod>>, + installments: Option<Option<stripe_shared::PaymentMethodOptionsCardInstallments>>, + mandate_options: Option<Option<stripe_shared::PaymentMethodOptionsCardMandateOptions>>, + network: Option<Option<PaymentIntentPaymentMethodOptionsCardNetwork>>, + request_extended_authorization: Option<Option<PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization>>, + request_incremental_authorization: Option<Option<PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization>>, + request_multicapture: Option<Option<PaymentIntentPaymentMethodOptionsCardRequestMulticapture>>, + request_overcapture: Option<Option<PaymentIntentPaymentMethodOptionsCardRequestOvercapture>>, + request_three_d_secure: Option<Option<PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure>>, + setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsCardSetupFutureUsage>>, + statement_descriptor_suffix_kana: Option<Option<String>>, + statement_descriptor_suffix_kanji: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsCard>, + builder: PaymentIntentPaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsCardBuilder { + type Out = PaymentIntentPaymentMethodOptionsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "installments" => Deserialize::begin(&mut self.installments), + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "network" => Deserialize::begin(&mut self.network), + "request_extended_authorization" => Deserialize::begin(&mut self.request_extended_authorization), + "request_incremental_authorization" => Deserialize::begin(&mut self.request_incremental_authorization), + "request_multicapture" => Deserialize::begin(&mut self.request_multicapture), + "request_overcapture" => Deserialize::begin(&mut self.request_overcapture), + "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "statement_descriptor_suffix_kana" => Deserialize::begin(&mut self.statement_descriptor_suffix_kana), + "statement_descriptor_suffix_kanji" => Deserialize::begin(&mut self.statement_descriptor_suffix_kanji), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + capture_method: Deserialize::default(), + installments: Deserialize::default(), + mandate_options: Deserialize::default(), + network: Deserialize::default(), + request_extended_authorization: Deserialize::default(), + request_incremental_authorization: Deserialize::default(), + request_multicapture: Deserialize::default(), + request_overcapture: Deserialize::default(), + request_three_d_secure: Deserialize::default(), + setup_future_usage: Deserialize::default(), + statement_descriptor_suffix_kana: Deserialize::default(), + statement_descriptor_suffix_kanji: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let installments = self.installments.take()?; + let mandate_options = self.mandate_options.take()?; + let network = self.network.take()?; + let request_extended_authorization = self.request_extended_authorization.take()?; + let request_incremental_authorization = self.request_incremental_authorization.take()?; + let request_multicapture = self.request_multicapture.take()?; + let request_overcapture = self.request_overcapture.take()?; + let request_three_d_secure = self.request_three_d_secure.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let statement_descriptor_suffix_kana = self.statement_descriptor_suffix_kana.take()?; + let statement_descriptor_suffix_kanji = self.statement_descriptor_suffix_kanji.take()?; + + Some(Self::Out { + capture_method, + installments, + mandate_options, + network, + request_extended_authorization, + request_incremental_authorization, + request_multicapture, + request_overcapture, + request_three_d_secure, + setup_future_usage, + statement_descriptor_suffix_kana, + statement_descriptor_suffix_kanji, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsCard { + type Builder = PaymentIntentPaymentMethodOptionsCardBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "installments" => b.installments = Some(FromValueOpt::from_value(v)?), + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "request_extended_authorization" => b.request_extended_authorization = Some(FromValueOpt::from_value(v)?), + "request_incremental_authorization" => b.request_incremental_authorization = Some(FromValueOpt::from_value(v)?), + "request_multicapture" => b.request_multicapture = Some(FromValueOpt::from_value(v)?), + "request_overcapture" => b.request_overcapture = Some(FromValueOpt::from_value(v)?), + "request_three_d_secure" => b.request_three_d_secure = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_suffix_kana" => b.statement_descriptor_suffix_kana = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_suffix_kanji" => b.statement_descriptor_suffix_kanji = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsCardCaptureMethod { @@ -104,13 +249,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardCaptu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsCardCaptureMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardCaptureMethod); /// Selected network to process this payment intent on. /// Depends on the available networks of the card attached to the payment intent. /// Can be only set confirm-time. @@ -190,13 +349,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardNetwo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsCardNetwork", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardNetwork); /// Request ability to [capture beyond the standard authorization validity window](https://stripe.com/docs/payments/extended-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { @@ -243,16 +416,32 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestExtendedAu serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization")) } } -/// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization); +/// Request ability to [increment](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { IfAvailable, @@ -298,15 +487,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestIncrementa serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization); /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsCardRequestMulticapture { @@ -357,13 +562,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardReque fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsCardRequestMulticapture", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardRequestMulticapture")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestMulticapture { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestMulticapture> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardRequestMulticapture::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardRequestMulticapture); /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsCardRequestOvercapture { @@ -414,22 +633,37 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardReque fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsCardRequestOvercapture", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardRequestOvercapture")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestOvercapture { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestOvercapture> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardRequestOvercapture::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardRequestOvercapture); /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, + ChallengeOnly, } impl PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -437,7 +671,7 @@ impl PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", + ChallengeOnly => "challenge_only", } } } @@ -449,7 +683,7 @@ impl std::str::FromStr for PaymentIntentPaymentMethodOptionsCardRequestThreeDSec match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), + "challenge_only" => Ok(ChallengeOnly), _ => Err(()), } } @@ -477,13 +711,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardReque fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -542,10 +790,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardSetup fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsCardSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsCardSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_eps.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_eps.rs index f6d8fd7a8..1d098cf0c 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_eps.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_eps.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsEps { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentIntentPaymentMethodOptionsEps { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsEpsBuilder { + setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsEps { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsEps>, + builder: PaymentIntentPaymentMethodOptionsEpsBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsEps> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsEpsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsEpsBuilder { + type Out = PaymentIntentPaymentMethodOptionsEps; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsEps { + type Builder = PaymentIntentPaymentMethodOptionsEpsBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsEps { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsEpsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsEpsSetupF fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_link.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_link.rs index b9c971f7e..865480a51 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_link.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_link.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsLink { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<PaymentIntentPaymentMethodOptionsLinkCaptureMethod>, /// \[Deprecated\] This is a legacy parameter that no longer has any function. pub persistent_token: Option<String>, @@ -11,9 +12,102 @@ pub struct PaymentIntentPaymentMethodOptionsLink { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsLinkBuilder { + capture_method: Option<Option<PaymentIntentPaymentMethodOptionsLinkCaptureMethod>>, + persistent_token: Option<Option<String>>, + setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsLink>, + builder: PaymentIntentPaymentMethodOptionsLinkBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsLinkBuilder { + type Out = PaymentIntentPaymentMethodOptionsLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "persistent_token" => Deserialize::begin(&mut self.persistent_token), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { capture_method: Deserialize::default(), persistent_token: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let persistent_token = self.persistent_token.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { capture_method, persistent_token, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsLink { + type Builder = PaymentIntentPaymentMethodOptionsLinkBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "persistent_token" => b.persistent_token = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsLinkCaptureMethod { @@ -61,13 +155,27 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsLinkCaptu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsLinkCaptureMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsLinkCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsLinkCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsLinkCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsLinkCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsLinkCaptureMethod); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -123,10 +231,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsLinkSetup fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_acss_debit.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_acss_debit.rs index 0a743d280..d7aee0d31 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_acss_debit.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_acss_debit.rs @@ -1,18 +1,115 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit { /// A URL for custom mandate text - #[serde(skip_serializing_if = "Option::is_none")] pub custom_mandate_url: Option<String>, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. pub interval_description: Option<String>, /// Payment schedule for the mandate. - pub payment_schedule: - Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>, + pub payment_schedule: Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>, /// Transaction type of the mandate. - pub transaction_type: - Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>, + pub transaction_type: Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder { + custom_mandate_url: Option<Option<String>>, + interval_description: Option<Option<String>>, + payment_schedule: Option<Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>>, + transaction_type: Option<Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit>, + builder: PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder { + type Out = PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom_mandate_url" => Deserialize::begin(&mut self.custom_mandate_url), + "interval_description" => Deserialize::begin(&mut self.interval_description), + "payment_schedule" => Deserialize::begin(&mut self.payment_schedule), + "transaction_type" => Deserialize::begin(&mut self.transaction_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom_mandate_url: Deserialize::default(), interval_description: Deserialize::default(), payment_schedule: Deserialize::default(), transaction_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom_mandate_url = self.custom_mandate_url.take()?; + let interval_description = self.interval_description.take()?; + let payment_schedule = self.payment_schedule.take()?; + let transaction_type = self.transaction_type.take()?; + + Some(Self::Out { custom_mandate_url, interval_description, payment_schedule, transaction_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit { + type Builder = PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom_mandate_url" => b.custom_mandate_url = Some(FromValueOpt::from_value(v)?), + "interval_description" => b.interval_description = Some(FromValueOpt::from_value(v)?), + "payment_schedule" => b.payment_schedule = Some(FromValueOpt::from_value(v)?), + "transaction_type" => b.transaction_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { @@ -62,15 +159,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDeb serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule); /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { @@ -117,12 +230,28 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDeb serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType); diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_sepa_debit.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_sepa_debit.rs index 7571f1f03..109511a2c 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_sepa_debit.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_mandate_options_sepa_debit.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit {} +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit>, + builder: PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder { + type Out = PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit { + type Builder = PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_sepa_debit.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_sepa_debit.rs index c12599aab..6343a6f86 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_sepa_debit.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_sepa_debit.rs @@ -1,17 +1,106 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsSepaDebit { - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit>, + pub mandate_options: Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsSepaDebitBuilder { + mandate_options: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit>>, + setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsSepaDebit>, + builder: PaymentIntentPaymentMethodOptionsSepaDebitBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsSepaDebitBuilder { + type Out = PaymentIntentPaymentMethodOptionsSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { mandate_options: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let mandate_options = self.mandate_options.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { mandate_options, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsSepaDebit { + type Builder = PaymentIntentPaymentMethodOptionsSepaDebitBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -70,10 +159,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsSepaDebit fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_swish.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_swish.rs deleted file mode 100644 index f535e0d86..000000000 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_swish.rs +++ /dev/null @@ -1,73 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct PaymentIntentPaymentMethodOptionsSwish { - /// The order ID displayed in the Swish app after the payment is authorized. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference: Option<String>, - /// Indicates that you intend to make future payments with this PaymentIntent's payment method. - /// - /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. - /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - /// - /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] - pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage>, -} -/// Indicates that you intend to make future payments with this PaymentIntent's payment method. -/// -/// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. -/// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. -/// -/// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - None, -} -impl PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - pub fn as_str(self) -> &'static str { - use PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match self { - None => "none", - } - } -} - -impl std::str::FromStr for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::*; - match s { - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage", - ) - }) - } -} diff --git a/generated/stripe_shared/src/payment_intent_payment_method_options_us_bank_account.rs b/generated/stripe_shared/src/payment_intent_payment_method_options_us_bank_account.rs index 46e4a054b..b970e0a77 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_us_bank_account.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_us_bank_account.rs @@ -1,26 +1,123 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentPaymentMethodOptionsUsBankAccount { - #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections: Option<stripe_shared::LinkedAccountOptionsUsBankAccount>, - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<stripe_shared::PaymentMethodOptionsUsBankAccountMandateOptions>, /// Preferred transaction settlement speed - #[serde(skip_serializing_if = "Option::is_none")] - pub preferred_settlement_speed: - Option<PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, + pub preferred_settlement_speed: Option<PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] - pub verification_method: - Option<PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, + pub verification_method: Option<PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentPaymentMethodOptionsUsBankAccountBuilder { + financial_connections: Option<Option<stripe_shared::LinkedAccountOptionsUsBankAccount>>, + preferred_settlement_speed: Option<Option<PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed>>, + setup_future_usage: Option<Option<PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage>>, + verification_method: Option<Option<PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentPaymentMethodOptionsUsBankAccount>, + builder: PaymentIntentPaymentMethodOptionsUsBankAccountBuilder, + } + + impl Visitor for Place<PaymentIntentPaymentMethodOptionsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsUsBankAccountBuilder { + type Out = PaymentIntentPaymentMethodOptionsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "financial_connections" => Deserialize::begin(&mut self.financial_connections), + "preferred_settlement_speed" => Deserialize::begin(&mut self.preferred_settlement_speed), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + financial_connections: Deserialize::default(), + preferred_settlement_speed: Deserialize::default(), + setup_future_usage: Deserialize::default(), + verification_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let financial_connections = self.financial_connections.take()?; + let preferred_settlement_speed = self.preferred_settlement_speed.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { financial_connections, preferred_settlement_speed, setup_future_usage, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentPaymentMethodOptionsUsBankAccount { + type Builder = PaymentIntentPaymentMethodOptionsUsBankAccountBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "financial_connections" => b.financial_connections = Some(FromValueOpt::from_value(v)?), + "preferred_settlement_speed" => b.preferred_settlement_speed = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred transaction settlement speed #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { @@ -67,15 +164,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountPreferre serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -130,19 +243,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFut serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage); /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -192,12 +317,28 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountVerifica serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod); diff --git a/generated/stripe_shared/src/payment_intent_processing.rs b/generated/stripe_shared/src/payment_intent_processing.rs index 249bfa825..b874ed235 100644 --- a/generated/stripe_shared/src/payment_intent_processing.rs +++ b/generated/stripe_shared/src/payment_intent_processing.rs @@ -1,11 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentProcessing { - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::PaymentIntentCardProcessing>, /// Type of the payment method for which payment is in `processing` state, one of `card`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentIntentProcessingType, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentProcessingBuilder { + card: Option<Option<stripe_shared::PaymentIntentCardProcessing>>, + type_: Option<PaymentIntentProcessingType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentProcessing { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentProcessing>, + builder: PaymentIntentProcessingBuilder, + } + + impl Visitor for Place<PaymentIntentProcessing> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentProcessingBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentProcessingBuilder { + type Out = PaymentIntentProcessing; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "card" => Deserialize::begin(&mut self.card), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { card: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let card = self.card.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { card, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentProcessing { + type Builder = PaymentIntentProcessingBuilder; + } + + impl FromValueOpt for PaymentIntentProcessing { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentProcessingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of the payment method for which payment is in `processing` state, one of `card`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentIntentProcessingType { @@ -53,7 +144,24 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentProcessingType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentProcessingType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentIntentProcessingType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentIntentProcessingType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentIntentProcessingType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentProcessingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentIntentProcessingType); diff --git a/generated/stripe_shared/src/payment_intent_processing_customer_notification.rs b/generated/stripe_shared/src/payment_intent_processing_customer_notification.rs index 46b5848f9..e8452afb3 100644 --- a/generated/stripe_shared/src/payment_intent_processing_customer_notification.rs +++ b/generated/stripe_shared/src/payment_intent_processing_customer_notification.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentIntentProcessingCustomerNotification { /// Whether customer approval has been requested for this payment. /// For payments greater than INR 15000 or mandate amount, the customer must provide explicit approval of the payment with their bank. @@ -6,3 +8,93 @@ pub struct PaymentIntentProcessingCustomerNotification { /// If customer approval is required, they need to provide approval before this time. pub completes_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct PaymentIntentProcessingCustomerNotificationBuilder { + approval_requested: Option<Option<bool>>, + completes_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentProcessingCustomerNotification { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentIntentProcessingCustomerNotification>, + builder: PaymentIntentProcessingCustomerNotificationBuilder, + } + + impl Visitor for Place<PaymentIntentProcessingCustomerNotification> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentIntentProcessingCustomerNotificationBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentIntentProcessingCustomerNotificationBuilder { + type Out = PaymentIntentProcessingCustomerNotification; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "approval_requested" => Deserialize::begin(&mut self.approval_requested), + "completes_at" => Deserialize::begin(&mut self.completes_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { approval_requested: Deserialize::default(), completes_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let approval_requested = self.approval_requested.take()?; + let completes_at = self.completes_at.take()?; + + Some(Self::Out { approval_requested, completes_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentProcessingCustomerNotification { + type Builder = PaymentIntentProcessingCustomerNotificationBuilder; + } + + impl FromValueOpt for PaymentIntentProcessingCustomerNotification { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentProcessingCustomerNotificationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "approval_requested" => b.approval_requested = Some(FromValueOpt::from_value(v)?), + "completes_at" => b.completes_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_link.rs b/generated/stripe_shared/src/payment_link.rs index 2b1b5a6dc..cc7030984 100644 --- a/generated/stripe_shared/src/payment_link.rs +++ b/generated/stripe_shared/src/payment_link.rs @@ -7,7 +7,9 @@ /// Related guide: [Payment Links API](https://stripe.com/docs/payment-links) /// /// For more details see <<https://stripe.com/docs/api/payment_links/payment_links/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLink { /// Whether the payment link's `url` is active. /// If `false`, customers visiting the URL will be shown a page saying that the link has been deactivated. @@ -30,19 +32,16 @@ pub struct PaymentLink { /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: stripe_types::Currency, /// Collect additional information from your customer using custom fields. - /// Up to 3 fields are supported. + /// Up to 2 fields are supported. pub custom_fields: Vec<stripe_shared::PaymentLinksResourceCustomFields>, pub custom_text: stripe_shared::PaymentLinksResourceCustomText, /// Configuration for Customer creation during checkout. pub customer_creation: PaymentLinkCustomerCreation, /// Unique identifier for the object. pub id: stripe_shared::PaymentLinkId, - /// The custom message to be displayed to a customer when a payment link is no longer active. - pub inactive_message: Option<String>, /// Configuration for creating invoice for payment mode payment links. pub invoice_creation: Option<stripe_shared::PaymentLinksResourceInvoiceCreation>, /// The line items representing what is being sold. - #[serde(skip_serializing_if = "Option::is_none")] pub line_items: Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, @@ -60,11 +59,8 @@ pub struct PaymentLink { /// When `null`, Stripe will dynamically show relevant payment methods you've enabled in your [payment method settings](https://dashboard.stripe.com/settings/payment_methods). pub payment_method_types: Option<Vec<stripe_shared::PaymentLinkPaymentMethodTypes>>, pub phone_number_collection: stripe_shared::PaymentLinksResourcePhoneNumberCollection, - /// Settings that restrict the usage of a payment link. - pub restrictions: Option<stripe_shared::PaymentLinksResourceRestrictions>, /// Configuration for collecting the customer's shipping address. - pub shipping_address_collection: - Option<stripe_shared::PaymentLinksResourceShippingAddressCollection>, + pub shipping_address_collection: Option<stripe_shared::PaymentLinksResourceShippingAddressCollection>, /// The shipping rate options applied to the session. pub shipping_options: Vec<stripe_shared::PaymentLinksResourceShippingOption>, /// Indicates the type of transaction being performed which customizes relevant text on the page, such as the submit button. @@ -78,6 +74,270 @@ pub struct PaymentLink { /// The public URL that can be shared with customers. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinkBuilder { + active: Option<bool>, + after_completion: Option<stripe_shared::PaymentLinksResourceAfterCompletion>, + allow_promotion_codes: Option<bool>, + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + application_fee_amount: Option<Option<i64>>, + application_fee_percent: Option<Option<f64>>, + automatic_tax: Option<stripe_shared::PaymentLinksResourceAutomaticTax>, + billing_address_collection: Option<stripe_shared::PaymentLinkBillingAddressCollection>, + consent_collection: Option<Option<stripe_shared::PaymentLinksResourceConsentCollection>>, + currency: Option<stripe_types::Currency>, + custom_fields: Option<Vec<stripe_shared::PaymentLinksResourceCustomFields>>, + custom_text: Option<stripe_shared::PaymentLinksResourceCustomText>, + customer_creation: Option<PaymentLinkCustomerCreation>, + id: Option<stripe_shared::PaymentLinkId>, + invoice_creation: Option<Option<stripe_shared::PaymentLinksResourceInvoiceCreation>>, + line_items: Option<Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + payment_intent_data: Option<Option<stripe_shared::PaymentLinksResourcePaymentIntentData>>, + payment_method_collection: Option<PaymentLinkPaymentMethodCollection>, + payment_method_types: Option<Option<Vec<stripe_shared::PaymentLinkPaymentMethodTypes>>>, + phone_number_collection: Option<stripe_shared::PaymentLinksResourcePhoneNumberCollection>, + shipping_address_collection: Option<Option<stripe_shared::PaymentLinksResourceShippingAddressCollection>>, + shipping_options: Option<Vec<stripe_shared::PaymentLinksResourceShippingOption>>, + submit_type: Option<stripe_shared::PaymentLinkSubmitType>, + subscription_data: Option<Option<stripe_shared::PaymentLinksResourceSubscriptionData>>, + tax_id_collection: Option<stripe_shared::PaymentLinksResourceTaxIdCollection>, + transfer_data: Option<Option<stripe_shared::PaymentLinksResourceTransferData>>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLink>, + builder: PaymentLinkBuilder, + } + + impl Visitor for Place<PaymentLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinkBuilder { + type Out = PaymentLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "after_completion" => Deserialize::begin(&mut self.after_completion), + "allow_promotion_codes" => Deserialize::begin(&mut self.allow_promotion_codes), + "application" => Deserialize::begin(&mut self.application), + "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount), + "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent), + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "billing_address_collection" => Deserialize::begin(&mut self.billing_address_collection), + "consent_collection" => Deserialize::begin(&mut self.consent_collection), + "currency" => Deserialize::begin(&mut self.currency), + "custom_fields" => Deserialize::begin(&mut self.custom_fields), + "custom_text" => Deserialize::begin(&mut self.custom_text), + "customer_creation" => Deserialize::begin(&mut self.customer_creation), + "id" => Deserialize::begin(&mut self.id), + "invoice_creation" => Deserialize::begin(&mut self.invoice_creation), + "line_items" => Deserialize::begin(&mut self.line_items), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "payment_intent_data" => Deserialize::begin(&mut self.payment_intent_data), + "payment_method_collection" => Deserialize::begin(&mut self.payment_method_collection), + "payment_method_types" => Deserialize::begin(&mut self.payment_method_types), + "phone_number_collection" => Deserialize::begin(&mut self.phone_number_collection), + "shipping_address_collection" => Deserialize::begin(&mut self.shipping_address_collection), + "shipping_options" => Deserialize::begin(&mut self.shipping_options), + "submit_type" => Deserialize::begin(&mut self.submit_type), + "subscription_data" => Deserialize::begin(&mut self.subscription_data), + "tax_id_collection" => Deserialize::begin(&mut self.tax_id_collection), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + after_completion: Deserialize::default(), + allow_promotion_codes: Deserialize::default(), + application: Deserialize::default(), + application_fee_amount: Deserialize::default(), + application_fee_percent: Deserialize::default(), + automatic_tax: Deserialize::default(), + billing_address_collection: Deserialize::default(), + consent_collection: Deserialize::default(), + currency: Deserialize::default(), + custom_fields: Deserialize::default(), + custom_text: Deserialize::default(), + customer_creation: Deserialize::default(), + id: Deserialize::default(), + invoice_creation: Deserialize::default(), + line_items: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + on_behalf_of: Deserialize::default(), + payment_intent_data: Deserialize::default(), + payment_method_collection: Deserialize::default(), + payment_method_types: Deserialize::default(), + phone_number_collection: Deserialize::default(), + shipping_address_collection: Deserialize::default(), + shipping_options: Deserialize::default(), + submit_type: Deserialize::default(), + subscription_data: Deserialize::default(), + tax_id_collection: Deserialize::default(), + transfer_data: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let after_completion = self.after_completion.take()?; + let allow_promotion_codes = self.allow_promotion_codes.take()?; + let application = self.application.take()?; + let application_fee_amount = self.application_fee_amount.take()?; + let application_fee_percent = self.application_fee_percent.take()?; + let automatic_tax = self.automatic_tax.take()?; + let billing_address_collection = self.billing_address_collection.take()?; + let consent_collection = self.consent_collection.take()?; + let currency = self.currency.take()?; + let custom_fields = self.custom_fields.take()?; + let custom_text = self.custom_text.take()?; + let customer_creation = self.customer_creation.take()?; + let id = self.id.take()?; + let invoice_creation = self.invoice_creation.take()?; + let line_items = self.line_items.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let payment_intent_data = self.payment_intent_data.take()?; + let payment_method_collection = self.payment_method_collection.take()?; + let payment_method_types = self.payment_method_types.take()?; + let phone_number_collection = self.phone_number_collection.take()?; + let shipping_address_collection = self.shipping_address_collection.take()?; + let shipping_options = self.shipping_options.take()?; + let submit_type = self.submit_type.take()?; + let subscription_data = self.subscription_data.take()?; + let tax_id_collection = self.tax_id_collection.take()?; + let transfer_data = self.transfer_data.take()?; + let url = self.url.take()?; + + Some(Self::Out { + active, + after_completion, + allow_promotion_codes, + application, + application_fee_amount, + application_fee_percent, + automatic_tax, + billing_address_collection, + consent_collection, + currency, + custom_fields, + custom_text, + customer_creation, + id, + invoice_creation, + line_items, + livemode, + metadata, + on_behalf_of, + payment_intent_data, + payment_method_collection, + payment_method_types, + phone_number_collection, + shipping_address_collection, + shipping_options, + submit_type, + subscription_data, + tax_id_collection, + transfer_data, + url, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLink { + type Builder = PaymentLinkBuilder; + } + + impl FromValueOpt for PaymentLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "after_completion" => b.after_completion = Some(FromValueOpt::from_value(v)?), + "allow_promotion_codes" => b.allow_promotion_codes = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "application_fee_amount" => b.application_fee_amount = Some(FromValueOpt::from_value(v)?), + "application_fee_percent" => b.application_fee_percent = Some(FromValueOpt::from_value(v)?), + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "billing_address_collection" => b.billing_address_collection = Some(FromValueOpt::from_value(v)?), + "consent_collection" => b.consent_collection = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "custom_fields" => b.custom_fields = Some(FromValueOpt::from_value(v)?), + "custom_text" => b.custom_text = Some(FromValueOpt::from_value(v)?), + "customer_creation" => b.customer_creation = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice_creation" => b.invoice_creation = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "payment_intent_data" => b.payment_intent_data = Some(FromValueOpt::from_value(v)?), + "payment_method_collection" => b.payment_method_collection = Some(FromValueOpt::from_value(v)?), + "payment_method_types" => b.payment_method_types = Some(FromValueOpt::from_value(v)?), + "phone_number_collection" => b.phone_number_collection = Some(FromValueOpt::from_value(v)?), + "shipping_address_collection" => b.shipping_address_collection = Some(FromValueOpt::from_value(v)?), + "shipping_options" => b.shipping_options = Some(FromValueOpt::from_value(v)?), + "submit_type" => b.submit_type = Some(FromValueOpt::from_value(v)?), + "subscription_data" => b.subscription_data = Some(FromValueOpt::from_value(v)?), + "tax_id_collection" => b.tax_id_collection = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Configuration for Customer creation during checkout. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinkCustomerCreation { @@ -128,10 +388,27 @@ impl<'de> serde::Deserialize<'de> for PaymentLinkCustomerCreation { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkCustomerCreation")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkCustomerCreation")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinkCustomerCreation { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinkCustomerCreation> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkCustomerCreation::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinkCustomerCreation); /// Configuration for collecting a payment method during checkout. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinkPaymentMethodCollection { @@ -182,11 +459,27 @@ impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodCollection { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentLinkPaymentMethodCollection") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkPaymentMethodCollection")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinkPaymentMethodCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinkPaymentMethodCollection> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkPaymentMethodCollection::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodCollection); impl stripe_types::Object for PaymentLink { type Id = stripe_shared::PaymentLinkId; fn id(&self) -> &Self::Id { @@ -243,11 +536,27 @@ impl<'de> serde::Deserialize<'de> for PaymentLinkBillingAddressCollection { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentLinkBillingAddressCollection") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkBillingAddressCollection")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinkBillingAddressCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinkBillingAddressCollection> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkBillingAddressCollection::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinkBillingAddressCollection); #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum PaymentLinkPaymentMethodTypes { @@ -277,7 +586,6 @@ pub enum PaymentLinkPaymentMethodTypes { Promptpay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, /// An unrecognized value from Stripe. Should not be used as a request parameter. @@ -313,7 +621,6 @@ impl PaymentLinkPaymentMethodTypes { Promptpay => "promptpay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Unknown => "unknown", @@ -352,7 +659,6 @@ impl std::str::FromStr for PaymentLinkPaymentMethodTypes { "promptpay" => Ok(Promptpay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), _ => Err(()), @@ -382,9 +688,27 @@ impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodTypes { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentLinkPaymentMethodTypes::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinkPaymentMethodTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinkPaymentMethodTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkPaymentMethodTypes::from_str(s).unwrap_or(PaymentLinkPaymentMethodTypes::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodTypes); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinkSubmitType { Auto, @@ -440,7 +764,24 @@ impl<'de> serde::Deserialize<'de> for PaymentLinkSubmitType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkSubmitType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkSubmitType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinkSubmitType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinkSubmitType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkSubmitType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinkSubmitType); diff --git a/generated/stripe_shared/src/payment_links_resource_after_completion.rs b/generated/stripe_shared/src/payment_links_resource_after_completion.rs index 73c843e35..6c6829f3a 100644 --- a/generated/stripe_shared/src/payment_links_resource_after_completion.rs +++ b/generated/stripe_shared/src/payment_links_resource_after_completion.rs @@ -1,14 +1,107 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceAfterCompletion { - #[serde(skip_serializing_if = "Option::is_none")] - pub hosted_confirmation: - Option<stripe_shared::PaymentLinksResourceCompletionBehaviorConfirmationPage>, - #[serde(skip_serializing_if = "Option::is_none")] + pub hosted_confirmation: Option<stripe_shared::PaymentLinksResourceCompletionBehaviorConfirmationPage>, pub redirect: Option<stripe_shared::PaymentLinksResourceCompletionBehaviorRedirect>, /// The specified behavior after the purchase is complete. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentLinksResourceAfterCompletionType, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceAfterCompletionBuilder { + hosted_confirmation: Option<Option<stripe_shared::PaymentLinksResourceCompletionBehaviorConfirmationPage>>, + redirect: Option<Option<stripe_shared::PaymentLinksResourceCompletionBehaviorRedirect>>, + type_: Option<PaymentLinksResourceAfterCompletionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceAfterCompletion { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceAfterCompletion>, + builder: PaymentLinksResourceAfterCompletionBuilder, + } + + impl Visitor for Place<PaymentLinksResourceAfterCompletion> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceAfterCompletionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceAfterCompletionBuilder { + type Out = PaymentLinksResourceAfterCompletion; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "hosted_confirmation" => Deserialize::begin(&mut self.hosted_confirmation), + "redirect" => Deserialize::begin(&mut self.redirect), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { hosted_confirmation: Deserialize::default(), redirect: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let hosted_confirmation = self.hosted_confirmation.take()?; + let redirect = self.redirect.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { hosted_confirmation, redirect, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceAfterCompletion { + type Builder = PaymentLinksResourceAfterCompletionBuilder; + } + + impl FromValueOpt for PaymentLinksResourceAfterCompletion { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceAfterCompletionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "hosted_confirmation" => b.hosted_confirmation = Some(FromValueOpt::from_value(v)?), + "redirect" => b.redirect = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The specified behavior after the purchase is complete. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinksResourceAfterCompletionType { @@ -59,8 +152,24 @@ impl<'de> serde::Deserialize<'de> for PaymentLinksResourceAfterCompletionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentLinksResourceAfterCompletionType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinksResourceAfterCompletionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourceAfterCompletionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourceAfterCompletionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourceAfterCompletionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceAfterCompletionType); diff --git a/generated/stripe_shared/src/payment_links_resource_automatic_tax.rs b/generated/stripe_shared/src/payment_links_resource_automatic_tax.rs index 9996bae28..4bfd72716 100644 --- a/generated/stripe_shared/src/payment_links_resource_automatic_tax.rs +++ b/generated/stripe_shared/src/payment_links_resource_automatic_tax.rs @@ -1,9 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceAutomaticTax { /// If `true`, tax will be calculated automatically using the customer's location. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - pub liability: Option<stripe_shared::ConnectAccountReference>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceAutomaticTaxBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceAutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceAutomaticTax>, + builder: PaymentLinksResourceAutomaticTaxBuilder, + } + + impl Visitor for Place<PaymentLinksResourceAutomaticTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceAutomaticTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceAutomaticTaxBuilder { + type Out = PaymentLinksResourceAutomaticTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceAutomaticTax { + type Builder = PaymentLinksResourceAutomaticTaxBuilder; + } + + impl FromValueOpt for PaymentLinksResourceAutomaticTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceAutomaticTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_completed_sessions.rs b/generated/stripe_shared/src/payment_links_resource_completed_sessions.rs deleted file mode 100644 index 5459c9fd9..000000000 --- a/generated/stripe_shared/src/payment_links_resource_completed_sessions.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct PaymentLinksResourceCompletedSessions { - /// The current number of checkout sessions that have been completed on the payment link which count towards the `completed_sessions` restriction to be met. - pub count: u64, - /// The maximum number of checkout sessions that can be completed for the `completed_sessions` restriction to be met. - pub limit: i64, -} diff --git a/generated/stripe_shared/src/payment_links_resource_completion_behavior_confirmation_page.rs b/generated/stripe_shared/src/payment_links_resource_completion_behavior_confirmation_page.rs index e49274d09..b88118ce7 100644 --- a/generated/stripe_shared/src/payment_links_resource_completion_behavior_confirmation_page.rs +++ b/generated/stripe_shared/src/payment_links_resource_completion_behavior_confirmation_page.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCompletionBehaviorConfirmationPage { /// The custom message that is displayed to the customer after the purchase is complete. pub custom_message: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder { + custom_message: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCompletionBehaviorConfirmationPage { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCompletionBehaviorConfirmationPage>, + builder: PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCompletionBehaviorConfirmationPage> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder { + type Out = PaymentLinksResourceCompletionBehaviorConfirmationPage; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom_message" => Deserialize::begin(&mut self.custom_message), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom_message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom_message = self.custom_message.take()?; + + Some(Self::Out { custom_message }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCompletionBehaviorConfirmationPage { + type Builder = PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCompletionBehaviorConfirmationPage { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom_message" => b.custom_message = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_completion_behavior_redirect.rs b/generated/stripe_shared/src/payment_links_resource_completion_behavior_redirect.rs index 9a36cb2a2..d7a6277d4 100644 --- a/generated/stripe_shared/src/payment_links_resource_completion_behavior_redirect.rs +++ b/generated/stripe_shared/src/payment_links_resource_completion_behavior_redirect.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCompletionBehaviorRedirect { /// The URL the customer will be redirected to after the purchase is complete. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCompletionBehaviorRedirectBuilder { + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCompletionBehaviorRedirect { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCompletionBehaviorRedirect>, + builder: PaymentLinksResourceCompletionBehaviorRedirectBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCompletionBehaviorRedirect> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCompletionBehaviorRedirectBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCompletionBehaviorRedirectBuilder { + type Out = PaymentLinksResourceCompletionBehaviorRedirect; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let url = self.url.take()?; + + Some(Self::Out { url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCompletionBehaviorRedirect { + type Builder = PaymentLinksResourceCompletionBehaviorRedirectBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCompletionBehaviorRedirect { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCompletionBehaviorRedirectBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_consent_collection.rs b/generated/stripe_shared/src/payment_links_resource_consent_collection.rs index 7096a9f9f..ad62b5e6c 100644 --- a/generated/stripe_shared/src/payment_links_resource_consent_collection.rs +++ b/generated/stripe_shared/src/payment_links_resource_consent_collection.rs @@ -1,14 +1,103 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceConsentCollection { - /// Settings related to the payment method reuse text shown in the Checkout UI. - pub payment_method_reuse_agreement: - Option<stripe_shared::PaymentLinksResourcePaymentMethodReuseAgreement>, /// If set to `auto`, enables the collection of customer consent for promotional communications. pub promotions: Option<PaymentLinksResourceConsentCollectionPromotions>, /// If set to `required`, it requires cutomers to accept the terms of service before being able to pay. /// If set to `none`, customers won't be shown a checkbox to accept the terms of service. pub terms_of_service: Option<PaymentLinksResourceConsentCollectionTermsOfService>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceConsentCollectionBuilder { + promotions: Option<Option<PaymentLinksResourceConsentCollectionPromotions>>, + terms_of_service: Option<Option<PaymentLinksResourceConsentCollectionTermsOfService>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceConsentCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceConsentCollection>, + builder: PaymentLinksResourceConsentCollectionBuilder, + } + + impl Visitor for Place<PaymentLinksResourceConsentCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceConsentCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceConsentCollectionBuilder { + type Out = PaymentLinksResourceConsentCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "promotions" => Deserialize::begin(&mut self.promotions), + "terms_of_service" => Deserialize::begin(&mut self.terms_of_service), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { promotions: Deserialize::default(), terms_of_service: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let promotions = self.promotions.take()?; + let terms_of_service = self.terms_of_service.take()?; + + Some(Self::Out { promotions, terms_of_service }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceConsentCollection { + type Builder = PaymentLinksResourceConsentCollectionBuilder; + } + + impl FromValueOpt for PaymentLinksResourceConsentCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceConsentCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "promotions" => b.promotions = Some(FromValueOpt::from_value(v)?), + "terms_of_service" => b.terms_of_service = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// If set to `auto`, enables the collection of customer consent for promotional communications. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinksResourceConsentCollectionPromotions { @@ -59,13 +148,27 @@ impl<'de> serde::Deserialize<'de> for PaymentLinksResourceConsentCollectionPromo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentLinksResourceConsentCollectionPromotions", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinksResourceConsentCollectionPromotions")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourceConsentCollectionPromotions { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourceConsentCollectionPromotions> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourceConsentCollectionPromotions::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceConsentCollectionPromotions); /// If set to `required`, it requires cutomers to accept the terms of service before being able to pay. /// If set to `none`, customers won't be shown a checkbox to accept the terms of service. #[derive(Copy, Clone, Eq, PartialEq)] @@ -117,10 +220,24 @@ impl<'de> serde::Deserialize<'de> for PaymentLinksResourceConsentCollectionTerms fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentLinksResourceConsentCollectionTermsOfService", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinksResourceConsentCollectionTermsOfService")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourceConsentCollectionTermsOfService { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourceConsentCollectionTermsOfService> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourceConsentCollectionTermsOfService::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceConsentCollectionTermsOfService); diff --git a/generated/stripe_shared/src/payment_links_resource_custom_fields.rs b/generated/stripe_shared/src/payment_links_resource_custom_fields.rs index 157ae43eb..63ae9f2a5 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_fields.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_fields.rs @@ -1,22 +1,139 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomFields { - #[serde(skip_serializing_if = "Option::is_none")] pub dropdown: Option<stripe_shared::PaymentLinksResourceCustomFieldsDropdown>, /// String of your choice that your integration can use to reconcile this field. /// Must be unique to this field, alphanumeric, and up to 200 characters. pub key: String, pub label: stripe_shared::PaymentLinksResourceCustomFieldsLabel, - #[serde(skip_serializing_if = "Option::is_none")] pub numeric: Option<stripe_shared::PaymentLinksResourceCustomFieldsNumeric>, /// Whether the customer is required to complete the field before completing the Checkout Session. /// Defaults to `false`. pub optional: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub text: Option<stripe_shared::PaymentLinksResourceCustomFieldsText>, /// The type of the field. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentLinksResourceCustomFieldsType, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomFieldsBuilder { + dropdown: Option<Option<stripe_shared::PaymentLinksResourceCustomFieldsDropdown>>, + key: Option<String>, + label: Option<stripe_shared::PaymentLinksResourceCustomFieldsLabel>, + numeric: Option<Option<stripe_shared::PaymentLinksResourceCustomFieldsNumeric>>, + optional: Option<bool>, + text: Option<Option<stripe_shared::PaymentLinksResourceCustomFieldsText>>, + type_: Option<PaymentLinksResourceCustomFieldsType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomFields { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomFields>, + builder: PaymentLinksResourceCustomFieldsBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomFields> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomFieldsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomFieldsBuilder { + type Out = PaymentLinksResourceCustomFields; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "dropdown" => Deserialize::begin(&mut self.dropdown), + "key" => Deserialize::begin(&mut self.key), + "label" => Deserialize::begin(&mut self.label), + "numeric" => Deserialize::begin(&mut self.numeric), + "optional" => Deserialize::begin(&mut self.optional), + "text" => Deserialize::begin(&mut self.text), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + dropdown: Deserialize::default(), + key: Deserialize::default(), + label: Deserialize::default(), + numeric: Deserialize::default(), + optional: Deserialize::default(), + text: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let dropdown = self.dropdown.take()?; + let key = self.key.take()?; + let label = self.label.take()?; + let numeric = self.numeric.take()?; + let optional = self.optional.take()?; + let text = self.text.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { dropdown, key, label, numeric, optional, text, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomFields { + type Builder = PaymentLinksResourceCustomFieldsBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomFields { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomFieldsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "dropdown" => b.dropdown = Some(FromValueOpt::from_value(v)?), + "key" => b.key = Some(FromValueOpt::from_value(v)?), + "label" => b.label = Some(FromValueOpt::from_value(v)?), + "numeric" => b.numeric = Some(FromValueOpt::from_value(v)?), + "optional" => b.optional = Some(FromValueOpt::from_value(v)?), + "text" => b.text = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the field. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinksResourceCustomFieldsType { @@ -70,8 +187,24 @@ impl<'de> serde::Deserialize<'de> for PaymentLinksResourceCustomFieldsType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentLinksResourceCustomFieldsType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinksResourceCustomFieldsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourceCustomFieldsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourceCustomFieldsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourceCustomFieldsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceCustomFieldsType); diff --git a/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown.rs b/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown.rs index f38092d50..c2f19f644 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomFieldsDropdown { /// The options available for the customer to select. Up to 200 options allowed. pub options: Vec<stripe_shared::PaymentLinksResourceCustomFieldsDropdownOption>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomFieldsDropdownBuilder { + options: Option<Vec<stripe_shared::PaymentLinksResourceCustomFieldsDropdownOption>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomFieldsDropdown { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomFieldsDropdown>, + builder: PaymentLinksResourceCustomFieldsDropdownBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomFieldsDropdown> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomFieldsDropdownBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomFieldsDropdownBuilder { + type Out = PaymentLinksResourceCustomFieldsDropdown; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "options" => Deserialize::begin(&mut self.options), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let options = self.options.take()?; + + Some(Self::Out { options }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomFieldsDropdown { + type Builder = PaymentLinksResourceCustomFieldsDropdownBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomFieldsDropdown { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomFieldsDropdownBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "options" => b.options = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown_option.rs b/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown_option.rs index f2c52007a..a1dcee225 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown_option.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_fields_dropdown_option.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomFieldsDropdownOption { /// The label for the option, displayed to the customer. Up to 100 characters. pub label: String, @@ -6,3 +8,93 @@ pub struct PaymentLinksResourceCustomFieldsDropdownOption { /// Must be unique to this option, alphanumeric, and up to 100 characters. pub value: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomFieldsDropdownOptionBuilder { + label: Option<String>, + value: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomFieldsDropdownOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomFieldsDropdownOption>, + builder: PaymentLinksResourceCustomFieldsDropdownOptionBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomFieldsDropdownOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomFieldsDropdownOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomFieldsDropdownOptionBuilder { + type Out = PaymentLinksResourceCustomFieldsDropdownOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "label" => Deserialize::begin(&mut self.label), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { label: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let label = self.label.take()?; + let value = self.value.take()?; + + Some(Self::Out { label, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomFieldsDropdownOption { + type Builder = PaymentLinksResourceCustomFieldsDropdownOptionBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomFieldsDropdownOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomFieldsDropdownOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "label" => b.label = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_custom_fields_label.rs b/generated/stripe_shared/src/payment_links_resource_custom_fields_label.rs index bd358de3a..e40d7d1f4 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_fields_label.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_fields_label.rs @@ -1,11 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomFieldsLabel { /// Custom text for the label, displayed to the customer. Up to 50 characters. pub custom: Option<String>, /// The type of the label. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentLinksResourceCustomFieldsLabelType, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomFieldsLabelBuilder { + custom: Option<Option<String>>, + type_: Option<PaymentLinksResourceCustomFieldsLabelType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomFieldsLabel { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomFieldsLabel>, + builder: PaymentLinksResourceCustomFieldsLabelBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomFieldsLabel> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomFieldsLabelBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomFieldsLabelBuilder { + type Out = PaymentLinksResourceCustomFieldsLabel; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom" => Deserialize::begin(&mut self.custom), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom = self.custom.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { custom, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomFieldsLabel { + type Builder = PaymentLinksResourceCustomFieldsLabelBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomFieldsLabel { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomFieldsLabelBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom" => b.custom = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the label. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinksResourceCustomFieldsLabelType { @@ -53,8 +145,24 @@ impl<'de> serde::Deserialize<'de> for PaymentLinksResourceCustomFieldsLabelType fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentLinksResourceCustomFieldsLabelType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinksResourceCustomFieldsLabelType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourceCustomFieldsLabelType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourceCustomFieldsLabelType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourceCustomFieldsLabelType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceCustomFieldsLabelType); diff --git a/generated/stripe_shared/src/payment_links_resource_custom_fields_numeric.rs b/generated/stripe_shared/src/payment_links_resource_custom_fields_numeric.rs index 991942e28..da8f2209d 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_fields_numeric.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_fields_numeric.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomFieldsNumeric { /// The maximum character length constraint for the customer's input. pub maximum_length: Option<i64>, /// The minimum character length requirement for the customer's input. pub minimum_length: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomFieldsNumericBuilder { + maximum_length: Option<Option<i64>>, + minimum_length: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomFieldsNumeric { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomFieldsNumeric>, + builder: PaymentLinksResourceCustomFieldsNumericBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomFieldsNumeric> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomFieldsNumericBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomFieldsNumericBuilder { + type Out = PaymentLinksResourceCustomFieldsNumeric; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "maximum_length" => Deserialize::begin(&mut self.maximum_length), + "minimum_length" => Deserialize::begin(&mut self.minimum_length), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum_length: Deserialize::default(), minimum_length: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let maximum_length = self.maximum_length.take()?; + let minimum_length = self.minimum_length.take()?; + + Some(Self::Out { maximum_length, minimum_length }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomFieldsNumeric { + type Builder = PaymentLinksResourceCustomFieldsNumericBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomFieldsNumeric { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomFieldsNumericBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "maximum_length" => b.maximum_length = Some(FromValueOpt::from_value(v)?), + "minimum_length" => b.minimum_length = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_custom_fields_text.rs b/generated/stripe_shared/src/payment_links_resource_custom_fields_text.rs index 2bc876ea7..ac12a2e04 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_fields_text.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_fields_text.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomFieldsText { /// The maximum character length constraint for the customer's input. pub maximum_length: Option<i64>, /// The minimum character length requirement for the customer's input. pub minimum_length: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomFieldsTextBuilder { + maximum_length: Option<Option<i64>>, + minimum_length: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomFieldsText { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomFieldsText>, + builder: PaymentLinksResourceCustomFieldsTextBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomFieldsText> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomFieldsTextBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomFieldsTextBuilder { + type Out = PaymentLinksResourceCustomFieldsText; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "maximum_length" => Deserialize::begin(&mut self.maximum_length), + "minimum_length" => Deserialize::begin(&mut self.minimum_length), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum_length: Deserialize::default(), minimum_length: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let maximum_length = self.maximum_length.take()?; + let minimum_length = self.minimum_length.take()?; + + Some(Self::Out { maximum_length, minimum_length }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomFieldsText { + type Builder = PaymentLinksResourceCustomFieldsTextBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomFieldsText { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomFieldsTextBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "maximum_length" => b.maximum_length = Some(FromValueOpt::from_value(v)?), + "minimum_length" => b.minimum_length = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_custom_text.rs b/generated/stripe_shared/src/payment_links_resource_custom_text.rs index e92effe8a..b64575df2 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_text.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_text.rs @@ -1,7 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomText { - /// Custom text that should be displayed after the payment confirmation button. - pub after_submit: Option<stripe_shared::PaymentLinksResourceCustomTextPosition>, /// Custom text that should be displayed alongside shipping address collection. pub shipping_address: Option<stripe_shared::PaymentLinksResourceCustomTextPosition>, /// Custom text that should be displayed alongside the payment confirmation button. @@ -9,3 +9,97 @@ pub struct PaymentLinksResourceCustomText { /// Custom text that should be displayed in place of the default terms of service agreement text. pub terms_of_service_acceptance: Option<stripe_shared::PaymentLinksResourceCustomTextPosition>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomTextBuilder { + shipping_address: Option<Option<stripe_shared::PaymentLinksResourceCustomTextPosition>>, + submit: Option<Option<stripe_shared::PaymentLinksResourceCustomTextPosition>>, + terms_of_service_acceptance: Option<Option<stripe_shared::PaymentLinksResourceCustomTextPosition>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomText { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomText>, + builder: PaymentLinksResourceCustomTextBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomText> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomTextBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomTextBuilder { + type Out = PaymentLinksResourceCustomText; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "shipping_address" => Deserialize::begin(&mut self.shipping_address), + "submit" => Deserialize::begin(&mut self.submit), + "terms_of_service_acceptance" => Deserialize::begin(&mut self.terms_of_service_acceptance), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { shipping_address: Deserialize::default(), submit: Deserialize::default(), terms_of_service_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let shipping_address = self.shipping_address.take()?; + let submit = self.submit.take()?; + let terms_of_service_acceptance = self.terms_of_service_acceptance.take()?; + + Some(Self::Out { shipping_address, submit, terms_of_service_acceptance }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomText { + type Builder = PaymentLinksResourceCustomTextBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomText { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomTextBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "shipping_address" => b.shipping_address = Some(FromValueOpt::from_value(v)?), + "submit" => b.submit = Some(FromValueOpt::from_value(v)?), + "terms_of_service_acceptance" => b.terms_of_service_acceptance = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_custom_text_position.rs b/generated/stripe_shared/src/payment_links_resource_custom_text_position.rs index cbef6514a..a3dbe5ff5 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_text_position.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_text_position.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceCustomTextPosition { /// Text may be up to 1200 characters in length. pub message: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceCustomTextPositionBuilder { + message: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCustomTextPosition { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceCustomTextPosition>, + builder: PaymentLinksResourceCustomTextPositionBuilder, + } + + impl Visitor for Place<PaymentLinksResourceCustomTextPosition> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceCustomTextPositionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceCustomTextPositionBuilder { + type Out = PaymentLinksResourceCustomTextPosition; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "message" => Deserialize::begin(&mut self.message), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let message = self.message.take()?; + + Some(Self::Out { message }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCustomTextPosition { + type Builder = PaymentLinksResourceCustomTextPositionBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCustomTextPosition { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomTextPositionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "message" => b.message = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_invoice_creation.rs b/generated/stripe_shared/src/payment_links_resource_invoice_creation.rs index 83c9b584c..f77c7b893 100644 --- a/generated/stripe_shared/src/payment_links_resource_invoice_creation.rs +++ b/generated/stripe_shared/src/payment_links_resource_invoice_creation.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceInvoiceCreation { /// Enable creating an invoice on successful payment. pub enabled: bool, /// Configuration for the invoice. Default invoice values will be used if unspecified. pub invoice_data: Option<stripe_shared::PaymentLinksResourceInvoiceSettings>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceInvoiceCreationBuilder { + enabled: Option<bool>, + invoice_data: Option<Option<stripe_shared::PaymentLinksResourceInvoiceSettings>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceInvoiceCreation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceInvoiceCreation>, + builder: PaymentLinksResourceInvoiceCreationBuilder, + } + + impl Visitor for Place<PaymentLinksResourceInvoiceCreation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceInvoiceCreationBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceInvoiceCreationBuilder { + type Out = PaymentLinksResourceInvoiceCreation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "invoice_data" => Deserialize::begin(&mut self.invoice_data), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), invoice_data: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + let invoice_data = self.invoice_data.take()?; + + Some(Self::Out { enabled, invoice_data }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceInvoiceCreation { + type Builder = PaymentLinksResourceInvoiceCreationBuilder; + } + + impl FromValueOpt for PaymentLinksResourceInvoiceCreation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceInvoiceCreationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "invoice_data" => b.invoice_data = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_invoice_settings.rs b/generated/stripe_shared/src/payment_links_resource_invoice_settings.rs index 23eb97d2d..867a98248 100644 --- a/generated/stripe_shared/src/payment_links_resource_invoice_settings.rs +++ b/generated/stripe_shared/src/payment_links_resource_invoice_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceInvoiceSettings { /// The account tax IDs associated with the invoice. pub account_tax_ids: Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>, @@ -8,12 +10,122 @@ pub struct PaymentLinksResourceInvoiceSettings { pub description: Option<String>, /// Footer to be displayed on the invoice. pub footer: Option<String>, - /// The connected account that issues the invoice. - /// The invoice is presented with the branding and support information of the specified account. - pub issuer: Option<stripe_shared::ConnectAccountReference>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. pub metadata: Option<std::collections::HashMap<String, String>>, /// Options for invoice PDF rendering. pub rendering_options: Option<stripe_shared::InvoiceSettingRenderingOptions>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceInvoiceSettingsBuilder { + account_tax_ids: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxId>>>>, + custom_fields: Option<Option<Vec<stripe_shared::InvoiceSettingCustomField>>>, + description: Option<Option<String>>, + footer: Option<Option<String>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + rendering_options: Option<Option<stripe_shared::InvoiceSettingRenderingOptions>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceInvoiceSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceInvoiceSettings>, + builder: PaymentLinksResourceInvoiceSettingsBuilder, + } + + impl Visitor for Place<PaymentLinksResourceInvoiceSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceInvoiceSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceInvoiceSettingsBuilder { + type Out = PaymentLinksResourceInvoiceSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids), + "custom_fields" => Deserialize::begin(&mut self.custom_fields), + "description" => Deserialize::begin(&mut self.description), + "footer" => Deserialize::begin(&mut self.footer), + "metadata" => Deserialize::begin(&mut self.metadata), + "rendering_options" => Deserialize::begin(&mut self.rendering_options), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_tax_ids: Deserialize::default(), + custom_fields: Deserialize::default(), + description: Deserialize::default(), + footer: Deserialize::default(), + metadata: Deserialize::default(), + rendering_options: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_tax_ids = self.account_tax_ids.take()?; + let custom_fields = self.custom_fields.take()?; + let description = self.description.take()?; + let footer = self.footer.take()?; + let metadata = self.metadata.take()?; + let rendering_options = self.rendering_options.take()?; + + Some(Self::Out { account_tax_ids, custom_fields, description, footer, metadata, rendering_options }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceInvoiceSettings { + type Builder = PaymentLinksResourceInvoiceSettingsBuilder; + } + + impl FromValueOpt for PaymentLinksResourceInvoiceSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceInvoiceSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_tax_ids" => b.account_tax_ids = Some(FromValueOpt::from_value(v)?), + "custom_fields" => b.custom_fields = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "footer" => b.footer = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "rendering_options" => b.rendering_options = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_payment_intent_data.rs b/generated/stripe_shared/src/payment_links_resource_payment_intent_data.rs index c7b9602bc..f8dca24ee 100644 --- a/generated/stripe_shared/src/payment_links_resource_payment_intent_data.rs +++ b/generated/stripe_shared/src/payment_links_resource_payment_intent_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourcePaymentIntentData { /// Indicates when the funds will be captured from the customer's account. pub capture_method: Option<PaymentLinksResourcePaymentIntentDataCaptureMethod>, @@ -15,10 +17,120 @@ pub struct PaymentLinksResourcePaymentIntentData { /// Concatenated with the prefix (shortened descriptor) or statement descriptor that's set on the account to form the complete statement descriptor. /// Maximum 22 characters for the concatenated descriptor. pub statement_descriptor_suffix: Option<String>, - /// A string that identifies the resulting payment as part of a group. - /// See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/connect/separate-charges-and-transfers) for details. - pub transfer_group: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourcePaymentIntentDataBuilder { + capture_method: Option<Option<PaymentLinksResourcePaymentIntentDataCaptureMethod>>, + description: Option<Option<String>>, + metadata: Option<std::collections::HashMap<String, String>>, + setup_future_usage: Option<Option<PaymentLinksResourcePaymentIntentDataSetupFutureUsage>>, + statement_descriptor: Option<Option<String>>, + statement_descriptor_suffix: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourcePaymentIntentData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourcePaymentIntentData>, + builder: PaymentLinksResourcePaymentIntentDataBuilder, + } + + impl Visitor for Place<PaymentLinksResourcePaymentIntentData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourcePaymentIntentDataBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourcePaymentIntentDataBuilder { + type Out = PaymentLinksResourcePaymentIntentData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "description" => Deserialize::begin(&mut self.description), + "metadata" => Deserialize::begin(&mut self.metadata), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "statement_descriptor_suffix" => Deserialize::begin(&mut self.statement_descriptor_suffix), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + capture_method: Deserialize::default(), + description: Deserialize::default(), + metadata: Deserialize::default(), + setup_future_usage: Deserialize::default(), + statement_descriptor: Deserialize::default(), + statement_descriptor_suffix: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let description = self.description.take()?; + let metadata = self.metadata.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let statement_descriptor_suffix = self.statement_descriptor_suffix.take()?; + + Some(Self::Out { capture_method, description, metadata, setup_future_usage, statement_descriptor, statement_descriptor_suffix }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourcePaymentIntentData { + type Builder = PaymentLinksResourcePaymentIntentDataBuilder; + } + + impl FromValueOpt for PaymentLinksResourcePaymentIntentData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourcePaymentIntentDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "statement_descriptor_suffix" => b.statement_descriptor_suffix = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinksResourcePaymentIntentDataCaptureMethod { @@ -72,13 +184,27 @@ impl<'de> serde::Deserialize<'de> for PaymentLinksResourcePaymentIntentDataCaptu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentLinksResourcePaymentIntentDataCaptureMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinksResourcePaymentIntentDataCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourcePaymentIntentDataCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourcePaymentIntentDataCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourcePaymentIntentDataCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourcePaymentIntentDataCaptureMethod); /// Indicates that you intend to make future payments with the payment method collected during checkout. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinksResourcePaymentIntentDataSetupFutureUsage { @@ -129,10 +255,24 @@ impl<'de> serde::Deserialize<'de> for PaymentLinksResourcePaymentIntentDataSetup fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentLinksResourcePaymentIntentDataSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinksResourcePaymentIntentDataSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourcePaymentIntentDataSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourcePaymentIntentDataSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourcePaymentIntentDataSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourcePaymentIntentDataSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_links_resource_payment_method_reuse_agreement.rs b/generated/stripe_shared/src/payment_links_resource_payment_method_reuse_agreement.rs deleted file mode 100644 index dff5dd838..000000000 --- a/generated/stripe_shared/src/payment_links_resource_payment_method_reuse_agreement.rs +++ /dev/null @@ -1,68 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct PaymentLinksResourcePaymentMethodReuseAgreement { - /// Determines the position and visibility of the payment method reuse agreement in the UI. - /// When set to `auto`, Stripe's defaults will be used. - /// - /// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. - pub position: PaymentLinksResourcePaymentMethodReuseAgreementPosition, -} -/// Determines the position and visibility of the payment method reuse agreement in the UI. -/// When set to `auto`, Stripe's defaults will be used. -/// -/// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentLinksResourcePaymentMethodReuseAgreementPosition { - Auto, - Hidden, -} -impl PaymentLinksResourcePaymentMethodReuseAgreementPosition { - pub fn as_str(self) -> &'static str { - use PaymentLinksResourcePaymentMethodReuseAgreementPosition::*; - match self { - Auto => "auto", - Hidden => "hidden", - } - } -} - -impl std::str::FromStr for PaymentLinksResourcePaymentMethodReuseAgreementPosition { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use PaymentLinksResourcePaymentMethodReuseAgreementPosition::*; - match s { - "auto" => Ok(Auto), - "hidden" => Ok(Hidden), - _ => Err(()), - } - } -} -impl std::fmt::Display for PaymentLinksResourcePaymentMethodReuseAgreementPosition { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for PaymentLinksResourcePaymentMethodReuseAgreementPosition { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for PaymentLinksResourcePaymentMethodReuseAgreementPosition { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for PaymentLinksResourcePaymentMethodReuseAgreementPosition { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentLinksResourcePaymentMethodReuseAgreementPosition", - ) - }) - } -} diff --git a/generated/stripe_shared/src/payment_links_resource_phone_number_collection.rs b/generated/stripe_shared/src/payment_links_resource_phone_number_collection.rs index 20a7c9d22..11cbcc8e3 100644 --- a/generated/stripe_shared/src/payment_links_resource_phone_number_collection.rs +++ b/generated/stripe_shared/src/payment_links_resource_phone_number_collection.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourcePhoneNumberCollection { /// If `true`, a phone number will be collected during checkout. pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourcePhoneNumberCollectionBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourcePhoneNumberCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourcePhoneNumberCollection>, + builder: PaymentLinksResourcePhoneNumberCollectionBuilder, + } + + impl Visitor for Place<PaymentLinksResourcePhoneNumberCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourcePhoneNumberCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourcePhoneNumberCollectionBuilder { + type Out = PaymentLinksResourcePhoneNumberCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourcePhoneNumberCollection { + type Builder = PaymentLinksResourcePhoneNumberCollectionBuilder; + } + + impl FromValueOpt for PaymentLinksResourcePhoneNumberCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourcePhoneNumberCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_restrictions.rs b/generated/stripe_shared/src/payment_links_resource_restrictions.rs deleted file mode 100644 index 697c4612a..000000000 --- a/generated/stripe_shared/src/payment_links_resource_restrictions.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct PaymentLinksResourceRestrictions { - pub completed_sessions: stripe_shared::PaymentLinksResourceCompletedSessions, -} diff --git a/generated/stripe_shared/src/payment_links_resource_shipping_address_collection.rs b/generated/stripe_shared/src/payment_links_resource_shipping_address_collection.rs index 3cbf4fdc4..24659a913 100644 --- a/generated/stripe_shared/src/payment_links_resource_shipping_address_collection.rs +++ b/generated/stripe_shared/src/payment_links_resource_shipping_address_collection.rs @@ -1,9 +1,97 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceShippingAddressCollection { /// An array of two-letter ISO country codes representing which countries Checkout should provide as options for shipping locations. /// Unsupported country codes: `AS, CX, CC, CU, HM, IR, KP, MH, FM, NF, MP, PW, SD, SY, UM, VI`. pub allowed_countries: Vec<PaymentLinksResourceShippingAddressCollectionAllowedCountries>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceShippingAddressCollectionBuilder { + allowed_countries: Option<Vec<PaymentLinksResourceShippingAddressCollectionAllowedCountries>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceShippingAddressCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceShippingAddressCollection>, + builder: PaymentLinksResourceShippingAddressCollectionBuilder, + } + + impl Visitor for Place<PaymentLinksResourceShippingAddressCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceShippingAddressCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceShippingAddressCollectionBuilder { + type Out = PaymentLinksResourceShippingAddressCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "allowed_countries" => Deserialize::begin(&mut self.allowed_countries), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_countries: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let allowed_countries = self.allowed_countries.take()?; + + Some(Self::Out { allowed_countries }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceShippingAddressCollection { + type Builder = PaymentLinksResourceShippingAddressCollectionBuilder; + } + + impl FromValueOpt for PaymentLinksResourceShippingAddressCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceShippingAddressCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "allowed_countries" => b.allowed_countries = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// An array of two-letter ISO country codes representing which countries Checkout should provide as options for shipping locations. /// Unsupported country codes: `AS, CX, CC, CU, HM, IR, KP, MH, FM, NF, MP, PW, SD, SY, UM, VI`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -760,13 +848,28 @@ impl serde::Serialize for PaymentLinksResourceShippingAddressCollectionAllowedCo serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentLinksResourceShippingAddressCollectionAllowedCountries -{ +impl<'de> serde::Deserialize<'de> for PaymentLinksResourceShippingAddressCollectionAllowedCountries { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s) - .unwrap_or(PaymentLinksResourceShippingAddressCollectionAllowedCountries::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentLinksResourceShippingAddressCollectionAllowedCountries { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentLinksResourceShippingAddressCollectionAllowedCountries> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinksResourceShippingAddressCollectionAllowedCountries::from_str(s).unwrap_or(PaymentLinksResourceShippingAddressCollectionAllowedCountries::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceShippingAddressCollectionAllowedCountries); diff --git a/generated/stripe_shared/src/payment_links_resource_shipping_option.rs b/generated/stripe_shared/src/payment_links_resource_shipping_option.rs index b96cbd3f1..a5369b88c 100644 --- a/generated/stripe_shared/src/payment_links_resource_shipping_option.rs +++ b/generated/stripe_shared/src/payment_links_resource_shipping_option.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceShippingOption { /// A non-negative integer in cents representing how much to charge. pub shipping_amount: i64, /// The ID of the Shipping Rate to use for this shipping option. pub shipping_rate: stripe_types::Expandable<stripe_shared::ShippingRate>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceShippingOptionBuilder { + shipping_amount: Option<i64>, + shipping_rate: Option<stripe_types::Expandable<stripe_shared::ShippingRate>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceShippingOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceShippingOption>, + builder: PaymentLinksResourceShippingOptionBuilder, + } + + impl Visitor for Place<PaymentLinksResourceShippingOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceShippingOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceShippingOptionBuilder { + type Out = PaymentLinksResourceShippingOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "shipping_amount" => Deserialize::begin(&mut self.shipping_amount), + "shipping_rate" => Deserialize::begin(&mut self.shipping_rate), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { shipping_amount: Deserialize::default(), shipping_rate: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let shipping_amount = self.shipping_amount.take()?; + let shipping_rate = self.shipping_rate.take()?; + + Some(Self::Out { shipping_amount, shipping_rate }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceShippingOption { + type Builder = PaymentLinksResourceShippingOptionBuilder; + } + + impl FromValueOpt for PaymentLinksResourceShippingOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceShippingOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "shipping_amount" => b.shipping_amount = Some(FromValueOpt::from_value(v)?), + "shipping_rate" => b.shipping_rate = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_subscription_data.rs b/generated/stripe_shared/src/payment_links_resource_subscription_data.rs index a176b9ff8..f7d61e0e8 100644 --- a/generated/stripe_shared/src/payment_links_resource_subscription_data.rs +++ b/generated/stripe_shared/src/payment_links_resource_subscription_data.rs @@ -1,13 +1,106 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceSubscriptionData { /// The subscription's description, meant to be displayable to the customer. /// Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs. pub description: Option<String>, - pub invoice_settings: stripe_shared::PaymentLinksResourceSubscriptionDataInvoiceSettings, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that will set metadata on [Subscriptions](https://stripe.com/docs/api/subscriptions) generated from this payment link. pub metadata: std::collections::HashMap<String, String>, /// Integer representing the number of trial period days before the customer is charged for the first time. pub trial_period_days: Option<u32>, - /// Settings related to subscription trials. - pub trial_settings: Option<stripe_shared::SubscriptionsTrialsResourceTrialSettings>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceSubscriptionDataBuilder { + description: Option<Option<String>>, + metadata: Option<std::collections::HashMap<String, String>>, + trial_period_days: Option<Option<u32>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceSubscriptionData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceSubscriptionData>, + builder: PaymentLinksResourceSubscriptionDataBuilder, + } + + impl Visitor for Place<PaymentLinksResourceSubscriptionData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceSubscriptionDataBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceSubscriptionDataBuilder { + type Out = PaymentLinksResourceSubscriptionData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "description" => Deserialize::begin(&mut self.description), + "metadata" => Deserialize::begin(&mut self.metadata), + "trial_period_days" => Deserialize::begin(&mut self.trial_period_days), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { description: Deserialize::default(), metadata: Deserialize::default(), trial_period_days: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let description = self.description.take()?; + let metadata = self.metadata.take()?; + let trial_period_days = self.trial_period_days.take()?; + + Some(Self::Out { description, metadata, trial_period_days }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceSubscriptionData { + type Builder = PaymentLinksResourceSubscriptionDataBuilder; + } + + impl FromValueOpt for PaymentLinksResourceSubscriptionData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceSubscriptionDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "trial_period_days" => b.trial_period_days = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_subscription_data_invoice_settings.rs b/generated/stripe_shared/src/payment_links_resource_subscription_data_invoice_settings.rs deleted file mode 100644 index 67c6c7750..000000000 --- a/generated/stripe_shared/src/payment_links_resource_subscription_data_invoice_settings.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct PaymentLinksResourceSubscriptionDataInvoiceSettings { - pub issuer: stripe_shared::ConnectAccountReference, -} diff --git a/generated/stripe_shared/src/payment_links_resource_tax_id_collection.rs b/generated/stripe_shared/src/payment_links_resource_tax_id_collection.rs index 9282ec204..d3be8dcff 100644 --- a/generated/stripe_shared/src/payment_links_resource_tax_id_collection.rs +++ b/generated/stripe_shared/src/payment_links_resource_tax_id_collection.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceTaxIdCollection { /// Indicates whether tax ID collection is enabled for the session. pub enabled: bool, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceTaxIdCollectionBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceTaxIdCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceTaxIdCollection>, + builder: PaymentLinksResourceTaxIdCollectionBuilder, + } + + impl Visitor for Place<PaymentLinksResourceTaxIdCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceTaxIdCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceTaxIdCollectionBuilder { + type Out = PaymentLinksResourceTaxIdCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceTaxIdCollection { + type Builder = PaymentLinksResourceTaxIdCollectionBuilder; + } + + impl FromValueOpt for PaymentLinksResourceTaxIdCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceTaxIdCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_links_resource_transfer_data.rs b/generated/stripe_shared/src/payment_links_resource_transfer_data.rs index b6562b454..99782d477 100644 --- a/generated/stripe_shared/src/payment_links_resource_transfer_data.rs +++ b/generated/stripe_shared/src/payment_links_resource_transfer_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentLinksResourceTransferData { /// The amount in cents (or local equivalent) that will be transferred to the destination account. /// By default, the entire amount is transferred to the destination. @@ -6,3 +8,93 @@ pub struct PaymentLinksResourceTransferData { /// The connected account receiving the transfer. pub destination: stripe_types::Expandable<stripe_shared::Account>, } +#[cfg(feature = "min-ser")] +pub struct PaymentLinksResourceTransferDataBuilder { + amount: Option<Option<i64>>, + destination: Option<stripe_types::Expandable<stripe_shared::Account>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentLinksResourceTransferData>, + builder: PaymentLinksResourceTransferDataBuilder, + } + + impl Visitor for Place<PaymentLinksResourceTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentLinksResourceTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentLinksResourceTransferDataBuilder { + type Out = PaymentLinksResourceTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "destination" => Deserialize::begin(&mut self.destination), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let destination = self.destination.take()?; + + Some(Self::Out { amount, destination }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceTransferData { + type Builder = PaymentLinksResourceTransferDataBuilder; + } + + impl FromValueOpt for PaymentLinksResourceTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method.rs b/generated/stripe_shared/src/payment_method.rs index aa8017d45..5978bf7f3 100644 --- a/generated/stripe_shared/src/payment_method.rs +++ b/generated/stripe_shared/src/payment_method.rs @@ -5,99 +5,400 @@ /// Related guides: [Payment Methods](https://stripe.com/docs/payments/payment-methods) and [More Payment Scenarios](https://stripe.com/docs/payments/more-payment-scenarios). /// /// For more details see <<https://stripe.com/docs/api/payment_methods/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethod { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_shared::PaymentMethodAcssDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option<stripe_shared::PaymentMethodAffirm>, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option<stripe_shared::PaymentMethodAfterpayClearpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsAlipay>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_shared::PaymentMethodAuBecsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_shared::PaymentMethodBacsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option<stripe_shared::PaymentMethodBancontact>, pub billing_details: stripe_shared::BillingDetails, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option<stripe_shared::PaymentMethodBlik>, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<stripe_shared::PaymentMethodBoleto>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::PaymentMethodCard>, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option<stripe_shared::PaymentMethodCardPresent>, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option<stripe_shared::PaymentMethodCashapp>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// The ID of the Customer to which this PaymentMethod is saved. /// This will not be set when the PaymentMethod has not been saved to a Customer. pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option<stripe_shared::PaymentMethodCustomerBalance>, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option<stripe_shared::PaymentMethodEps>, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option<stripe_shared::PaymentMethodFpx>, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option<stripe_shared::PaymentMethodGiropay>, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option<stripe_shared::PaymentMethodGrabpay>, /// Unique identifier for the object. pub id: stripe_shared::PaymentMethodId, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option<stripe_shared::PaymentMethodIdeal>, - #[serde(skip_serializing_if = "Option::is_none")] pub interac_present: Option<stripe_shared::PaymentMethodInteracPresent>, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option<stripe_shared::PaymentMethodKlarna>, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option<stripe_shared::PaymentMethodKonbini>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::PaymentMethodLink>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. pub metadata: Option<std::collections::HashMap<String, String>>, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo: Option<stripe_shared::PaymentMethodOxxo>, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option<stripe_shared::PaymentMethodP24>, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option<stripe_shared::PaymentMethodPaynow>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_shared::PaymentMethodPaypal>, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option<stripe_shared::PaymentMethodPix>, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option<stripe_shared::PaymentMethodPromptpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option<stripe_shared::RadarRadarOptions>, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option<stripe_shared::PaymentMethodRevolutPay>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_shared::PaymentMethodSepaDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<stripe_shared::PaymentMethodSofort>, - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<stripe_shared::PaymentMethodSwish>, /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentMethodType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_shared::PaymentMethodUsBankAccount>, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option<stripe_shared::PaymentMethodWechatPay>, - #[serde(skip_serializing_if = "Option::is_none")] pub zip: Option<stripe_shared::PaymentMethodZip>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodBuilder { + acss_debit: Option<Option<stripe_shared::PaymentMethodAcssDebit>>, + affirm: Option<Option<stripe_shared::PaymentMethodAffirm>>, + afterpay_clearpay: Option<Option<stripe_shared::PaymentMethodAfterpayClearpay>>, + alipay: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsAlipay>>, + au_becs_debit: Option<Option<stripe_shared::PaymentMethodAuBecsDebit>>, + bacs_debit: Option<Option<stripe_shared::PaymentMethodBacsDebit>>, + bancontact: Option<Option<stripe_shared::PaymentMethodBancontact>>, + billing_details: Option<stripe_shared::BillingDetails>, + blik: Option<Option<stripe_shared::PaymentMethodBlik>>, + boleto: Option<Option<stripe_shared::PaymentMethodBoleto>>, + card: Option<Option<stripe_shared::PaymentMethodCard>>, + card_present: Option<Option<stripe_shared::PaymentMethodCardPresent>>, + cashapp: Option<Option<stripe_shared::PaymentMethodCashapp>>, + created: Option<stripe_types::Timestamp>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + customer_balance: Option<Option<stripe_shared::PaymentMethodCustomerBalance>>, + eps: Option<Option<stripe_shared::PaymentMethodEps>>, + fpx: Option<Option<stripe_shared::PaymentMethodFpx>>, + giropay: Option<Option<stripe_shared::PaymentMethodGiropay>>, + grabpay: Option<Option<stripe_shared::PaymentMethodGrabpay>>, + id: Option<stripe_shared::PaymentMethodId>, + ideal: Option<Option<stripe_shared::PaymentMethodIdeal>>, + interac_present: Option<Option<stripe_shared::PaymentMethodInteracPresent>>, + klarna: Option<Option<stripe_shared::PaymentMethodKlarna>>, + konbini: Option<Option<stripe_shared::PaymentMethodKonbini>>, + link: Option<Option<stripe_shared::PaymentMethodLink>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + oxxo: Option<Option<stripe_shared::PaymentMethodOxxo>>, + p24: Option<Option<stripe_shared::PaymentMethodP24>>, + paynow: Option<Option<stripe_shared::PaymentMethodPaynow>>, + paypal: Option<Option<stripe_shared::PaymentMethodPaypal>>, + pix: Option<Option<stripe_shared::PaymentMethodPix>>, + promptpay: Option<Option<stripe_shared::PaymentMethodPromptpay>>, + radar_options: Option<Option<stripe_shared::RadarRadarOptions>>, + revolut_pay: Option<Option<stripe_shared::PaymentMethodRevolutPay>>, + sepa_debit: Option<Option<stripe_shared::PaymentMethodSepaDebit>>, + sofort: Option<Option<stripe_shared::PaymentMethodSofort>>, + type_: Option<PaymentMethodType>, + us_bank_account: Option<Option<stripe_shared::PaymentMethodUsBankAccount>>, + wechat_pay: Option<Option<stripe_shared::PaymentMethodWechatPay>>, + zip: Option<Option<stripe_shared::PaymentMethodZip>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethod>, + builder: PaymentMethodBuilder, + } + + impl Visitor for Place<PaymentMethod> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodBuilder { + type Out = PaymentMethod; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "affirm" => Deserialize::begin(&mut self.affirm), + "afterpay_clearpay" => Deserialize::begin(&mut self.afterpay_clearpay), + "alipay" => Deserialize::begin(&mut self.alipay), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "billing_details" => Deserialize::begin(&mut self.billing_details), + "blik" => Deserialize::begin(&mut self.blik), + "boleto" => Deserialize::begin(&mut self.boleto), + "card" => Deserialize::begin(&mut self.card), + "card_present" => Deserialize::begin(&mut self.card_present), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "created" => Deserialize::begin(&mut self.created), + "customer" => Deserialize::begin(&mut self.customer), + "customer_balance" => Deserialize::begin(&mut self.customer_balance), + "eps" => Deserialize::begin(&mut self.eps), + "fpx" => Deserialize::begin(&mut self.fpx), + "giropay" => Deserialize::begin(&mut self.giropay), + "grabpay" => Deserialize::begin(&mut self.grabpay), + "id" => Deserialize::begin(&mut self.id), + "ideal" => Deserialize::begin(&mut self.ideal), + "interac_present" => Deserialize::begin(&mut self.interac_present), + "klarna" => Deserialize::begin(&mut self.klarna), + "konbini" => Deserialize::begin(&mut self.konbini), + "link" => Deserialize::begin(&mut self.link), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "oxxo" => Deserialize::begin(&mut self.oxxo), + "p24" => Deserialize::begin(&mut self.p24), + "paynow" => Deserialize::begin(&mut self.paynow), + "paypal" => Deserialize::begin(&mut self.paypal), + "pix" => Deserialize::begin(&mut self.pix), + "promptpay" => Deserialize::begin(&mut self.promptpay), + "radar_options" => Deserialize::begin(&mut self.radar_options), + "revolut_pay" => Deserialize::begin(&mut self.revolut_pay), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "sofort" => Deserialize::begin(&mut self.sofort), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + "wechat_pay" => Deserialize::begin(&mut self.wechat_pay), + "zip" => Deserialize::begin(&mut self.zip), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + affirm: Deserialize::default(), + afterpay_clearpay: Deserialize::default(), + alipay: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bacs_debit: Deserialize::default(), + bancontact: Deserialize::default(), + billing_details: Deserialize::default(), + blik: Deserialize::default(), + boleto: Deserialize::default(), + card: Deserialize::default(), + card_present: Deserialize::default(), + cashapp: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + customer_balance: Deserialize::default(), + eps: Deserialize::default(), + fpx: Deserialize::default(), + giropay: Deserialize::default(), + grabpay: Deserialize::default(), + id: Deserialize::default(), + ideal: Deserialize::default(), + interac_present: Deserialize::default(), + klarna: Deserialize::default(), + konbini: Deserialize::default(), + link: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + oxxo: Deserialize::default(), + p24: Deserialize::default(), + paynow: Deserialize::default(), + paypal: Deserialize::default(), + pix: Deserialize::default(), + promptpay: Deserialize::default(), + radar_options: Deserialize::default(), + revolut_pay: Deserialize::default(), + sepa_debit: Deserialize::default(), + sofort: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + wechat_pay: Deserialize::default(), + zip: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let affirm = self.affirm.take()?; + let afterpay_clearpay = self.afterpay_clearpay.take()?; + let alipay = self.alipay.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bacs_debit = self.bacs_debit.take()?; + let bancontact = self.bancontact.take()?; + let billing_details = self.billing_details.take()?; + let blik = self.blik.take()?; + let boleto = self.boleto.take()?; + let card = self.card.take()?; + let card_present = self.card_present.take()?; + let cashapp = self.cashapp.take()?; + let created = self.created.take()?; + let customer = self.customer.take()?; + let customer_balance = self.customer_balance.take()?; + let eps = self.eps.take()?; + let fpx = self.fpx.take()?; + let giropay = self.giropay.take()?; + let grabpay = self.grabpay.take()?; + let id = self.id.take()?; + let ideal = self.ideal.take()?; + let interac_present = self.interac_present.take()?; + let klarna = self.klarna.take()?; + let konbini = self.konbini.take()?; + let link = self.link.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let oxxo = self.oxxo.take()?; + let p24 = self.p24.take()?; + let paynow = self.paynow.take()?; + let paypal = self.paypal.take()?; + let pix = self.pix.take()?; + let promptpay = self.promptpay.take()?; + let radar_options = self.radar_options.take()?; + let revolut_pay = self.revolut_pay.take()?; + let sepa_debit = self.sepa_debit.take()?; + let sofort = self.sofort.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + let wechat_pay = self.wechat_pay.take()?; + let zip = self.zip.take()?; + + Some(Self::Out { + acss_debit, + affirm, + afterpay_clearpay, + alipay, + au_becs_debit, + bacs_debit, + bancontact, + billing_details, + blik, + boleto, + card, + card_present, + cashapp, + created, + customer, + customer_balance, + eps, + fpx, + giropay, + grabpay, + id, + ideal, + interac_present, + klarna, + konbini, + link, + livemode, + metadata, + oxxo, + p24, + paynow, + paypal, + pix, + promptpay, + radar_options, + revolut_pay, + sepa_debit, + sofort, + type_, + us_bank_account, + wechat_pay, + zip, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethod { + type Builder = PaymentMethodBuilder; + } + + impl FromValueOpt for PaymentMethod { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "affirm" => b.affirm = Some(FromValueOpt::from_value(v)?), + "afterpay_clearpay" => b.afterpay_clearpay = Some(FromValueOpt::from_value(v)?), + "alipay" => b.alipay = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "billing_details" => b.billing_details = Some(FromValueOpt::from_value(v)?), + "blik" => b.blik = Some(FromValueOpt::from_value(v)?), + "boleto" => b.boleto = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "card_present" => b.card_present = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "customer_balance" => b.customer_balance = Some(FromValueOpt::from_value(v)?), + "eps" => b.eps = Some(FromValueOpt::from_value(v)?), + "fpx" => b.fpx = Some(FromValueOpt::from_value(v)?), + "giropay" => b.giropay = Some(FromValueOpt::from_value(v)?), + "grabpay" => b.grabpay = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "ideal" => b.ideal = Some(FromValueOpt::from_value(v)?), + "interac_present" => b.interac_present = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "konbini" => b.konbini = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "oxxo" => b.oxxo = Some(FromValueOpt::from_value(v)?), + "p24" => b.p24 = Some(FromValueOpt::from_value(v)?), + "paynow" => b.paynow = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "pix" => b.pix = Some(FromValueOpt::from_value(v)?), + "promptpay" => b.promptpay = Some(FromValueOpt::from_value(v)?), + "radar_options" => b.radar_options = Some(FromValueOpt::from_value(v)?), + "revolut_pay" => b.revolut_pay = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + "wechat_pay" => b.wechat_pay = Some(FromValueOpt::from_value(v)?), + "zip" => b.zip = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. @@ -135,7 +436,6 @@ pub enum PaymentMethodType { RevolutPay, SepaDebit, Sofort, - Swish, UsBankAccount, WechatPay, Zip, @@ -177,7 +477,6 @@ impl PaymentMethodType { RevolutPay => "revolut_pay", SepaDebit => "sepa_debit", Sofort => "sofort", - Swish => "swish", UsBankAccount => "us_bank_account", WechatPay => "wechat_pay", Zip => "zip", @@ -222,7 +521,6 @@ impl std::str::FromStr for PaymentMethodType { "revolut_pay" => Ok(RevolutPay), "sepa_debit" => Ok(SepaDebit), "sofort" => Ok(Sofort), - "swish" => Ok(Swish), "us_bank_account" => Ok(UsBankAccount), "wechat_pay" => Ok(WechatPay), "zip" => Ok(Zip), @@ -253,9 +551,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodType::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodType::from_str(s).unwrap_or(PaymentMethodType::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodType); impl stripe_types::Object for PaymentMethod { type Id = stripe_shared::PaymentMethodId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/payment_method_acss_debit.rs b/generated/stripe_shared/src/payment_method_acss_debit.rs index cf687891c..f05549766 100644 --- a/generated/stripe_shared/src/payment_method_acss_debit.rs +++ b/generated/stripe_shared/src/payment_method_acss_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodAcssDebit { /// Name of the bank associated with the bank account. pub bank_name: Option<String>, @@ -12,3 +14,111 @@ pub struct PaymentMethodAcssDebit { /// Transit number of the bank account. pub transit_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodAcssDebitBuilder { + bank_name: Option<Option<String>>, + fingerprint: Option<Option<String>>, + institution_number: Option<Option<String>>, + last4: Option<Option<String>>, + transit_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodAcssDebit>, + builder: PaymentMethodAcssDebitBuilder, + } + + impl Visitor for Place<PaymentMethodAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodAcssDebitBuilder { + type Out = PaymentMethodAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_name" => Deserialize::begin(&mut self.bank_name), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "institution_number" => Deserialize::begin(&mut self.institution_number), + "last4" => Deserialize::begin(&mut self.last4), + "transit_number" => Deserialize::begin(&mut self.transit_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_name: Deserialize::default(), + fingerprint: Deserialize::default(), + institution_number: Deserialize::default(), + last4: Deserialize::default(), + transit_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_name = self.bank_name.take()?; + let fingerprint = self.fingerprint.take()?; + let institution_number = self.institution_number.take()?; + let last4 = self.last4.take()?; + let transit_number = self.transit_number.take()?; + + Some(Self::Out { bank_name, fingerprint, institution_number, last4, transit_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodAcssDebit { + type Builder = PaymentMethodAcssDebitBuilder; + } + + impl FromValueOpt for PaymentMethodAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "institution_number" => b.institution_number = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "transit_number" => b.transit_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_affirm.rs b/generated/stripe_shared/src/payment_method_affirm.rs index 21482a272..ce89c33f5 100644 --- a/generated/stripe_shared/src/payment_method_affirm.rs +++ b/generated/stripe_shared/src/payment_method_affirm.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodAffirm {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodAffirmBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodAffirm { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodAffirm>, + builder: PaymentMethodAffirmBuilder, + } + + impl Visitor for Place<PaymentMethodAffirm> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodAffirmBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodAffirmBuilder { + type Out = PaymentMethodAffirm; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodAffirm { + type Builder = PaymentMethodAffirmBuilder; + } + + impl FromValueOpt for PaymentMethodAffirm { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodAffirmBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_afterpay_clearpay.rs b/generated/stripe_shared/src/payment_method_afterpay_clearpay.rs index 4a9cbd897..520c4c86d 100644 --- a/generated/stripe_shared/src/payment_method_afterpay_clearpay.rs +++ b/generated/stripe_shared/src/payment_method_afterpay_clearpay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodAfterpayClearpay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodAfterpayClearpayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodAfterpayClearpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodAfterpayClearpay>, + builder: PaymentMethodAfterpayClearpayBuilder, + } + + impl Visitor for Place<PaymentMethodAfterpayClearpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodAfterpayClearpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodAfterpayClearpayBuilder { + type Out = PaymentMethodAfterpayClearpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodAfterpayClearpay { + type Builder = PaymentMethodAfterpayClearpayBuilder; + } + + impl FromValueOpt for PaymentMethodAfterpayClearpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodAfterpayClearpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_au_becs_debit.rs b/generated/stripe_shared/src/payment_method_au_becs_debit.rs index a25c416ee..299e4af69 100644 --- a/generated/stripe_shared/src/payment_method_au_becs_debit.rs +++ b/generated/stripe_shared/src/payment_method_au_becs_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodAuBecsDebit { /// Six-digit number identifying bank and branch associated with this bank account. pub bsb_number: Option<String>, @@ -8,3 +10,97 @@ pub struct PaymentMethodAuBecsDebit { /// Last four digits of the bank account number. pub last4: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodAuBecsDebitBuilder { + bsb_number: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodAuBecsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodAuBecsDebit>, + builder: PaymentMethodAuBecsDebitBuilder, + } + + impl Visitor for Place<PaymentMethodAuBecsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodAuBecsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodAuBecsDebitBuilder { + type Out = PaymentMethodAuBecsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bsb_number" => Deserialize::begin(&mut self.bsb_number), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bsb_number: Deserialize::default(), fingerprint: Deserialize::default(), last4: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bsb_number = self.bsb_number.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + + Some(Self::Out { bsb_number, fingerprint, last4 }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodAuBecsDebit { + type Builder = PaymentMethodAuBecsDebitBuilder; + } + + impl FromValueOpt for PaymentMethodAuBecsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodAuBecsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bsb_number" => b.bsb_number = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_bacs_debit.rs b/generated/stripe_shared/src/payment_method_bacs_debit.rs index fe3ee850c..701c66812 100644 --- a/generated/stripe_shared/src/payment_method_bacs_debit.rs +++ b/generated/stripe_shared/src/payment_method_bacs_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodBacsDebit { /// Uniquely identifies this particular bank account. /// You can use this attribute to check whether two bank accounts are the same. @@ -8,3 +10,97 @@ pub struct PaymentMethodBacsDebit { /// Sort code of the bank account. (e.g., `10-20-30`) pub sort_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodBacsDebitBuilder { + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + sort_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodBacsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodBacsDebit>, + builder: PaymentMethodBacsDebitBuilder, + } + + impl Visitor for Place<PaymentMethodBacsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodBacsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodBacsDebitBuilder { + type Out = PaymentMethodBacsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "sort_code" => Deserialize::begin(&mut self.sort_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { fingerprint: Deserialize::default(), last4: Deserialize::default(), sort_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let sort_code = self.sort_code.take()?; + + Some(Self::Out { fingerprint, last4, sort_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodBacsDebit { + type Builder = PaymentMethodBacsDebitBuilder; + } + + impl FromValueOpt for PaymentMethodBacsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodBacsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "sort_code" => b.sort_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_bancontact.rs b/generated/stripe_shared/src/payment_method_bancontact.rs index 8c7d8a5b9..6d023d374 100644 --- a/generated/stripe_shared/src/payment_method_bancontact.rs +++ b/generated/stripe_shared/src/payment_method_bancontact.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodBancontact {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodBancontactBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodBancontact { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodBancontact>, + builder: PaymentMethodBancontactBuilder, + } + + impl Visitor for Place<PaymentMethodBancontact> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodBancontactBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodBancontactBuilder { + type Out = PaymentMethodBancontact; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodBancontact { + type Builder = PaymentMethodBancontactBuilder; + } + + impl FromValueOpt for PaymentMethodBancontact { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodBancontactBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_blik.rs b/generated/stripe_shared/src/payment_method_blik.rs index f89a95af6..f3ba8e8a6 100644 --- a/generated/stripe_shared/src/payment_method_blik.rs +++ b/generated/stripe_shared/src/payment_method_blik.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodBlik {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodBlikBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodBlik { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodBlik>, + builder: PaymentMethodBlikBuilder, + } + + impl Visitor for Place<PaymentMethodBlik> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodBlikBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodBlikBuilder { + type Out = PaymentMethodBlik; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodBlik { + type Builder = PaymentMethodBlikBuilder; + } + + impl FromValueOpt for PaymentMethodBlik { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodBlikBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_boleto.rs b/generated/stripe_shared/src/payment_method_boleto.rs index 7d42b3261..cddde644b 100644 --- a/generated/stripe_shared/src/payment_method_boleto.rs +++ b/generated/stripe_shared/src/payment_method_boleto.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodBoleto { /// Uniquely identifies the customer tax id (CNPJ or CPF) pub tax_id: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodBoletoBuilder { + tax_id: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodBoleto { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodBoleto>, + builder: PaymentMethodBoletoBuilder, + } + + impl Visitor for Place<PaymentMethodBoleto> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodBoletoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodBoletoBuilder { + type Out = PaymentMethodBoleto; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "tax_id" => Deserialize::begin(&mut self.tax_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let tax_id = self.tax_id.take()?; + + Some(Self::Out { tax_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodBoleto { + type Builder = PaymentMethodBoletoBuilder; + } + + impl FromValueOpt for PaymentMethodBoleto { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodBoletoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "tax_id" => b.tax_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card.rs b/generated/stripe_shared/src/payment_method_card.rs index b9ca4b3ac..99099856c 100644 --- a/generated/stripe_shared/src/payment_method_card.rs +++ b/generated/stripe_shared/src/payment_method_card.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCard { /// Card brand. /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. @@ -10,7 +12,6 @@ pub struct PaymentMethodCard { pub country: Option<String>, /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// Two-digit number representing the card's expiration month. pub exp_month: i64, @@ -21,17 +22,14 @@ pub struct PaymentMethodCard { /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number. /// /// *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*. - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`. pub funding: String, /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, /// The last four digits of the card. pub last4: String, @@ -42,3 +40,156 @@ pub struct PaymentMethodCard { /// If this Card is part of a card wallet, this contains the details of the card wallet. pub wallet: Option<stripe_shared::PaymentMethodCardWallet>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardBuilder { + brand: Option<String>, + checks: Option<Option<stripe_shared::PaymentMethodCardChecks>>, + country: Option<Option<String>>, + description: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + fingerprint: Option<Option<String>>, + funding: Option<String>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<String>, + networks: Option<Option<stripe_shared::Networks>>, + three_d_secure_usage: Option<Option<stripe_shared::ThreeDSecureUsage>>, + wallet: Option<Option<stripe_shared::PaymentMethodCardWallet>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCard>, + builder: PaymentMethodCardBuilder, + } + + impl Visitor for Place<PaymentMethodCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardBuilder { + type Out = PaymentMethodCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "brand" => Deserialize::begin(&mut self.brand), + "checks" => Deserialize::begin(&mut self.checks), + "country" => Deserialize::begin(&mut self.country), + "description" => Deserialize::begin(&mut self.description), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "networks" => Deserialize::begin(&mut self.networks), + "three_d_secure_usage" => Deserialize::begin(&mut self.three_d_secure_usage), + "wallet" => Deserialize::begin(&mut self.wallet), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + brand: Deserialize::default(), + checks: Deserialize::default(), + country: Deserialize::default(), + description: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + networks: Deserialize::default(), + three_d_secure_usage: Deserialize::default(), + wallet: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let brand = self.brand.take()?; + let checks = self.checks.take()?; + let country = self.country.take()?; + let description = self.description.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let networks = self.networks.take()?; + let three_d_secure_usage = self.three_d_secure_usage.take()?; + let wallet = self.wallet.take()?; + + Some(Self::Out { brand, checks, country, description, exp_month, exp_year, fingerprint, funding, iin, issuer, last4, networks, three_d_secure_usage, wallet }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCard { + type Builder = PaymentMethodCardBuilder; + } + + impl FromValueOpt for PaymentMethodCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "checks" => b.checks = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "networks" => b.networks = Some(FromValueOpt::from_value(v)?), + "three_d_secure_usage" => b.three_d_secure_usage = Some(FromValueOpt::from_value(v)?), + "wallet" => b.wallet = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_checks.rs b/generated/stripe_shared/src/payment_method_card_checks.rs index 4d44d424b..7ba5f0dbc 100644 --- a/generated/stripe_shared/src/payment_method_card_checks.rs +++ b/generated/stripe_shared/src/payment_method_card_checks.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardChecks { /// If a address line1 was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub address_line1_check: Option<String>, @@ -7,3 +9,97 @@ pub struct PaymentMethodCardChecks { /// If a CVC was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub cvc_check: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardChecksBuilder { + address_line1_check: Option<Option<String>>, + address_postal_code_check: Option<Option<String>>, + cvc_check: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardChecks { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardChecks>, + builder: PaymentMethodCardChecksBuilder, + } + + impl Visitor for Place<PaymentMethodCardChecks> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardChecksBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardChecksBuilder { + type Out = PaymentMethodCardChecks; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address_line1_check" => Deserialize::begin(&mut self.address_line1_check), + "address_postal_code_check" => Deserialize::begin(&mut self.address_postal_code_check), + "cvc_check" => Deserialize::begin(&mut self.cvc_check), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address_line1_check: Deserialize::default(), address_postal_code_check: Deserialize::default(), cvc_check: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address_line1_check = self.address_line1_check.take()?; + let address_postal_code_check = self.address_postal_code_check.take()?; + let cvc_check = self.cvc_check.take()?; + + Some(Self::Out { address_line1_check, address_postal_code_check, cvc_check }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardChecks { + type Builder = PaymentMethodCardChecksBuilder; + } + + impl FromValueOpt for PaymentMethodCardChecks { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardChecksBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address_line1_check" => b.address_line1_check = Some(FromValueOpt::from_value(v)?), + "address_postal_code_check" => b.address_postal_code_check = Some(FromValueOpt::from_value(v)?), + "cvc_check" => b.cvc_check = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_present.rs b/generated/stripe_shared/src/payment_method_card_present.rs index 7777c00da..2d444dd35 100644 --- a/generated/stripe_shared/src/payment_method_card_present.rs +++ b/generated/stripe_shared/src/payment_method_card_present.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardPresent { /// Card brand. /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. @@ -13,7 +15,6 @@ pub struct PaymentMethodCardPresent { pub country: Option<String>, /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// Two-digit number representing the card's expiration month. pub exp_month: i64, @@ -29,11 +30,9 @@ pub struct PaymentMethodCardPresent { pub funding: Option<String>, /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, /// The last four digits of the card. pub last4: Option<String>, @@ -42,6 +41,154 @@ pub struct PaymentMethodCardPresent { /// How card details were read in this transaction. pub read_method: Option<PaymentMethodCardPresentReadMethod>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardPresentBuilder { + brand: Option<Option<String>>, + cardholder_name: Option<Option<String>>, + country: Option<Option<String>>, + description: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + networks: Option<Option<stripe_shared::PaymentMethodCardPresentNetworks>>, + read_method: Option<Option<PaymentMethodCardPresentReadMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardPresent>, + builder: PaymentMethodCardPresentBuilder, + } + + impl Visitor for Place<PaymentMethodCardPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardPresentBuilder { + type Out = PaymentMethodCardPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "brand" => Deserialize::begin(&mut self.brand), + "cardholder_name" => Deserialize::begin(&mut self.cardholder_name), + "country" => Deserialize::begin(&mut self.country), + "description" => Deserialize::begin(&mut self.description), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "networks" => Deserialize::begin(&mut self.networks), + "read_method" => Deserialize::begin(&mut self.read_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + brand: Deserialize::default(), + cardholder_name: Deserialize::default(), + country: Deserialize::default(), + description: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + networks: Deserialize::default(), + read_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let brand = self.brand.take()?; + let cardholder_name = self.cardholder_name.take()?; + let country = self.country.take()?; + let description = self.description.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let networks = self.networks.take()?; + let read_method = self.read_method.take()?; + + Some(Self::Out { brand, cardholder_name, country, description, exp_month, exp_year, fingerprint, funding, iin, issuer, last4, networks, read_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardPresent { + type Builder = PaymentMethodCardPresentBuilder; + } + + impl FromValueOpt for PaymentMethodCardPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "cardholder_name" => b.cardholder_name = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "networks" => b.networks = Some(FromValueOpt::from_value(v)?), + "read_method" => b.read_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// How card details were read in this transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodCardPresentReadMethod { @@ -101,8 +248,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodCardPresentReadMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodCardPresentReadMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodCardPresentReadMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodCardPresentReadMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodCardPresentReadMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodCardPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodCardPresentReadMethod); diff --git a/generated/stripe_shared/src/payment_method_card_present_networks.rs b/generated/stripe_shared/src/payment_method_card_present_networks.rs index 6385e724c..176162576 100644 --- a/generated/stripe_shared/src/payment_method_card_present_networks.rs +++ b/generated/stripe_shared/src/payment_method_card_present_networks.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardPresentNetworks { /// All available networks for the card. pub available: Vec<String>, /// The preferred network for the card. pub preferred: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardPresentNetworksBuilder { + available: Option<Vec<String>>, + preferred: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardPresentNetworks { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardPresentNetworks>, + builder: PaymentMethodCardPresentNetworksBuilder, + } + + impl Visitor for Place<PaymentMethodCardPresentNetworks> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardPresentNetworksBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardPresentNetworksBuilder { + type Out = PaymentMethodCardPresentNetworks; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available" => Deserialize::begin(&mut self.available), + "preferred" => Deserialize::begin(&mut self.preferred), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default(), preferred: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available = self.available.take()?; + let preferred = self.preferred.take()?; + + Some(Self::Out { available, preferred }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardPresentNetworks { + type Builder = PaymentMethodCardPresentNetworksBuilder; + } + + impl FromValueOpt for PaymentMethodCardPresentNetworks { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardPresentNetworksBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available" => b.available = Some(FromValueOpt::from_value(v)?), + "preferred" => b.preferred = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_wallet.rs b/generated/stripe_shared/src/payment_method_card_wallet.rs index 8dec84790..3abd64913 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet.rs @@ -1,27 +1,150 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWallet { - #[serde(skip_serializing_if = "Option::is_none")] pub amex_express_checkout: Option<stripe_shared::PaymentMethodCardWalletAmexExpressCheckout>, - #[serde(skip_serializing_if = "Option::is_none")] pub apple_pay: Option<stripe_shared::PaymentMethodCardWalletApplePay>, /// (For tokenized numbers only.) The last four digits of the device account number. pub dynamic_last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option<stripe_shared::PaymentMethodCardWalletGooglePay>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::PaymentMethodCardWalletLink>, - #[serde(skip_serializing_if = "Option::is_none")] pub masterpass: Option<stripe_shared::PaymentMethodCardWalletMasterpass>, - #[serde(skip_serializing_if = "Option::is_none")] pub samsung_pay: Option<stripe_shared::PaymentMethodCardWalletSamsungPay>, /// The type of the card wallet, one of `amex_express_checkout`, `apple_pay`, `google_pay`, `masterpass`, `samsung_pay`, `visa_checkout`, or `link`. /// An additional hash is included on the Wallet subhash with a name matching this value. /// It contains additional information specific to the card wallet type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentMethodCardWalletType, - #[serde(skip_serializing_if = "Option::is_none")] pub visa_checkout: Option<stripe_shared::PaymentMethodCardWalletVisaCheckout>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletBuilder { + amex_express_checkout: Option<Option<stripe_shared::PaymentMethodCardWalletAmexExpressCheckout>>, + apple_pay: Option<Option<stripe_shared::PaymentMethodCardWalletApplePay>>, + dynamic_last4: Option<Option<String>>, + google_pay: Option<Option<stripe_shared::PaymentMethodCardWalletGooglePay>>, + link: Option<Option<stripe_shared::PaymentMethodCardWalletLink>>, + masterpass: Option<Option<stripe_shared::PaymentMethodCardWalletMasterpass>>, + samsung_pay: Option<Option<stripe_shared::PaymentMethodCardWalletSamsungPay>>, + type_: Option<PaymentMethodCardWalletType>, + visa_checkout: Option<Option<stripe_shared::PaymentMethodCardWalletVisaCheckout>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWallet { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWallet>, + builder: PaymentMethodCardWalletBuilder, + } + + impl Visitor for Place<PaymentMethodCardWallet> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletBuilder { + type Out = PaymentMethodCardWallet; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amex_express_checkout" => Deserialize::begin(&mut self.amex_express_checkout), + "apple_pay" => Deserialize::begin(&mut self.apple_pay), + "dynamic_last4" => Deserialize::begin(&mut self.dynamic_last4), + "google_pay" => Deserialize::begin(&mut self.google_pay), + "link" => Deserialize::begin(&mut self.link), + "masterpass" => Deserialize::begin(&mut self.masterpass), + "samsung_pay" => Deserialize::begin(&mut self.samsung_pay), + "type" => Deserialize::begin(&mut self.type_), + "visa_checkout" => Deserialize::begin(&mut self.visa_checkout), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amex_express_checkout: Deserialize::default(), + apple_pay: Deserialize::default(), + dynamic_last4: Deserialize::default(), + google_pay: Deserialize::default(), + link: Deserialize::default(), + masterpass: Deserialize::default(), + samsung_pay: Deserialize::default(), + type_: Deserialize::default(), + visa_checkout: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amex_express_checkout = self.amex_express_checkout.take()?; + let apple_pay = self.apple_pay.take()?; + let dynamic_last4 = self.dynamic_last4.take()?; + let google_pay = self.google_pay.take()?; + let link = self.link.take()?; + let masterpass = self.masterpass.take()?; + let samsung_pay = self.samsung_pay.take()?; + let type_ = self.type_.take()?; + let visa_checkout = self.visa_checkout.take()?; + + Some(Self::Out { amex_express_checkout, apple_pay, dynamic_last4, google_pay, link, masterpass, samsung_pay, type_, visa_checkout }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWallet { + type Builder = PaymentMethodCardWalletBuilder; + } + + impl FromValueOpt for PaymentMethodCardWallet { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amex_express_checkout" => b.amex_express_checkout = Some(FromValueOpt::from_value(v)?), + "apple_pay" => b.apple_pay = Some(FromValueOpt::from_value(v)?), + "dynamic_last4" => b.dynamic_last4 = Some(FromValueOpt::from_value(v)?), + "google_pay" => b.google_pay = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "masterpass" => b.masterpass = Some(FromValueOpt::from_value(v)?), + "samsung_pay" => b.samsung_pay = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "visa_checkout" => b.visa_checkout = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the card wallet, one of `amex_express_checkout`, `apple_pay`, `google_pay`, `masterpass`, `samsung_pay`, `visa_checkout`, or `link`. /// An additional hash is included on the Wallet subhash with a name matching this value. /// It contains additional information specific to the card wallet type. @@ -89,7 +212,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodCardWalletType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodCardWalletType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodCardWalletType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodCardWalletType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodCardWalletType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodCardWalletType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodCardWalletType); diff --git a/generated/stripe_shared/src/payment_method_card_wallet_amex_express_checkout.rs b/generated/stripe_shared/src/payment_method_card_wallet_amex_express_checkout.rs index e96dafb68..9b5791566 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet_amex_express_checkout.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet_amex_express_checkout.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWalletAmexExpressCheckout {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletAmexExpressCheckoutBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWalletAmexExpressCheckout { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWalletAmexExpressCheckout>, + builder: PaymentMethodCardWalletAmexExpressCheckoutBuilder, + } + + impl Visitor for Place<PaymentMethodCardWalletAmexExpressCheckout> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletAmexExpressCheckoutBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletAmexExpressCheckoutBuilder { + type Out = PaymentMethodCardWalletAmexExpressCheckout; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWalletAmexExpressCheckout { + type Builder = PaymentMethodCardWalletAmexExpressCheckoutBuilder; + } + + impl FromValueOpt for PaymentMethodCardWalletAmexExpressCheckout { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletAmexExpressCheckoutBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_wallet_apple_pay.rs b/generated/stripe_shared/src/payment_method_card_wallet_apple_pay.rs index 9948e0e45..6e6a1334f 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet_apple_pay.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet_apple_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWalletApplePay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletApplePayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWalletApplePay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWalletApplePay>, + builder: PaymentMethodCardWalletApplePayBuilder, + } + + impl Visitor for Place<PaymentMethodCardWalletApplePay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletApplePayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletApplePayBuilder { + type Out = PaymentMethodCardWalletApplePay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWalletApplePay { + type Builder = PaymentMethodCardWalletApplePayBuilder; + } + + impl FromValueOpt for PaymentMethodCardWalletApplePay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletApplePayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_wallet_google_pay.rs b/generated/stripe_shared/src/payment_method_card_wallet_google_pay.rs index c7282dd73..f2774b694 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet_google_pay.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet_google_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWalletGooglePay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletGooglePayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWalletGooglePay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWalletGooglePay>, + builder: PaymentMethodCardWalletGooglePayBuilder, + } + + impl Visitor for Place<PaymentMethodCardWalletGooglePay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletGooglePayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletGooglePayBuilder { + type Out = PaymentMethodCardWalletGooglePay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWalletGooglePay { + type Builder = PaymentMethodCardWalletGooglePayBuilder; + } + + impl FromValueOpt for PaymentMethodCardWalletGooglePay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletGooglePayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_wallet_link.rs b/generated/stripe_shared/src/payment_method_card_wallet_link.rs index ba0b9d736..018883235 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet_link.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet_link.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWalletLink {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletLinkBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWalletLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWalletLink>, + builder: PaymentMethodCardWalletLinkBuilder, + } + + impl Visitor for Place<PaymentMethodCardWalletLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletLinkBuilder { + type Out = PaymentMethodCardWalletLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWalletLink { + type Builder = PaymentMethodCardWalletLinkBuilder; + } + + impl FromValueOpt for PaymentMethodCardWalletLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_wallet_masterpass.rs b/generated/stripe_shared/src/payment_method_card_wallet_masterpass.rs index 281b61fb8..a2b14213b 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet_masterpass.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet_masterpass.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWalletMasterpass { /// Owner's verified billing address. /// Values are verified or provided by the wallet directly (if supported) at the time of authorization or settlement. @@ -17,3 +19,101 @@ pub struct PaymentMethodCardWalletMasterpass { /// They cannot be set or mutated. pub shipping_address: Option<stripe_shared::Address>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletMasterpassBuilder { + billing_address: Option<Option<stripe_shared::Address>>, + email: Option<Option<String>>, + name: Option<Option<String>>, + shipping_address: Option<Option<stripe_shared::Address>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWalletMasterpass { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWalletMasterpass>, + builder: PaymentMethodCardWalletMasterpassBuilder, + } + + impl Visitor for Place<PaymentMethodCardWalletMasterpass> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletMasterpassBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletMasterpassBuilder { + type Out = PaymentMethodCardWalletMasterpass; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_address" => Deserialize::begin(&mut self.billing_address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + "shipping_address" => Deserialize::begin(&mut self.shipping_address), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_address: Deserialize::default(), email: Deserialize::default(), name: Deserialize::default(), shipping_address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_address = self.billing_address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + let shipping_address = self.shipping_address.take()?; + + Some(Self::Out { billing_address, email, name, shipping_address }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWalletMasterpass { + type Builder = PaymentMethodCardWalletMasterpassBuilder; + } + + impl FromValueOpt for PaymentMethodCardWalletMasterpass { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletMasterpassBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_address" => b.billing_address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "shipping_address" => b.shipping_address = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_wallet_samsung_pay.rs b/generated/stripe_shared/src/payment_method_card_wallet_samsung_pay.rs index e015c6843..a6eb99f5e 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet_samsung_pay.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet_samsung_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWalletSamsungPay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletSamsungPayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWalletSamsungPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWalletSamsungPay>, + builder: PaymentMethodCardWalletSamsungPayBuilder, + } + + impl Visitor for Place<PaymentMethodCardWalletSamsungPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletSamsungPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletSamsungPayBuilder { + type Out = PaymentMethodCardWalletSamsungPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWalletSamsungPay { + type Builder = PaymentMethodCardWalletSamsungPayBuilder; + } + + impl FromValueOpt for PaymentMethodCardWalletSamsungPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletSamsungPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_card_wallet_visa_checkout.rs b/generated/stripe_shared/src/payment_method_card_wallet_visa_checkout.rs index ff4dfe3ec..0bbc1682d 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet_visa_checkout.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet_visa_checkout.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCardWalletVisaCheckout { /// Owner's verified billing address. /// Values are verified or provided by the wallet directly (if supported) at the time of authorization or settlement. @@ -17,3 +19,101 @@ pub struct PaymentMethodCardWalletVisaCheckout { /// They cannot be set or mutated. pub shipping_address: Option<stripe_shared::Address>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCardWalletVisaCheckoutBuilder { + billing_address: Option<Option<stripe_shared::Address>>, + email: Option<Option<String>>, + name: Option<Option<String>>, + shipping_address: Option<Option<stripe_shared::Address>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCardWalletVisaCheckout { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCardWalletVisaCheckout>, + builder: PaymentMethodCardWalletVisaCheckoutBuilder, + } + + impl Visitor for Place<PaymentMethodCardWalletVisaCheckout> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCardWalletVisaCheckoutBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCardWalletVisaCheckoutBuilder { + type Out = PaymentMethodCardWalletVisaCheckout; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_address" => Deserialize::begin(&mut self.billing_address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + "shipping_address" => Deserialize::begin(&mut self.shipping_address), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_address: Deserialize::default(), email: Deserialize::default(), name: Deserialize::default(), shipping_address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_address = self.billing_address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + let shipping_address = self.shipping_address.take()?; + + Some(Self::Out { billing_address, email, name, shipping_address }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCardWalletVisaCheckout { + type Builder = PaymentMethodCardWalletVisaCheckoutBuilder; + } + + impl FromValueOpt for PaymentMethodCardWalletVisaCheckout { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCardWalletVisaCheckoutBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_address" => b.billing_address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "shipping_address" => b.shipping_address = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_cashapp.rs b/generated/stripe_shared/src/payment_method_cashapp.rs index f2d838cc6..734fb8379 100644 --- a/generated/stripe_shared/src/payment_method_cashapp.rs +++ b/generated/stripe_shared/src/payment_method_cashapp.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCashapp { /// A unique and immutable identifier assigned by Cash App to every buyer. pub buyer_id: Option<String>, /// A public identifier for buyers using Cash App. pub cashtag: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCashappBuilder { + buyer_id: Option<Option<String>>, + cashtag: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCashapp { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCashapp>, + builder: PaymentMethodCashappBuilder, + } + + impl Visitor for Place<PaymentMethodCashapp> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCashappBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCashappBuilder { + type Out = PaymentMethodCashapp; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "buyer_id" => Deserialize::begin(&mut self.buyer_id), + "cashtag" => Deserialize::begin(&mut self.cashtag), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { buyer_id: Deserialize::default(), cashtag: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let buyer_id = self.buyer_id.take()?; + let cashtag = self.cashtag.take()?; + + Some(Self::Out { buyer_id, cashtag }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCashapp { + type Builder = PaymentMethodCashappBuilder; + } + + impl FromValueOpt for PaymentMethodCashapp { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCashappBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "buyer_id" => b.buyer_id = Some(FromValueOpt::from_value(v)?), + "cashtag" => b.cashtag = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_config_biz_payment_method_configuration_details.rs b/generated/stripe_shared/src/payment_method_config_biz_payment_method_configuration_details.rs index 58c432f62..e3fd7cffa 100644 --- a/generated/stripe_shared/src/payment_method_config_biz_payment_method_configuration_details.rs +++ b/generated/stripe_shared/src/payment_method_config_biz_payment_method_configuration_details.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodConfigBizPaymentMethodConfigurationDetails { /// ID of the payment method configuration used. pub id: String, /// ID of the parent payment method configuration used. pub parent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder { + id: Option<String>, + parent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodConfigBizPaymentMethodConfigurationDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodConfigBizPaymentMethodConfigurationDetails>, + builder: PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder, + } + + impl Visitor for Place<PaymentMethodConfigBizPaymentMethodConfigurationDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder { + type Out = PaymentMethodConfigBizPaymentMethodConfigurationDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "parent" => Deserialize::begin(&mut self.parent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), parent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let parent = self.parent.take()?; + + Some(Self::Out { id, parent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodConfigBizPaymentMethodConfigurationDetails { + type Builder = PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder; + } + + impl FromValueOpt for PaymentMethodConfigBizPaymentMethodConfigurationDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "parent" => b.parent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_customer_balance.rs b/generated/stripe_shared/src/payment_method_customer_balance.rs index 6e1cd2152..86204f8be 100644 --- a/generated/stripe_shared/src/payment_method_customer_balance.rs +++ b/generated/stripe_shared/src/payment_method_customer_balance.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodCustomerBalance {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodCustomerBalanceBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodCustomerBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodCustomerBalance>, + builder: PaymentMethodCustomerBalanceBuilder, + } + + impl Visitor for Place<PaymentMethodCustomerBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodCustomerBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodCustomerBalanceBuilder { + type Out = PaymentMethodCustomerBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodCustomerBalance { + type Builder = PaymentMethodCustomerBalanceBuilder; + } + + impl FromValueOpt for PaymentMethodCustomerBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodCustomerBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details.rs b/generated/stripe_shared/src/payment_method_details.rs index bcb6ce6ba..ac0644dba 100644 --- a/generated/stripe_shared/src/payment_method_details.rs +++ b/generated/stripe_shared/src/payment_method_details.rs @@ -1,90 +1,380 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub ach_credit_transfer: Option<stripe_shared::PaymentMethodDetailsAchCreditTransfer>, - #[serde(skip_serializing_if = "Option::is_none")] pub ach_debit: Option<stripe_shared::PaymentMethodDetailsAchDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_shared::PaymentMethodDetailsAcssDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option<stripe_shared::PaymentMethodDetailsAffirm>, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option<stripe_shared::PaymentMethodDetailsAfterpayClearpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsAlipayDetails>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_shared::PaymentMethodDetailsAuBecsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_shared::PaymentMethodDetailsBacsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option<stripe_shared::PaymentMethodDetailsBancontact>, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option<stripe_shared::PaymentMethodDetailsBlik>, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<stripe_shared::PaymentMethodDetailsBoleto>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::PaymentMethodDetailsCard>, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option<stripe_shared::PaymentMethodDetailsCardPresent>, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option<stripe_shared::PaymentMethodDetailsCashapp>, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option<stripe_shared::PaymentMethodDetailsCustomerBalance>, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option<stripe_shared::PaymentMethodDetailsEps>, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option<stripe_shared::PaymentMethodDetailsFpx>, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option<stripe_shared::PaymentMethodDetailsGiropay>, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option<stripe_shared::PaymentMethodDetailsGrabpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option<stripe_shared::PaymentMethodDetailsIdeal>, - #[serde(skip_serializing_if = "Option::is_none")] pub interac_present: Option<stripe_shared::PaymentMethodDetailsInteracPresent>, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option<stripe_shared::PaymentMethodDetailsKlarna>, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option<stripe_shared::PaymentMethodDetailsKonbini>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::PaymentMethodDetailsLink>, - #[serde(skip_serializing_if = "Option::is_none")] pub multibanco: Option<stripe_shared::PaymentMethodDetailsMultibanco>, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo: Option<stripe_shared::PaymentMethodDetailsOxxo>, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option<stripe_shared::PaymentMethodDetailsP24>, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option<stripe_shared::PaymentMethodDetailsPaynow>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_shared::PaymentMethodDetailsPaypal>, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option<stripe_shared::PaymentMethodDetailsPix>, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option<stripe_shared::PaymentMethodDetailsPromptpay>, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option<stripe_shared::PaymentMethodDetailsRevolutPay>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_credit_transfer: Option<stripe_shared::PaymentMethodDetailsSepaCreditTransfer>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_shared::PaymentMethodDetailsSepaDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<stripe_shared::PaymentMethodDetailsSofort>, - #[serde(skip_serializing_if = "Option::is_none")] pub stripe_account: Option<stripe_shared::PaymentMethodDetailsStripeAccount>, - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<stripe_shared::PaymentMethodDetailsSwish>, /// The type of transaction-specific details of the payment method used in the payment, one of `ach_credit_transfer`, `ach_debit`, `acss_debit`, `alipay`, `au_becs_debit`, `bancontact`, `card`, `card_present`, `eps`, `giropay`, `ideal`, `klarna`, `multibanco`, `p24`, `sepa_debit`, `sofort`, `stripe_account`, or `wechat`. /// An additional hash is included on `payment_method_details` with a name matching this value. /// It contains information specific to the payment method. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_shared::PaymentMethodDetailsUsBankAccount>, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat: Option<stripe_shared::PaymentMethodDetailsWechat>, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option<stripe_shared::PaymentMethodDetailsWechatPay>, - #[serde(skip_serializing_if = "Option::is_none")] pub zip: Option<stripe_shared::PaymentMethodDetailsZip>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsBuilder { + ach_credit_transfer: Option<Option<stripe_shared::PaymentMethodDetailsAchCreditTransfer>>, + ach_debit: Option<Option<stripe_shared::PaymentMethodDetailsAchDebit>>, + acss_debit: Option<Option<stripe_shared::PaymentMethodDetailsAcssDebit>>, + affirm: Option<Option<stripe_shared::PaymentMethodDetailsAffirm>>, + afterpay_clearpay: Option<Option<stripe_shared::PaymentMethodDetailsAfterpayClearpay>>, + alipay: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsAlipayDetails>>, + au_becs_debit: Option<Option<stripe_shared::PaymentMethodDetailsAuBecsDebit>>, + bacs_debit: Option<Option<stripe_shared::PaymentMethodDetailsBacsDebit>>, + bancontact: Option<Option<stripe_shared::PaymentMethodDetailsBancontact>>, + blik: Option<Option<stripe_shared::PaymentMethodDetailsBlik>>, + boleto: Option<Option<stripe_shared::PaymentMethodDetailsBoleto>>, + card: Option<Option<stripe_shared::PaymentMethodDetailsCard>>, + card_present: Option<Option<stripe_shared::PaymentMethodDetailsCardPresent>>, + cashapp: Option<Option<stripe_shared::PaymentMethodDetailsCashapp>>, + customer_balance: Option<Option<stripe_shared::PaymentMethodDetailsCustomerBalance>>, + eps: Option<Option<stripe_shared::PaymentMethodDetailsEps>>, + fpx: Option<Option<stripe_shared::PaymentMethodDetailsFpx>>, + giropay: Option<Option<stripe_shared::PaymentMethodDetailsGiropay>>, + grabpay: Option<Option<stripe_shared::PaymentMethodDetailsGrabpay>>, + ideal: Option<Option<stripe_shared::PaymentMethodDetailsIdeal>>, + interac_present: Option<Option<stripe_shared::PaymentMethodDetailsInteracPresent>>, + klarna: Option<Option<stripe_shared::PaymentMethodDetailsKlarna>>, + konbini: Option<Option<stripe_shared::PaymentMethodDetailsKonbini>>, + link: Option<Option<stripe_shared::PaymentMethodDetailsLink>>, + multibanco: Option<Option<stripe_shared::PaymentMethodDetailsMultibanco>>, + oxxo: Option<Option<stripe_shared::PaymentMethodDetailsOxxo>>, + p24: Option<Option<stripe_shared::PaymentMethodDetailsP24>>, + paynow: Option<Option<stripe_shared::PaymentMethodDetailsPaynow>>, + paypal: Option<Option<stripe_shared::PaymentMethodDetailsPaypal>>, + pix: Option<Option<stripe_shared::PaymentMethodDetailsPix>>, + promptpay: Option<Option<stripe_shared::PaymentMethodDetailsPromptpay>>, + revolut_pay: Option<Option<stripe_shared::PaymentMethodDetailsRevolutPay>>, + sepa_credit_transfer: Option<Option<stripe_shared::PaymentMethodDetailsSepaCreditTransfer>>, + sepa_debit: Option<Option<stripe_shared::PaymentMethodDetailsSepaDebit>>, + sofort: Option<Option<stripe_shared::PaymentMethodDetailsSofort>>, + stripe_account: Option<Option<stripe_shared::PaymentMethodDetailsStripeAccount>>, + type_: Option<String>, + us_bank_account: Option<Option<stripe_shared::PaymentMethodDetailsUsBankAccount>>, + wechat: Option<Option<stripe_shared::PaymentMethodDetailsWechat>>, + wechat_pay: Option<Option<stripe_shared::PaymentMethodDetailsWechatPay>>, + zip: Option<Option<stripe_shared::PaymentMethodDetailsZip>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetails>, + builder: PaymentMethodDetailsBuilder, + } + + impl Visitor for Place<PaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsBuilder { + type Out = PaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ach_credit_transfer" => Deserialize::begin(&mut self.ach_credit_transfer), + "ach_debit" => Deserialize::begin(&mut self.ach_debit), + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "affirm" => Deserialize::begin(&mut self.affirm), + "afterpay_clearpay" => Deserialize::begin(&mut self.afterpay_clearpay), + "alipay" => Deserialize::begin(&mut self.alipay), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "blik" => Deserialize::begin(&mut self.blik), + "boleto" => Deserialize::begin(&mut self.boleto), + "card" => Deserialize::begin(&mut self.card), + "card_present" => Deserialize::begin(&mut self.card_present), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "customer_balance" => Deserialize::begin(&mut self.customer_balance), + "eps" => Deserialize::begin(&mut self.eps), + "fpx" => Deserialize::begin(&mut self.fpx), + "giropay" => Deserialize::begin(&mut self.giropay), + "grabpay" => Deserialize::begin(&mut self.grabpay), + "ideal" => Deserialize::begin(&mut self.ideal), + "interac_present" => Deserialize::begin(&mut self.interac_present), + "klarna" => Deserialize::begin(&mut self.klarna), + "konbini" => Deserialize::begin(&mut self.konbini), + "link" => Deserialize::begin(&mut self.link), + "multibanco" => Deserialize::begin(&mut self.multibanco), + "oxxo" => Deserialize::begin(&mut self.oxxo), + "p24" => Deserialize::begin(&mut self.p24), + "paynow" => Deserialize::begin(&mut self.paynow), + "paypal" => Deserialize::begin(&mut self.paypal), + "pix" => Deserialize::begin(&mut self.pix), + "promptpay" => Deserialize::begin(&mut self.promptpay), + "revolut_pay" => Deserialize::begin(&mut self.revolut_pay), + "sepa_credit_transfer" => Deserialize::begin(&mut self.sepa_credit_transfer), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "sofort" => Deserialize::begin(&mut self.sofort), + "stripe_account" => Deserialize::begin(&mut self.stripe_account), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + "wechat" => Deserialize::begin(&mut self.wechat), + "wechat_pay" => Deserialize::begin(&mut self.wechat_pay), + "zip" => Deserialize::begin(&mut self.zip), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + ach_credit_transfer: Deserialize::default(), + ach_debit: Deserialize::default(), + acss_debit: Deserialize::default(), + affirm: Deserialize::default(), + afterpay_clearpay: Deserialize::default(), + alipay: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bacs_debit: Deserialize::default(), + bancontact: Deserialize::default(), + blik: Deserialize::default(), + boleto: Deserialize::default(), + card: Deserialize::default(), + card_present: Deserialize::default(), + cashapp: Deserialize::default(), + customer_balance: Deserialize::default(), + eps: Deserialize::default(), + fpx: Deserialize::default(), + giropay: Deserialize::default(), + grabpay: Deserialize::default(), + ideal: Deserialize::default(), + interac_present: Deserialize::default(), + klarna: Deserialize::default(), + konbini: Deserialize::default(), + link: Deserialize::default(), + multibanco: Deserialize::default(), + oxxo: Deserialize::default(), + p24: Deserialize::default(), + paynow: Deserialize::default(), + paypal: Deserialize::default(), + pix: Deserialize::default(), + promptpay: Deserialize::default(), + revolut_pay: Deserialize::default(), + sepa_credit_transfer: Deserialize::default(), + sepa_debit: Deserialize::default(), + sofort: Deserialize::default(), + stripe_account: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + wechat: Deserialize::default(), + wechat_pay: Deserialize::default(), + zip: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ach_credit_transfer = self.ach_credit_transfer.take()?; + let ach_debit = self.ach_debit.take()?; + let acss_debit = self.acss_debit.take()?; + let affirm = self.affirm.take()?; + let afterpay_clearpay = self.afterpay_clearpay.take()?; + let alipay = self.alipay.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bacs_debit = self.bacs_debit.take()?; + let bancontact = self.bancontact.take()?; + let blik = self.blik.take()?; + let boleto = self.boleto.take()?; + let card = self.card.take()?; + let card_present = self.card_present.take()?; + let cashapp = self.cashapp.take()?; + let customer_balance = self.customer_balance.take()?; + let eps = self.eps.take()?; + let fpx = self.fpx.take()?; + let giropay = self.giropay.take()?; + let grabpay = self.grabpay.take()?; + let ideal = self.ideal.take()?; + let interac_present = self.interac_present.take()?; + let klarna = self.klarna.take()?; + let konbini = self.konbini.take()?; + let link = self.link.take()?; + let multibanco = self.multibanco.take()?; + let oxxo = self.oxxo.take()?; + let p24 = self.p24.take()?; + let paynow = self.paynow.take()?; + let paypal = self.paypal.take()?; + let pix = self.pix.take()?; + let promptpay = self.promptpay.take()?; + let revolut_pay = self.revolut_pay.take()?; + let sepa_credit_transfer = self.sepa_credit_transfer.take()?; + let sepa_debit = self.sepa_debit.take()?; + let sofort = self.sofort.take()?; + let stripe_account = self.stripe_account.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + let wechat = self.wechat.take()?; + let wechat_pay = self.wechat_pay.take()?; + let zip = self.zip.take()?; + + Some(Self::Out { + ach_credit_transfer, + ach_debit, + acss_debit, + affirm, + afterpay_clearpay, + alipay, + au_becs_debit, + bacs_debit, + bancontact, + blik, + boleto, + card, + card_present, + cashapp, + customer_balance, + eps, + fpx, + giropay, + grabpay, + ideal, + interac_present, + klarna, + konbini, + link, + multibanco, + oxxo, + p24, + paynow, + paypal, + pix, + promptpay, + revolut_pay, + sepa_credit_transfer, + sepa_debit, + sofort, + stripe_account, + type_, + us_bank_account, + wechat, + wechat_pay, + zip, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetails { + type Builder = PaymentMethodDetailsBuilder; + } + + impl FromValueOpt for PaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ach_credit_transfer" => b.ach_credit_transfer = Some(FromValueOpt::from_value(v)?), + "ach_debit" => b.ach_debit = Some(FromValueOpt::from_value(v)?), + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "affirm" => b.affirm = Some(FromValueOpt::from_value(v)?), + "afterpay_clearpay" => b.afterpay_clearpay = Some(FromValueOpt::from_value(v)?), + "alipay" => b.alipay = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "blik" => b.blik = Some(FromValueOpt::from_value(v)?), + "boleto" => b.boleto = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "card_present" => b.card_present = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "customer_balance" => b.customer_balance = Some(FromValueOpt::from_value(v)?), + "eps" => b.eps = Some(FromValueOpt::from_value(v)?), + "fpx" => b.fpx = Some(FromValueOpt::from_value(v)?), + "giropay" => b.giropay = Some(FromValueOpt::from_value(v)?), + "grabpay" => b.grabpay = Some(FromValueOpt::from_value(v)?), + "ideal" => b.ideal = Some(FromValueOpt::from_value(v)?), + "interac_present" => b.interac_present = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "konbini" => b.konbini = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "multibanco" => b.multibanco = Some(FromValueOpt::from_value(v)?), + "oxxo" => b.oxxo = Some(FromValueOpt::from_value(v)?), + "p24" => b.p24 = Some(FromValueOpt::from_value(v)?), + "paynow" => b.paynow = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "pix" => b.pix = Some(FromValueOpt::from_value(v)?), + "promptpay" => b.promptpay = Some(FromValueOpt::from_value(v)?), + "revolut_pay" => b.revolut_pay = Some(FromValueOpt::from_value(v)?), + "sepa_credit_transfer" => b.sepa_credit_transfer = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "stripe_account" => b.stripe_account = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + "wechat" => b.wechat = Some(FromValueOpt::from_value(v)?), + "wechat_pay" => b.wechat_pay = Some(FromValueOpt::from_value(v)?), + "zip" => b.zip = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_ach_credit_transfer.rs b/generated/stripe_shared/src/payment_method_details_ach_credit_transfer.rs index be72e0222..2b7b4e676 100644 --- a/generated/stripe_shared/src/payment_method_details_ach_credit_transfer.rs +++ b/generated/stripe_shared/src/payment_method_details_ach_credit_transfer.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsAchCreditTransfer { /// Account number to transfer funds to. pub account_number: Option<String>, @@ -9,3 +11,101 @@ pub struct PaymentMethodDetailsAchCreditTransfer { /// SWIFT code of the bank associated with the routing number. pub swift_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsAchCreditTransferBuilder { + account_number: Option<Option<String>>, + bank_name: Option<Option<String>>, + routing_number: Option<Option<String>>, + swift_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsAchCreditTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsAchCreditTransfer>, + builder: PaymentMethodDetailsAchCreditTransferBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsAchCreditTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsAchCreditTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsAchCreditTransferBuilder { + type Out = PaymentMethodDetailsAchCreditTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_number" => Deserialize::begin(&mut self.account_number), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "routing_number" => Deserialize::begin(&mut self.routing_number), + "swift_code" => Deserialize::begin(&mut self.swift_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_number: Deserialize::default(), bank_name: Deserialize::default(), routing_number: Deserialize::default(), swift_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_number = self.account_number.take()?; + let bank_name = self.bank_name.take()?; + let routing_number = self.routing_number.take()?; + let swift_code = self.swift_code.take()?; + + Some(Self::Out { account_number, bank_name, routing_number, swift_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsAchCreditTransfer { + type Builder = PaymentMethodDetailsAchCreditTransferBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsAchCreditTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsAchCreditTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_number" => b.account_number = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + "swift_code" => b.swift_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_ach_debit.rs b/generated/stripe_shared/src/payment_method_details_ach_debit.rs index 1e41479cc..54f2e1f86 100644 --- a/generated/stripe_shared/src/payment_method_details_ach_debit.rs +++ b/generated/stripe_shared/src/payment_method_details_ach_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsAchDebit { /// Type of entity that holds the account. This can be either `individual` or `company`. pub account_holder_type: Option<PaymentMethodDetailsAchDebitAccountHolderType>, @@ -14,6 +16,119 @@ pub struct PaymentMethodDetailsAchDebit { /// Routing transit number of the bank account. pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsAchDebitBuilder { + account_holder_type: Option<Option<PaymentMethodDetailsAchDebitAccountHolderType>>, + bank_name: Option<Option<String>>, + country: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsAchDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsAchDebit>, + builder: PaymentMethodDetailsAchDebitBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsAchDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsAchDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsAchDebitBuilder { + type Out = PaymentMethodDetailsAchDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "country" => Deserialize::begin(&mut self.country), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_type: Deserialize::default(), + bank_name: Deserialize::default(), + country: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let bank_name = self.bank_name.take()?; + let country = self.country.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { account_holder_type, bank_name, country, fingerprint, last4, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsAchDebit { + type Builder = PaymentMethodDetailsAchDebitBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsAchDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsAchDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of entity that holds the account. This can be either `individual` or `company`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsAchDebitAccountHolderType { @@ -64,10 +179,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsAchDebitAccountHolderT fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsAchDebitAccountHolderType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsAchDebitAccountHolderType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsAchDebitAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsAchDebitAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsAchDebitAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsAchDebitAccountHolderType); diff --git a/generated/stripe_shared/src/payment_method_details_acss_debit.rs b/generated/stripe_shared/src/payment_method_details_acss_debit.rs index c9f1f96f3..2ae8441ad 100644 --- a/generated/stripe_shared/src/payment_method_details_acss_debit.rs +++ b/generated/stripe_shared/src/payment_method_details_acss_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsAcssDebit { /// Name of the bank associated with the bank account. pub bank_name: Option<String>, @@ -10,8 +12,120 @@ pub struct PaymentMethodDetailsAcssDebit { /// Last four digits of the bank account number. pub last4: Option<String>, /// ID of the mandate used to make this payment. - #[serde(skip_serializing_if = "Option::is_none")] pub mandate: Option<String>, /// Transit number of the bank account. pub transit_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsAcssDebitBuilder { + bank_name: Option<Option<String>>, + fingerprint: Option<Option<String>>, + institution_number: Option<Option<String>>, + last4: Option<Option<String>>, + mandate: Option<Option<String>>, + transit_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsAcssDebit>, + builder: PaymentMethodDetailsAcssDebitBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsAcssDebitBuilder { + type Out = PaymentMethodDetailsAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_name" => Deserialize::begin(&mut self.bank_name), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "institution_number" => Deserialize::begin(&mut self.institution_number), + "last4" => Deserialize::begin(&mut self.last4), + "mandate" => Deserialize::begin(&mut self.mandate), + "transit_number" => Deserialize::begin(&mut self.transit_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_name: Deserialize::default(), + fingerprint: Deserialize::default(), + institution_number: Deserialize::default(), + last4: Deserialize::default(), + mandate: Deserialize::default(), + transit_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_name = self.bank_name.take()?; + let fingerprint = self.fingerprint.take()?; + let institution_number = self.institution_number.take()?; + let last4 = self.last4.take()?; + let mandate = self.mandate.take()?; + let transit_number = self.transit_number.take()?; + + Some(Self::Out { bank_name, fingerprint, institution_number, last4, mandate, transit_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsAcssDebit { + type Builder = PaymentMethodDetailsAcssDebitBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "institution_number" => b.institution_number = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "mandate" => b.mandate = Some(FromValueOpt::from_value(v)?), + "transit_number" => b.transit_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_affirm.rs b/generated/stripe_shared/src/payment_method_details_affirm.rs index e88966e31..bd23cb968 100644 --- a/generated/stripe_shared/src/payment_method_details_affirm.rs +++ b/generated/stripe_shared/src/payment_method_details_affirm.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsAffirm {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsAffirmBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsAffirm { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsAffirm>, + builder: PaymentMethodDetailsAffirmBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsAffirm> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsAffirmBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsAffirmBuilder { + type Out = PaymentMethodDetailsAffirm; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsAffirm { + type Builder = PaymentMethodDetailsAffirmBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsAffirm { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsAffirmBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_afterpay_clearpay.rs b/generated/stripe_shared/src/payment_method_details_afterpay_clearpay.rs index a03a3296f..6525e09a6 100644 --- a/generated/stripe_shared/src/payment_method_details_afterpay_clearpay.rs +++ b/generated/stripe_shared/src/payment_method_details_afterpay_clearpay.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsAfterpayClearpay { /// The Afterpay order ID associated with this payment intent. pub order_id: Option<String>, /// Order identifier shown to the merchant in Afterpay’s online portal. pub reference: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsAfterpayClearpayBuilder { + order_id: Option<Option<String>>, + reference: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsAfterpayClearpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsAfterpayClearpay>, + builder: PaymentMethodDetailsAfterpayClearpayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsAfterpayClearpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsAfterpayClearpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsAfterpayClearpayBuilder { + type Out = PaymentMethodDetailsAfterpayClearpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "order_id" => Deserialize::begin(&mut self.order_id), + "reference" => Deserialize::begin(&mut self.reference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { order_id: Deserialize::default(), reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let order_id = self.order_id.take()?; + let reference = self.reference.take()?; + + Some(Self::Out { order_id, reference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsAfterpayClearpay { + type Builder = PaymentMethodDetailsAfterpayClearpayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsAfterpayClearpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsAfterpayClearpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "order_id" => b.order_id = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_au_becs_debit.rs b/generated/stripe_shared/src/payment_method_details_au_becs_debit.rs index bd8d92351..836168e5e 100644 --- a/generated/stripe_shared/src/payment_method_details_au_becs_debit.rs +++ b/generated/stripe_shared/src/payment_method_details_au_becs_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsAuBecsDebit { /// Bank-State-Branch number of the bank account. pub bsb_number: Option<String>, @@ -8,6 +10,103 @@ pub struct PaymentMethodDetailsAuBecsDebit { /// Last four digits of the bank account number. pub last4: Option<String>, /// ID of the mandate used to make this payment. - #[serde(skip_serializing_if = "Option::is_none")] pub mandate: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsAuBecsDebitBuilder { + bsb_number: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + mandate: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsAuBecsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsAuBecsDebit>, + builder: PaymentMethodDetailsAuBecsDebitBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsAuBecsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsAuBecsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsAuBecsDebitBuilder { + type Out = PaymentMethodDetailsAuBecsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bsb_number" => Deserialize::begin(&mut self.bsb_number), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "mandate" => Deserialize::begin(&mut self.mandate), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bsb_number: Deserialize::default(), fingerprint: Deserialize::default(), last4: Deserialize::default(), mandate: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bsb_number = self.bsb_number.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let mandate = self.mandate.take()?; + + Some(Self::Out { bsb_number, fingerprint, last4, mandate }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsAuBecsDebit { + type Builder = PaymentMethodDetailsAuBecsDebitBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsAuBecsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsAuBecsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bsb_number" => b.bsb_number = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "mandate" => b.mandate = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_bacs_debit.rs b/generated/stripe_shared/src/payment_method_details_bacs_debit.rs index 9d0e77bfe..6fd7eb798 100644 --- a/generated/stripe_shared/src/payment_method_details_bacs_debit.rs +++ b/generated/stripe_shared/src/payment_method_details_bacs_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsBacsDebit { /// Uniquely identifies this particular bank account. /// You can use this attribute to check whether two bank accounts are the same. @@ -10,3 +12,101 @@ pub struct PaymentMethodDetailsBacsDebit { /// Sort code of the bank account. (e.g., `10-20-30`) pub sort_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsBacsDebitBuilder { + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + mandate: Option<Option<String>>, + sort_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsBacsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsBacsDebit>, + builder: PaymentMethodDetailsBacsDebitBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsBacsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsBacsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsBacsDebitBuilder { + type Out = PaymentMethodDetailsBacsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "mandate" => Deserialize::begin(&mut self.mandate), + "sort_code" => Deserialize::begin(&mut self.sort_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { fingerprint: Deserialize::default(), last4: Deserialize::default(), mandate: Deserialize::default(), sort_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let mandate = self.mandate.take()?; + let sort_code = self.sort_code.take()?; + + Some(Self::Out { fingerprint, last4, mandate, sort_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsBacsDebit { + type Builder = PaymentMethodDetailsBacsDebitBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsBacsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsBacsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "mandate" => b.mandate = Some(FromValueOpt::from_value(v)?), + "sort_code" => b.sort_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_bancontact.rs b/generated/stripe_shared/src/payment_method_details_bancontact.rs index f0948896c..26ddbf558 100644 --- a/generated/stripe_shared/src/payment_method_details_bancontact.rs +++ b/generated/stripe_shared/src/payment_method_details_bancontact.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsBancontact { /// Bank code of bank associated with the bank account. pub bank_code: Option<String>, @@ -19,6 +21,129 @@ pub struct PaymentMethodDetailsBancontact { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsBancontactBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + generated_sepa_debit: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + generated_sepa_debit_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + iban_last4: Option<Option<String>>, + preferred_language: Option<Option<PaymentMethodDetailsBancontactPreferredLanguage>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsBancontact { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsBancontact>, + builder: PaymentMethodDetailsBancontactBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsBancontact> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsBancontactBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsBancontactBuilder { + type Out = PaymentMethodDetailsBancontact; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "generated_sepa_debit" => Deserialize::begin(&mut self.generated_sepa_debit), + "generated_sepa_debit_mandate" => Deserialize::begin(&mut self.generated_sepa_debit_mandate), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + bic: Deserialize::default(), + generated_sepa_debit: Deserialize::default(), + generated_sepa_debit_mandate: Deserialize::default(), + iban_last4: Deserialize::default(), + preferred_language: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let generated_sepa_debit = self.generated_sepa_debit.take()?; + let generated_sepa_debit_mandate = self.generated_sepa_debit_mandate.take()?; + let iban_last4 = self.iban_last4.take()?; + let preferred_language = self.preferred_language.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank_code, bank_name, bic, generated_sepa_debit, generated_sepa_debit_mandate, iban_last4, preferred_language, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsBancontact { + type Builder = PaymentMethodDetailsBancontactBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsBancontact { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsBancontactBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit" => b.generated_sepa_debit = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit_mandate" => b.generated_sepa_debit_mandate = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred language of the Bancontact authorization page that the customer is redirected to. /// Can be one of `en`, `de`, `fr`, or `nl` #[derive(Copy, Clone, Eq, PartialEq)] @@ -76,10 +201,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsBancontactPreferredLan fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsBancontactPreferredLanguage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsBancontactPreferredLanguage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsBancontactPreferredLanguage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsBancontactPreferredLanguage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsBancontactPreferredLanguage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsBancontactPreferredLanguage); diff --git a/generated/stripe_shared/src/payment_method_details_blik.rs b/generated/stripe_shared/src/payment_method_details_blik.rs index d19223ff9..925c8968f 100644 --- a/generated/stripe_shared/src/payment_method_details_blik.rs +++ b/generated/stripe_shared/src/payment_method_details_blik.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsBlik {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsBlikBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsBlik { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsBlik>, + builder: PaymentMethodDetailsBlikBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsBlik> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsBlikBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsBlikBuilder { + type Out = PaymentMethodDetailsBlik; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsBlik { + type Builder = PaymentMethodDetailsBlikBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsBlik { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsBlikBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_boleto.rs b/generated/stripe_shared/src/payment_method_details_boleto.rs index ef12f5e3f..26994c7bc 100644 --- a/generated/stripe_shared/src/payment_method_details_boleto.rs +++ b/generated/stripe_shared/src/payment_method_details_boleto.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsBoleto { /// The tax ID of the customer (CPF for individuals consumers or CNPJ for businesses consumers) pub tax_id: String, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsBoletoBuilder { + tax_id: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsBoleto { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsBoleto>, + builder: PaymentMethodDetailsBoletoBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsBoleto> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsBoletoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsBoletoBuilder { + type Out = PaymentMethodDetailsBoleto; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "tax_id" => Deserialize::begin(&mut self.tax_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let tax_id = self.tax_id.take()?; + + Some(Self::Out { tax_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsBoleto { + type Builder = PaymentMethodDetailsBoletoBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsBoleto { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsBoletoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "tax_id" => b.tax_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card.rs b/generated/stripe_shared/src/payment_method_details_card.rs index 01f4e216c..0e02bcd71 100644 --- a/generated/stripe_shared/src/payment_method_details_card.rs +++ b/generated/stripe_shared/src/payment_method_details_card.rs @@ -1,71 +1,289 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCard { /// The authorized amount. -pub amount_authorized: Option<i64>, - /// Card brand. + pub amount_authorized: Option<i64>, + /// Card brand. /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. -pub brand: Option<String>, - /// When using manual capture, a future timestamp at which the charge will be automatically refunded if uncaptured. -#[serde(skip_serializing_if = "Option::is_none")] -pub capture_before: Option<stripe_types::Timestamp>, + pub brand: Option<String>, + /// When using manual capture, a future timestamp at which the charge will be automatically refunded if uncaptured. + pub capture_before: Option<stripe_types::Timestamp>, /// Check results by Card networks on Card address and CVC at time of payment. -pub checks: Option<stripe_shared::PaymentMethodDetailsCardChecks>, - /// Two-letter ISO code representing the country of the card. + pub checks: Option<stripe_shared::PaymentMethodDetailsCardChecks>, + /// Two-letter ISO code representing the country of the card. /// You could use this attribute to get a sense of the international breakdown of cards you've collected. -pub country: Option<String>, - /// A high-level description of the type of cards issued in this range. + pub country: Option<String>, + /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). -#[serde(skip_serializing_if = "Option::is_none")] -pub description: Option<String>, + pub description: Option<String>, /// Two-digit number representing the card's expiration month. -pub exp_month: i64, + pub exp_month: i64, /// Four-digit number representing the card's expiration year. -pub exp_year: i64, -#[serde(skip_serializing_if = "Option::is_none")] -pub extended_authorization: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization>, - /// Uniquely identifies this particular card number. + pub exp_year: i64, + pub extended_authorization: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization>, + /// Uniquely identifies this particular card number. /// You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example. /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number. /// - /// *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*. -#[serde(skip_serializing_if = "Option::is_none")] -pub fingerprint: Option<String>, + /// *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*. + pub fingerprint: Option<String>, /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`. -pub funding: Option<String>, - /// Issuer identification number of the card. + pub funding: Option<String>, + /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). -#[serde(skip_serializing_if = "Option::is_none")] -pub iin: Option<String>, -#[serde(skip_serializing_if = "Option::is_none")] -pub incremental_authorization: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization>, + pub iin: Option<String>, + pub incremental_authorization: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization>, /// Installment details for this payment (Mexico only). /// - /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). -pub installments: Option<stripe_shared::PaymentMethodDetailsCardInstallments>, - /// The name of the card's issuing bank. + /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). + pub installments: Option<stripe_shared::PaymentMethodDetailsCardInstallments>, + /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). -#[serde(skip_serializing_if = "Option::is_none")] -pub issuer: Option<String>, + pub issuer: Option<String>, /// The last four digits of the card. -pub last4: Option<String>, + pub last4: Option<String>, /// ID of the mandate used to make this payment or created by it. -pub mandate: Option<String>, + pub mandate: Option<String>, /// True if this payment was marked as MOTO and out of scope for SCA. -#[serde(skip_serializing_if = "Option::is_none")] -pub moto: Option<bool>, -#[serde(skip_serializing_if = "Option::is_none")] -pub multicapture: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture>, - /// Identifies which network this charge was processed on. + pub moto: Option<bool>, + pub multicapture: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture>, + /// Identifies which network this charge was processed on. /// Can be `amex`, `cartes_bancaires`, `diners`, `discover`, `eftpos_au`, `interac`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. -pub network: Option<String>, - /// If this card has network token credentials, this contains the details of the network token credentials. -#[serde(skip_serializing_if = "Option::is_none")] -pub network_token: Option<stripe_shared::PaymentMethodDetailsCardNetworkToken>, -#[serde(skip_serializing_if = "Option::is_none")] -pub overcapture: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture>, + pub network: Option<String>, + /// If this card has network token credentials, this contains the details of the network token credentials. + pub network_token: Option<stripe_shared::PaymentMethodDetailsCardNetworkToken>, + pub overcapture: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture>, /// Populated if this transaction used 3D Secure authentication. -pub three_d_secure: Option<stripe_shared::ThreeDSecureDetailsCharge>, + pub three_d_secure: Option<stripe_shared::ThreeDSecureDetailsCharge>, /// If this Card is part of a card wallet, this contains the details of the card wallet. -pub wallet: Option<stripe_shared::PaymentMethodDetailsCardWallet>, - + pub wallet: Option<stripe_shared::PaymentMethodDetailsCardWallet>, +} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardBuilder { + amount_authorized: Option<Option<i64>>, + brand: Option<Option<String>>, + capture_before: Option<Option<stripe_types::Timestamp>>, + checks: Option<Option<stripe_shared::PaymentMethodDetailsCardChecks>>, + country: Option<Option<String>>, + description: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + extended_authorization: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization>>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + iin: Option<Option<String>>, + incremental_authorization: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization>>, + installments: Option<Option<stripe_shared::PaymentMethodDetailsCardInstallments>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + mandate: Option<Option<String>>, + moto: Option<Option<bool>>, + multicapture: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture>>, + network: Option<Option<String>>, + network_token: Option<Option<stripe_shared::PaymentMethodDetailsCardNetworkToken>>, + overcapture: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture>>, + three_d_secure: Option<Option<stripe_shared::ThreeDSecureDetailsCharge>>, + wallet: Option<Option<stripe_shared::PaymentMethodDetailsCardWallet>>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCard>, + builder: PaymentMethodDetailsCardBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardBuilder { + type Out = PaymentMethodDetailsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_authorized" => Deserialize::begin(&mut self.amount_authorized), + "brand" => Deserialize::begin(&mut self.brand), + "capture_before" => Deserialize::begin(&mut self.capture_before), + "checks" => Deserialize::begin(&mut self.checks), + "country" => Deserialize::begin(&mut self.country), + "description" => Deserialize::begin(&mut self.description), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "extended_authorization" => Deserialize::begin(&mut self.extended_authorization), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "incremental_authorization" => Deserialize::begin(&mut self.incremental_authorization), + "installments" => Deserialize::begin(&mut self.installments), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "mandate" => Deserialize::begin(&mut self.mandate), + "moto" => Deserialize::begin(&mut self.moto), + "multicapture" => Deserialize::begin(&mut self.multicapture), + "network" => Deserialize::begin(&mut self.network), + "network_token" => Deserialize::begin(&mut self.network_token), + "overcapture" => Deserialize::begin(&mut self.overcapture), + "three_d_secure" => Deserialize::begin(&mut self.three_d_secure), + "wallet" => Deserialize::begin(&mut self.wallet), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_authorized: Deserialize::default(), + brand: Deserialize::default(), + capture_before: Deserialize::default(), + checks: Deserialize::default(), + country: Deserialize::default(), + description: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + extended_authorization: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + incremental_authorization: Deserialize::default(), + installments: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + mandate: Deserialize::default(), + moto: Deserialize::default(), + multicapture: Deserialize::default(), + network: Deserialize::default(), + network_token: Deserialize::default(), + overcapture: Deserialize::default(), + three_d_secure: Deserialize::default(), + wallet: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_authorized = self.amount_authorized.take()?; + let brand = self.brand.take()?; + let capture_before = self.capture_before.take()?; + let checks = self.checks.take()?; + let country = self.country.take()?; + let description = self.description.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let extended_authorization = self.extended_authorization.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let incremental_authorization = self.incremental_authorization.take()?; + let installments = self.installments.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let mandate = self.mandate.take()?; + let moto = self.moto.take()?; + let multicapture = self.multicapture.take()?; + let network = self.network.take()?; + let network_token = self.network_token.take()?; + let overcapture = self.overcapture.take()?; + let three_d_secure = self.three_d_secure.take()?; + let wallet = self.wallet.take()?; + + Some(Self::Out { + amount_authorized, + brand, + capture_before, + checks, + country, + description, + exp_month, + exp_year, + extended_authorization, + fingerprint, + funding, + iin, + incremental_authorization, + installments, + issuer, + last4, + mandate, + moto, + multicapture, + network, + network_token, + overcapture, + three_d_secure, + wallet, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCard { + type Builder = PaymentMethodDetailsCardBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_authorized" => b.amount_authorized = Some(FromValueOpt::from_value(v)?), + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "capture_before" => b.capture_before = Some(FromValueOpt::from_value(v)?), + "checks" => b.checks = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "extended_authorization" => b.extended_authorization = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "incremental_authorization" => b.incremental_authorization = Some(FromValueOpt::from_value(v)?), + "installments" => b.installments = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "mandate" => b.mandate = Some(FromValueOpt::from_value(v)?), + "moto" => b.moto = Some(FromValueOpt::from_value(v)?), + "multicapture" => b.multicapture = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "network_token" => b.network_token = Some(FromValueOpt::from_value(v)?), + "overcapture" => b.overcapture = Some(FromValueOpt::from_value(v)?), + "three_d_secure" => b.three_d_secure = Some(FromValueOpt::from_value(v)?), + "wallet" => b.wallet = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_checks.rs b/generated/stripe_shared/src/payment_method_details_card_checks.rs index 3f0d16aff..0f60deee3 100644 --- a/generated/stripe_shared/src/payment_method_details_card_checks.rs +++ b/generated/stripe_shared/src/payment_method_details_card_checks.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardChecks { /// If a address line1 was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub address_line1_check: Option<String>, @@ -7,3 +9,97 @@ pub struct PaymentMethodDetailsCardChecks { /// If a CVC was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub cvc_check: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardChecksBuilder { + address_line1_check: Option<Option<String>>, + address_postal_code_check: Option<Option<String>>, + cvc_check: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardChecks { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardChecks>, + builder: PaymentMethodDetailsCardChecksBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardChecks> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardChecksBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardChecksBuilder { + type Out = PaymentMethodDetailsCardChecks; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address_line1_check" => Deserialize::begin(&mut self.address_line1_check), + "address_postal_code_check" => Deserialize::begin(&mut self.address_postal_code_check), + "cvc_check" => Deserialize::begin(&mut self.cvc_check), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address_line1_check: Deserialize::default(), address_postal_code_check: Deserialize::default(), cvc_check: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address_line1_check = self.address_line1_check.take()?; + let address_postal_code_check = self.address_postal_code_check.take()?; + let cvc_check = self.cvc_check.take()?; + + Some(Self::Out { address_line1_check, address_postal_code_check, cvc_check }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardChecks { + type Builder = PaymentMethodDetailsCardChecksBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardChecks { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardChecksBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address_line1_check" => b.address_line1_check = Some(FromValueOpt::from_value(v)?), + "address_postal_code_check" => b.address_postal_code_check = Some(FromValueOpt::from_value(v)?), + "cvc_check" => b.cvc_check = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_installments.rs b/generated/stripe_shared/src/payment_method_details_card_installments.rs index 45ddbf0f4..f3aaf4276 100644 --- a/generated/stripe_shared/src/payment_method_details_card_installments.rs +++ b/generated/stripe_shared/src/payment_method_details_card_installments.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardInstallments { /// Installment plan selected for the payment. pub plan: Option<stripe_shared::PaymentMethodDetailsCardInstallmentsPlan>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardInstallmentsBuilder { + plan: Option<Option<stripe_shared::PaymentMethodDetailsCardInstallmentsPlan>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardInstallments { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardInstallments>, + builder: PaymentMethodDetailsCardInstallmentsBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardInstallments> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardInstallmentsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardInstallmentsBuilder { + type Out = PaymentMethodDetailsCardInstallments; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "plan" => Deserialize::begin(&mut self.plan), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { plan: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let plan = self.plan.take()?; + + Some(Self::Out { plan }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardInstallments { + type Builder = PaymentMethodDetailsCardInstallmentsBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardInstallments { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardInstallmentsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "plan" => b.plan = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_installments_plan.rs b/generated/stripe_shared/src/payment_method_details_card_installments_plan.rs index 2f3a98f78..9774f7bdf 100644 --- a/generated/stripe_shared/src/payment_method_details_card_installments_plan.rs +++ b/generated/stripe_shared/src/payment_method_details_card_installments_plan.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardInstallmentsPlan { /// For `fixed_count` installment plans, this is the number of installment payments your customer will make to their credit card. pub count: Option<u64>, @@ -6,9 +8,103 @@ pub struct PaymentMethodDetailsCardInstallmentsPlan { /// One of `month`. pub interval: Option<PaymentMethodDetailsCardInstallmentsPlanInterval>, /// Type of installment plan, one of `fixed_count`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentMethodDetailsCardInstallmentsPlanType, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardInstallmentsPlanBuilder { + count: Option<Option<u64>>, + interval: Option<Option<PaymentMethodDetailsCardInstallmentsPlanInterval>>, + type_: Option<PaymentMethodDetailsCardInstallmentsPlanType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardInstallmentsPlan { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardInstallmentsPlan>, + builder: PaymentMethodDetailsCardInstallmentsPlanBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardInstallmentsPlan> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardInstallmentsPlanBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardInstallmentsPlanBuilder { + type Out = PaymentMethodDetailsCardInstallmentsPlan; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "count" => Deserialize::begin(&mut self.count), + "interval" => Deserialize::begin(&mut self.interval), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { count: Deserialize::default(), interval: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let count = self.count.take()?; + let interval = self.interval.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { count, interval, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardInstallmentsPlan { + type Builder = PaymentMethodDetailsCardInstallmentsPlanBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardInstallmentsPlan { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardInstallmentsPlanBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "count" => b.count = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// For `fixed_count` installment plans, this is the interval between installment payments your customer will make to their credit card. /// One of `month`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -57,13 +153,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardInstallmentsPlanIn fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsCardInstallmentsPlanInterval", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardInstallmentsPlanInterval")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsCardInstallmentsPlanInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsCardInstallmentsPlanInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsCardInstallmentsPlanInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardInstallmentsPlanInterval); /// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsCardInstallmentsPlanType { @@ -111,10 +221,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardInstallmentsPlanTy fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsCardInstallmentsPlanType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardInstallmentsPlanType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsCardInstallmentsPlanType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsCardInstallmentsPlanType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsCardInstallmentsPlanType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardInstallmentsPlanType); diff --git a/generated/stripe_shared/src/payment_method_details_card_network_token.rs b/generated/stripe_shared/src/payment_method_details_card_network_token.rs index 14178b946..b1c0853cf 100644 --- a/generated/stripe_shared/src/payment_method_details_card_network_token.rs +++ b/generated/stripe_shared/src/payment_method_details_card_network_token.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardNetworkToken { /// Indicates if Stripe used a network token, either user provided or Stripe managed when processing the transaction. pub used: bool, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardNetworkTokenBuilder { + used: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardNetworkToken { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardNetworkToken>, + builder: PaymentMethodDetailsCardNetworkTokenBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardNetworkToken> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardNetworkTokenBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardNetworkTokenBuilder { + type Out = PaymentMethodDetailsCardNetworkToken; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "used" => Deserialize::begin(&mut self.used), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { used: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let used = self.used.take()?; + + Some(Self::Out { used }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardNetworkToken { + type Builder = PaymentMethodDetailsCardNetworkTokenBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardNetworkToken { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardNetworkTokenBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "used" => b.used = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_present.rs b/generated/stripe_shared/src/payment_method_details_card_present.rs index 44df57d11..95a55c23c 100644 --- a/generated/stripe_shared/src/payment_method_details_card_present.rs +++ b/generated/stripe_shared/src/payment_method_details_card_present.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardPresent { /// The authorized amount pub amount_authorized: Option<i64>, @@ -6,7 +8,6 @@ pub struct PaymentMethodDetailsCardPresent { /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. pub brand: Option<String>, /// When using manual capture, a future timestamp after which the charge will be automatically refunded if uncaptured. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_before: Option<stripe_types::Timestamp>, /// The cardholder name as read from the card, in [ISO 7813](https://en.wikipedia.org/wiki/ISO/IEC_7813) format. /// May include alphanumeric characters, special characters and first/last name separator (`/`). @@ -18,7 +19,6 @@ pub struct PaymentMethodDetailsCardPresent { pub country: Option<String>, /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// Authorization response cryptogram. pub emv_auth_data: Option<String>, @@ -39,14 +39,12 @@ pub struct PaymentMethodDetailsCardPresent { pub generated_card: Option<String>, /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, /// Whether this [PaymentIntent](https://stripe.com/docs/api/payment_intents) is eligible for incremental authorizations. /// Request support using [request_incremental_authorization_support](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_options-card_present-request_incremental_authorization_support). pub incremental_authorization_supported: bool, /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, /// The last four digits of the card. pub last4: Option<String>, @@ -62,6 +60,216 @@ pub struct PaymentMethodDetailsCardPresent { /// A collection of fields required to be displayed on receipts. Only required for EMV transactions. pub receipt: Option<stripe_shared::PaymentMethodDetailsCardPresentReceipt>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardPresentBuilder { + amount_authorized: Option<Option<i64>>, + brand: Option<Option<String>>, + capture_before: Option<Option<stripe_types::Timestamp>>, + cardholder_name: Option<Option<String>>, + country: Option<Option<String>>, + description: Option<Option<String>>, + emv_auth_data: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + generated_card: Option<Option<String>>, + iin: Option<Option<String>>, + incremental_authorization_supported: Option<bool>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + network: Option<Option<String>>, + offline: Option<Option<stripe_shared::PaymentMethodDetailsCardPresentOffline>>, + overcapture_supported: Option<bool>, + read_method: Option<Option<PaymentMethodDetailsCardPresentReadMethod>>, + receipt: Option<Option<stripe_shared::PaymentMethodDetailsCardPresentReceipt>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardPresent>, + builder: PaymentMethodDetailsCardPresentBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardPresentBuilder { + type Out = PaymentMethodDetailsCardPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_authorized" => Deserialize::begin(&mut self.amount_authorized), + "brand" => Deserialize::begin(&mut self.brand), + "capture_before" => Deserialize::begin(&mut self.capture_before), + "cardholder_name" => Deserialize::begin(&mut self.cardholder_name), + "country" => Deserialize::begin(&mut self.country), + "description" => Deserialize::begin(&mut self.description), + "emv_auth_data" => Deserialize::begin(&mut self.emv_auth_data), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "generated_card" => Deserialize::begin(&mut self.generated_card), + "iin" => Deserialize::begin(&mut self.iin), + "incremental_authorization_supported" => Deserialize::begin(&mut self.incremental_authorization_supported), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "network" => Deserialize::begin(&mut self.network), + "offline" => Deserialize::begin(&mut self.offline), + "overcapture_supported" => Deserialize::begin(&mut self.overcapture_supported), + "read_method" => Deserialize::begin(&mut self.read_method), + "receipt" => Deserialize::begin(&mut self.receipt), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_authorized: Deserialize::default(), + brand: Deserialize::default(), + capture_before: Deserialize::default(), + cardholder_name: Deserialize::default(), + country: Deserialize::default(), + description: Deserialize::default(), + emv_auth_data: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + generated_card: Deserialize::default(), + iin: Deserialize::default(), + incremental_authorization_supported: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + network: Deserialize::default(), + offline: Deserialize::default(), + overcapture_supported: Deserialize::default(), + read_method: Deserialize::default(), + receipt: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_authorized = self.amount_authorized.take()?; + let brand = self.brand.take()?; + let capture_before = self.capture_before.take()?; + let cardholder_name = self.cardholder_name.take()?; + let country = self.country.take()?; + let description = self.description.take()?; + let emv_auth_data = self.emv_auth_data.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let generated_card = self.generated_card.take()?; + let iin = self.iin.take()?; + let incremental_authorization_supported = self.incremental_authorization_supported.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let network = self.network.take()?; + let offline = self.offline.take()?; + let overcapture_supported = self.overcapture_supported.take()?; + let read_method = self.read_method.take()?; + let receipt = self.receipt.take()?; + + Some(Self::Out { + amount_authorized, + brand, + capture_before, + cardholder_name, + country, + description, + emv_auth_data, + exp_month, + exp_year, + fingerprint, + funding, + generated_card, + iin, + incremental_authorization_supported, + issuer, + last4, + network, + offline, + overcapture_supported, + read_method, + receipt, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardPresent { + type Builder = PaymentMethodDetailsCardPresentBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_authorized" => b.amount_authorized = Some(FromValueOpt::from_value(v)?), + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "capture_before" => b.capture_before = Some(FromValueOpt::from_value(v)?), + "cardholder_name" => b.cardholder_name = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "emv_auth_data" => b.emv_auth_data = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "generated_card" => b.generated_card = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "incremental_authorization_supported" => b.incremental_authorization_supported = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "offline" => b.offline = Some(FromValueOpt::from_value(v)?), + "overcapture_supported" => b.overcapture_supported = Some(FromValueOpt::from_value(v)?), + "read_method" => b.read_method = Some(FromValueOpt::from_value(v)?), + "receipt" => b.receipt = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// How card details were read in this transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsCardPresentReadMethod { @@ -121,8 +329,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardPresentReadMethod fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardPresentReadMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardPresentReadMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsCardPresentReadMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsCardPresentReadMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsCardPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardPresentReadMethod); diff --git a/generated/stripe_shared/src/payment_method_details_card_present_offline.rs b/generated/stripe_shared/src/payment_method_details_card_present_offline.rs index 1a9cfb636..6bf711b58 100644 --- a/generated/stripe_shared/src/payment_method_details_card_present_offline.rs +++ b/generated/stripe_shared/src/payment_method_details_card_present_offline.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardPresentOffline { /// Time at which the payment was collected while offline pub stored_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardPresentOfflineBuilder { + stored_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardPresentOffline { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardPresentOffline>, + builder: PaymentMethodDetailsCardPresentOfflineBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardPresentOffline> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardPresentOfflineBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardPresentOfflineBuilder { + type Out = PaymentMethodDetailsCardPresentOffline; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "stored_at" => Deserialize::begin(&mut self.stored_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { stored_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let stored_at = self.stored_at.take()?; + + Some(Self::Out { stored_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardPresentOffline { + type Builder = PaymentMethodDetailsCardPresentOfflineBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardPresentOffline { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardPresentOfflineBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "stored_at" => b.stored_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_present_receipt.rs b/generated/stripe_shared/src/payment_method_details_card_present_receipt.rs index d7cea8ddb..60540146b 100644 --- a/generated/stripe_shared/src/payment_method_details_card_present_receipt.rs +++ b/generated/stripe_shared/src/payment_method_details_card_present_receipt.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardPresentReceipt { /// The type of account being debited or credited - #[serde(skip_serializing_if = "Option::is_none")] pub account_type: Option<PaymentMethodDetailsCardPresentReceiptAccountType>, /// EMV tag 9F26, cryptogram generated by the integrated circuit chip. pub application_cryptogram: Option<String>, @@ -20,6 +21,144 @@ pub struct PaymentMethodDetailsCardPresentReceipt { /// An indication of various EMV functions performed during the transaction. pub transaction_status_information: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardPresentReceiptBuilder { + account_type: Option<Option<PaymentMethodDetailsCardPresentReceiptAccountType>>, + application_cryptogram: Option<Option<String>>, + application_preferred_name: Option<Option<String>>, + authorization_code: Option<Option<String>>, + authorization_response_code: Option<Option<String>>, + cardholder_verification_method: Option<Option<String>>, + dedicated_file_name: Option<Option<String>>, + terminal_verification_results: Option<Option<String>>, + transaction_status_information: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardPresentReceipt { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardPresentReceipt>, + builder: PaymentMethodDetailsCardPresentReceiptBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardPresentReceipt> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardPresentReceiptBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardPresentReceiptBuilder { + type Out = PaymentMethodDetailsCardPresentReceipt; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_type" => Deserialize::begin(&mut self.account_type), + "application_cryptogram" => Deserialize::begin(&mut self.application_cryptogram), + "application_preferred_name" => Deserialize::begin(&mut self.application_preferred_name), + "authorization_code" => Deserialize::begin(&mut self.authorization_code), + "authorization_response_code" => Deserialize::begin(&mut self.authorization_response_code), + "cardholder_verification_method" => Deserialize::begin(&mut self.cardholder_verification_method), + "dedicated_file_name" => Deserialize::begin(&mut self.dedicated_file_name), + "terminal_verification_results" => Deserialize::begin(&mut self.terminal_verification_results), + "transaction_status_information" => Deserialize::begin(&mut self.transaction_status_information), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_type: Deserialize::default(), + application_cryptogram: Deserialize::default(), + application_preferred_name: Deserialize::default(), + authorization_code: Deserialize::default(), + authorization_response_code: Deserialize::default(), + cardholder_verification_method: Deserialize::default(), + dedicated_file_name: Deserialize::default(), + terminal_verification_results: Deserialize::default(), + transaction_status_information: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_type = self.account_type.take()?; + let application_cryptogram = self.application_cryptogram.take()?; + let application_preferred_name = self.application_preferred_name.take()?; + let authorization_code = self.authorization_code.take()?; + let authorization_response_code = self.authorization_response_code.take()?; + let cardholder_verification_method = self.cardholder_verification_method.take()?; + let dedicated_file_name = self.dedicated_file_name.take()?; + let terminal_verification_results = self.terminal_verification_results.take()?; + let transaction_status_information = self.transaction_status_information.take()?; + + Some(Self::Out { + account_type, + application_cryptogram, + application_preferred_name, + authorization_code, + authorization_response_code, + cardholder_verification_method, + dedicated_file_name, + terminal_verification_results, + transaction_status_information, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardPresentReceipt { + type Builder = PaymentMethodDetailsCardPresentReceiptBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardPresentReceipt { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardPresentReceiptBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "application_cryptogram" => b.application_cryptogram = Some(FromValueOpt::from_value(v)?), + "application_preferred_name" => b.application_preferred_name = Some(FromValueOpt::from_value(v)?), + "authorization_code" => b.authorization_code = Some(FromValueOpt::from_value(v)?), + "authorization_response_code" => b.authorization_response_code = Some(FromValueOpt::from_value(v)?), + "cardholder_verification_method" => b.cardholder_verification_method = Some(FromValueOpt::from_value(v)?), + "dedicated_file_name" => b.dedicated_file_name = Some(FromValueOpt::from_value(v)?), + "terminal_verification_results" => b.terminal_verification_results = Some(FromValueOpt::from_value(v)?), + "transaction_status_information" => b.transaction_status_information = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of account being debited or credited #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsCardPresentReceiptAccountType { @@ -76,10 +215,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardPresentReceiptAcco fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsCardPresentReceiptAccountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardPresentReceiptAccountType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsCardPresentReceiptAccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsCardPresentReceiptAccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsCardPresentReceiptAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardPresentReceiptAccountType); diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet.rs b/generated/stripe_shared/src/payment_method_details_card_wallet.rs index 61e48efe2..dc1c4eaa6 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet.rs @@ -1,28 +1,150 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWallet { - #[serde(skip_serializing_if = "Option::is_none")] - pub amex_express_checkout: - Option<stripe_shared::PaymentMethodDetailsCardWalletAmexExpressCheckout>, - #[serde(skip_serializing_if = "Option::is_none")] + pub amex_express_checkout: Option<stripe_shared::PaymentMethodDetailsCardWalletAmexExpressCheckout>, pub apple_pay: Option<stripe_shared::PaymentMethodDetailsCardWalletApplePay>, /// (For tokenized numbers only.) The last four digits of the device account number. pub dynamic_last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option<stripe_shared::PaymentMethodDetailsCardWalletGooglePay>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::PaymentMethodDetailsCardWalletLink>, - #[serde(skip_serializing_if = "Option::is_none")] pub masterpass: Option<stripe_shared::PaymentMethodDetailsCardWalletMasterpass>, - #[serde(skip_serializing_if = "Option::is_none")] pub samsung_pay: Option<stripe_shared::PaymentMethodDetailsCardWalletSamsungPay>, /// The type of the card wallet, one of `amex_express_checkout`, `apple_pay`, `google_pay`, `masterpass`, `samsung_pay`, `visa_checkout`, or `link`. /// An additional hash is included on the Wallet subhash with a name matching this value. /// It contains additional information specific to the card wallet type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PaymentMethodDetailsCardWalletType, - #[serde(skip_serializing_if = "Option::is_none")] pub visa_checkout: Option<stripe_shared::PaymentMethodDetailsCardWalletVisaCheckout>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletBuilder { + amex_express_checkout: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletAmexExpressCheckout>>, + apple_pay: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletApplePay>>, + dynamic_last4: Option<Option<String>>, + google_pay: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletGooglePay>>, + link: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletLink>>, + masterpass: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletMasterpass>>, + samsung_pay: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletSamsungPay>>, + type_: Option<PaymentMethodDetailsCardWalletType>, + visa_checkout: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletVisaCheckout>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWallet { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWallet>, + builder: PaymentMethodDetailsCardWalletBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWallet> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletBuilder { + type Out = PaymentMethodDetailsCardWallet; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amex_express_checkout" => Deserialize::begin(&mut self.amex_express_checkout), + "apple_pay" => Deserialize::begin(&mut self.apple_pay), + "dynamic_last4" => Deserialize::begin(&mut self.dynamic_last4), + "google_pay" => Deserialize::begin(&mut self.google_pay), + "link" => Deserialize::begin(&mut self.link), + "masterpass" => Deserialize::begin(&mut self.masterpass), + "samsung_pay" => Deserialize::begin(&mut self.samsung_pay), + "type" => Deserialize::begin(&mut self.type_), + "visa_checkout" => Deserialize::begin(&mut self.visa_checkout), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amex_express_checkout: Deserialize::default(), + apple_pay: Deserialize::default(), + dynamic_last4: Deserialize::default(), + google_pay: Deserialize::default(), + link: Deserialize::default(), + masterpass: Deserialize::default(), + samsung_pay: Deserialize::default(), + type_: Deserialize::default(), + visa_checkout: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amex_express_checkout = self.amex_express_checkout.take()?; + let apple_pay = self.apple_pay.take()?; + let dynamic_last4 = self.dynamic_last4.take()?; + let google_pay = self.google_pay.take()?; + let link = self.link.take()?; + let masterpass = self.masterpass.take()?; + let samsung_pay = self.samsung_pay.take()?; + let type_ = self.type_.take()?; + let visa_checkout = self.visa_checkout.take()?; + + Some(Self::Out { amex_express_checkout, apple_pay, dynamic_last4, google_pay, link, masterpass, samsung_pay, type_, visa_checkout }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWallet { + type Builder = PaymentMethodDetailsCardWalletBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWallet { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amex_express_checkout" => b.amex_express_checkout = Some(FromValueOpt::from_value(v)?), + "apple_pay" => b.apple_pay = Some(FromValueOpt::from_value(v)?), + "dynamic_last4" => b.dynamic_last4 = Some(FromValueOpt::from_value(v)?), + "google_pay" => b.google_pay = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "masterpass" => b.masterpass = Some(FromValueOpt::from_value(v)?), + "samsung_pay" => b.samsung_pay = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "visa_checkout" => b.visa_checkout = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the card wallet, one of `amex_express_checkout`, `apple_pay`, `google_pay`, `masterpass`, `samsung_pay`, `visa_checkout`, or `link`. /// An additional hash is included on the Wallet subhash with a name matching this value. /// It contains additional information specific to the card wallet type. @@ -90,8 +212,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardWalletType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardWalletType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsCardWalletType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsCardWalletType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsCardWalletType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsCardWalletType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardWalletType); diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet_amex_express_checkout.rs b/generated/stripe_shared/src/payment_method_details_card_wallet_amex_express_checkout.rs index d6bb316e9..aeca54c94 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet_amex_express_checkout.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet_amex_express_checkout.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWalletAmexExpressCheckout {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWalletAmexExpressCheckout { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWalletAmexExpressCheckout>, + builder: PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWalletAmexExpressCheckout> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder { + type Out = PaymentMethodDetailsCardWalletAmexExpressCheckout; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWalletAmexExpressCheckout { + type Builder = PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWalletAmexExpressCheckout { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet_apple_pay.rs b/generated/stripe_shared/src/payment_method_details_card_wallet_apple_pay.rs index 7acbfb6e3..ee4b72ee4 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet_apple_pay.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet_apple_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWalletApplePay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletApplePayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWalletApplePay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWalletApplePay>, + builder: PaymentMethodDetailsCardWalletApplePayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWalletApplePay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletApplePayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletApplePayBuilder { + type Out = PaymentMethodDetailsCardWalletApplePay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWalletApplePay { + type Builder = PaymentMethodDetailsCardWalletApplePayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWalletApplePay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletApplePayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet_google_pay.rs b/generated/stripe_shared/src/payment_method_details_card_wallet_google_pay.rs index 6695fbe5f..7733ea491 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet_google_pay.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet_google_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWalletGooglePay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletGooglePayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWalletGooglePay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWalletGooglePay>, + builder: PaymentMethodDetailsCardWalletGooglePayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWalletGooglePay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletGooglePayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletGooglePayBuilder { + type Out = PaymentMethodDetailsCardWalletGooglePay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWalletGooglePay { + type Builder = PaymentMethodDetailsCardWalletGooglePayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWalletGooglePay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletGooglePayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet_link.rs b/generated/stripe_shared/src/payment_method_details_card_wallet_link.rs index 873024f1d..878092a90 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet_link.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet_link.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWalletLink {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletLinkBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWalletLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWalletLink>, + builder: PaymentMethodDetailsCardWalletLinkBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWalletLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletLinkBuilder { + type Out = PaymentMethodDetailsCardWalletLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWalletLink { + type Builder = PaymentMethodDetailsCardWalletLinkBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWalletLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet_masterpass.rs b/generated/stripe_shared/src/payment_method_details_card_wallet_masterpass.rs index dec58d814..2b206ea0d 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet_masterpass.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet_masterpass.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWalletMasterpass { /// Owner's verified billing address. /// Values are verified or provided by the wallet directly (if supported) at the time of authorization or settlement. @@ -17,3 +19,101 @@ pub struct PaymentMethodDetailsCardWalletMasterpass { /// They cannot be set or mutated. pub shipping_address: Option<stripe_shared::Address>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletMasterpassBuilder { + billing_address: Option<Option<stripe_shared::Address>>, + email: Option<Option<String>>, + name: Option<Option<String>>, + shipping_address: Option<Option<stripe_shared::Address>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWalletMasterpass { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWalletMasterpass>, + builder: PaymentMethodDetailsCardWalletMasterpassBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWalletMasterpass> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletMasterpassBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletMasterpassBuilder { + type Out = PaymentMethodDetailsCardWalletMasterpass; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_address" => Deserialize::begin(&mut self.billing_address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + "shipping_address" => Deserialize::begin(&mut self.shipping_address), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_address: Deserialize::default(), email: Deserialize::default(), name: Deserialize::default(), shipping_address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_address = self.billing_address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + let shipping_address = self.shipping_address.take()?; + + Some(Self::Out { billing_address, email, name, shipping_address }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWalletMasterpass { + type Builder = PaymentMethodDetailsCardWalletMasterpassBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWalletMasterpass { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletMasterpassBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_address" => b.billing_address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "shipping_address" => b.shipping_address = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet_samsung_pay.rs b/generated/stripe_shared/src/payment_method_details_card_wallet_samsung_pay.rs index cca8ef217..4516aa720 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet_samsung_pay.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet_samsung_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWalletSamsungPay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletSamsungPayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWalletSamsungPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWalletSamsungPay>, + builder: PaymentMethodDetailsCardWalletSamsungPayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWalletSamsungPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletSamsungPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletSamsungPayBuilder { + type Out = PaymentMethodDetailsCardWalletSamsungPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWalletSamsungPay { + type Builder = PaymentMethodDetailsCardWalletSamsungPayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWalletSamsungPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletSamsungPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_card_wallet_visa_checkout.rs b/generated/stripe_shared/src/payment_method_details_card_wallet_visa_checkout.rs index 902c15c77..99598f1ca 100644 --- a/generated/stripe_shared/src/payment_method_details_card_wallet_visa_checkout.rs +++ b/generated/stripe_shared/src/payment_method_details_card_wallet_visa_checkout.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCardWalletVisaCheckout { /// Owner's verified billing address. /// Values are verified or provided by the wallet directly (if supported) at the time of authorization or settlement. @@ -17,3 +19,101 @@ pub struct PaymentMethodDetailsCardWalletVisaCheckout { /// They cannot be set or mutated. pub shipping_address: Option<stripe_shared::Address>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCardWalletVisaCheckoutBuilder { + billing_address: Option<Option<stripe_shared::Address>>, + email: Option<Option<String>>, + name: Option<Option<String>>, + shipping_address: Option<Option<stripe_shared::Address>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCardWalletVisaCheckout { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCardWalletVisaCheckout>, + builder: PaymentMethodDetailsCardWalletVisaCheckoutBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCardWalletVisaCheckout> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCardWalletVisaCheckoutBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCardWalletVisaCheckoutBuilder { + type Out = PaymentMethodDetailsCardWalletVisaCheckout; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_address" => Deserialize::begin(&mut self.billing_address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + "shipping_address" => Deserialize::begin(&mut self.shipping_address), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_address: Deserialize::default(), email: Deserialize::default(), name: Deserialize::default(), shipping_address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_address = self.billing_address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + let shipping_address = self.shipping_address.take()?; + + Some(Self::Out { billing_address, email, name, shipping_address }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCardWalletVisaCheckout { + type Builder = PaymentMethodDetailsCardWalletVisaCheckoutBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCardWalletVisaCheckout { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCardWalletVisaCheckoutBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_address" => b.billing_address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "shipping_address" => b.shipping_address = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_cashapp.rs b/generated/stripe_shared/src/payment_method_details_cashapp.rs index 86783959f..d30292094 100644 --- a/generated/stripe_shared/src/payment_method_details_cashapp.rs +++ b/generated/stripe_shared/src/payment_method_details_cashapp.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCashapp { /// A unique and immutable identifier assigned by Cash App to every buyer. pub buyer_id: Option<String>, /// A public identifier for buyers using Cash App. pub cashtag: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCashappBuilder { + buyer_id: Option<Option<String>>, + cashtag: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCashapp { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCashapp>, + builder: PaymentMethodDetailsCashappBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCashapp> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCashappBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCashappBuilder { + type Out = PaymentMethodDetailsCashapp; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "buyer_id" => Deserialize::begin(&mut self.buyer_id), + "cashtag" => Deserialize::begin(&mut self.cashtag), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { buyer_id: Deserialize::default(), cashtag: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let buyer_id = self.buyer_id.take()?; + let cashtag = self.cashtag.take()?; + + Some(Self::Out { buyer_id, cashtag }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCashapp { + type Builder = PaymentMethodDetailsCashappBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCashapp { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCashappBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "buyer_id" => b.buyer_id = Some(FromValueOpt::from_value(v)?), + "cashtag" => b.cashtag = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_customer_balance.rs b/generated/stripe_shared/src/payment_method_details_customer_balance.rs index 14673643c..755c6b664 100644 --- a/generated/stripe_shared/src/payment_method_details_customer_balance.rs +++ b/generated/stripe_shared/src/payment_method_details_customer_balance.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsCustomerBalance {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsCustomerBalanceBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsCustomerBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsCustomerBalance>, + builder: PaymentMethodDetailsCustomerBalanceBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsCustomerBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsCustomerBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsCustomerBalanceBuilder { + type Out = PaymentMethodDetailsCustomerBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsCustomerBalance { + type Builder = PaymentMethodDetailsCustomerBalanceBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsCustomerBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsCustomerBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_eps.rs b/generated/stripe_shared/src/payment_method_details_eps.rs index d70131a36..09241e1cc 100644 --- a/generated/stripe_shared/src/payment_method_details_eps.rs +++ b/generated/stripe_shared/src/payment_method_details_eps.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsEps { /// The customer's bank. /// Should be one of `arzte_und_apotheker_bank`, `austrian_anadi_bank_ag`, `bank_austria`, `bankhaus_carl_spangler`, `bankhaus_schelhammer_und_schattera_ag`, `bawag_psk_ag`, `bks_bank_ag`, `brull_kallmus_bank_ag`, `btv_vier_lander_bank`, `capital_bank_grawe_gruppe_ag`, `deutsche_bank_ag`, `dolomitenbank`, `easybank_ag`, `erste_bank_und_sparkassen`, `hypo_alpeadriabank_international_ag`, `hypo_noe_lb_fur_niederosterreich_u_wien`, `hypo_oberosterreich_salzburg_steiermark`, `hypo_tirol_bank_ag`, `hypo_vorarlberg_bank_ag`, `hypo_bank_burgenland_aktiengesellschaft`, `marchfelder_bank`, `oberbank_ag`, `raiffeisen_bankengruppe_osterreich`, `schoellerbank_ag`, `sparda_bank_wien`, `volksbank_gruppe`, `volkskreditbank_ag`, or `vr_bank_braunau`. @@ -8,6 +10,96 @@ pub struct PaymentMethodDetailsEps { /// EPS rarely provides this information so the attribute is usually empty. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsEpsBuilder { + bank: Option<Option<PaymentMethodDetailsEpsBank>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsEps { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsEps>, + builder: PaymentMethodDetailsEpsBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsEps> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsEpsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsEpsBuilder { + type Out = PaymentMethodDetailsEps; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default(), verified_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsEps { + type Builder = PaymentMethodDetailsEpsBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsEps { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsEpsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer's bank. /// Should be one of `arzte_und_apotheker_bank`, `austrian_anadi_bank_ag`, `bank_austria`, `bankhaus_carl_spangler`, `bankhaus_schelhammer_und_schattera_ag`, `bawag_psk_ag`, `bks_bank_ag`, `brull_kallmus_bank_ag`, `btv_vier_lander_bank`, `capital_bank_grawe_gruppe_ag`, `deutsche_bank_ag`, `dolomitenbank`, `easybank_ag`, `erste_bank_und_sparkassen`, `hypo_alpeadriabank_international_ag`, `hypo_noe_lb_fur_niederosterreich_u_wien`, `hypo_oberosterreich_salzburg_steiermark`, `hypo_tirol_bank_ag`, `hypo_vorarlberg_bank_ag`, `hypo_bank_burgenland_aktiengesellschaft`, `marchfelder_bank`, `oberbank_ag`, `raiffeisen_bankengruppe_osterreich`, `schoellerbank_ag`, `sparda_bank_wien`, `volksbank_gruppe`, `volkskreditbank_ag`, or `vr_bank_braunau`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -141,6 +233,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsEpsBank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodDetailsEpsBank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsEpsBank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsEpsBank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsEpsBank::from_str(s).unwrap_or(PaymentMethodDetailsEpsBank::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsEpsBank); diff --git a/generated/stripe_shared/src/payment_method_details_fpx.rs b/generated/stripe_shared/src/payment_method_details_fpx.rs index 1fd4679be..4aac9608b 100644 --- a/generated/stripe_shared/src/payment_method_details_fpx.rs +++ b/generated/stripe_shared/src/payment_method_details_fpx.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsFpx { /// Account holder type, if provided. Can be one of `individual` or `company`. pub account_holder_type: Option<PaymentMethodDetailsFpxAccountHolderType>, @@ -8,6 +10,100 @@ pub struct PaymentMethodDetailsFpx { /// Unique transaction id generated by FPX for every request from the merchant pub transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsFpxBuilder { + account_holder_type: Option<Option<PaymentMethodDetailsFpxAccountHolderType>>, + bank: Option<PaymentMethodDetailsFpxBank>, + transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsFpx { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsFpx>, + builder: PaymentMethodDetailsFpxBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsFpx> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsFpxBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsFpxBuilder { + type Out = PaymentMethodDetailsFpx; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "bank" => Deserialize::begin(&mut self.bank), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_holder_type: Deserialize::default(), bank: Deserialize::default(), transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let bank = self.bank.take()?; + let transaction_id = self.transaction_id.take()?; + + Some(Self::Out { account_holder_type, bank, transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsFpx { + type Builder = PaymentMethodDetailsFpxBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsFpx { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsFpxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Account holder type, if provided. Can be one of `individual` or `company`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsFpxAccountHolderType { @@ -58,11 +154,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsFpxAccountHolderType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodDetailsFpxAccountHolderType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsFpxAccountHolderType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsFpxAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsFpxAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsFpxAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsFpxAccountHolderType); /// The customer's bank. /// Can be one of `affin_bank`, `agrobank`, `alliance_bank`, `ambank`, `bank_islam`, `bank_muamalat`, `bank_rakyat`, `bsn`, `cimb`, `hong_leong_bank`, `hsbc`, `kfh`, `maybank2u`, `ocbc`, `public_bank`, `rhb`, `standard_chartered`, `uob`, `deutsche_bank`, `maybank2e`, `pb_enterprise`, or `bank_of_china`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -178,6 +290,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsFpxBank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodDetailsFpxBank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsFpxBank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsFpxBank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsFpxBank::from_str(s).unwrap_or(PaymentMethodDetailsFpxBank::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsFpxBank); diff --git a/generated/stripe_shared/src/payment_method_details_giropay.rs b/generated/stripe_shared/src/payment_method_details_giropay.rs index 0c8a75eb6..03ab0be74 100644 --- a/generated/stripe_shared/src/payment_method_details_giropay.rs +++ b/generated/stripe_shared/src/payment_method_details_giropay.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsGiropay { /// Bank code of bank associated with the bank account. pub bank_code: Option<String>, @@ -11,3 +13,101 @@ pub struct PaymentMethodDetailsGiropay { /// Giropay rarely provides this information so the attribute is usually empty. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsGiropayBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsGiropay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsGiropay>, + builder: PaymentMethodDetailsGiropayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsGiropay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsGiropayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsGiropayBuilder { + type Out = PaymentMethodDetailsGiropay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_code: Deserialize::default(), bank_name: Deserialize::default(), bic: Deserialize::default(), verified_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank_code, bank_name, bic, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsGiropay { + type Builder = PaymentMethodDetailsGiropayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsGiropay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsGiropayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_grabpay.rs b/generated/stripe_shared/src/payment_method_details_grabpay.rs index d96f85e85..c59e7a7a6 100644 --- a/generated/stripe_shared/src/payment_method_details_grabpay.rs +++ b/generated/stripe_shared/src/payment_method_details_grabpay.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsGrabpay { /// Unique transaction id generated by GrabPay pub transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsGrabpayBuilder { + transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsGrabpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsGrabpay>, + builder: PaymentMethodDetailsGrabpayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsGrabpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsGrabpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsGrabpayBuilder { + type Out = PaymentMethodDetailsGrabpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let transaction_id = self.transaction_id.take()?; + + Some(Self::Out { transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsGrabpay { + type Builder = PaymentMethodDetailsGrabpayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsGrabpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsGrabpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "transaction_id" => b.transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_ideal.rs b/generated/stripe_shared/src/payment_method_details_ideal.rs index 139b7a1f8..9c93c5d0e 100644 --- a/generated/stripe_shared/src/payment_method_details_ideal.rs +++ b/generated/stripe_shared/src/payment_method_details_ideal.rs @@ -1,7 +1,9 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsIdeal { /// The customer's bank. - /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. + /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. pub bank: Option<PaymentMethodDetailsIdealBank>, /// The Bank Identifier Code of the customer's bank. pub bic: Option<PaymentMethodDetailsIdealBic>, @@ -15,8 +17,121 @@ pub struct PaymentMethodDetailsIdeal { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsIdealBuilder { + bank: Option<Option<PaymentMethodDetailsIdealBank>>, + bic: Option<Option<PaymentMethodDetailsIdealBic>>, + generated_sepa_debit: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + generated_sepa_debit_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + iban_last4: Option<Option<String>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsIdeal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsIdeal>, + builder: PaymentMethodDetailsIdealBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsIdeal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsIdealBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsIdealBuilder { + type Out = PaymentMethodDetailsIdeal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + "bic" => Deserialize::begin(&mut self.bic), + "generated_sepa_debit" => Deserialize::begin(&mut self.generated_sepa_debit), + "generated_sepa_debit_mandate" => Deserialize::begin(&mut self.generated_sepa_debit_mandate), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank: Deserialize::default(), + bic: Deserialize::default(), + generated_sepa_debit: Deserialize::default(), + generated_sepa_debit_mandate: Deserialize::default(), + iban_last4: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + let bic = self.bic.take()?; + let generated_sepa_debit = self.generated_sepa_debit.take()?; + let generated_sepa_debit_mandate = self.generated_sepa_debit_mandate.take()?; + let iban_last4 = self.iban_last4.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank, bic, generated_sepa_debit, generated_sepa_debit_mandate, iban_last4, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsIdeal { + type Builder = PaymentMethodDetailsIdealBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsIdeal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsIdealBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit" => b.generated_sepa_debit = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit_mandate" => b.generated_sepa_debit_mandate = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer's bank. -/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. +/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum PaymentMethodDetailsIdealBank { @@ -28,7 +143,6 @@ pub enum PaymentMethodDetailsIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -51,7 +165,6 @@ impl PaymentMethodDetailsIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -77,7 +190,6 @@ impl std::str::FromStr for PaymentMethodDetailsIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -112,9 +224,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsIdealBank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodDetailsIdealBank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsIdealBank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsIdealBank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsIdealBank::from_str(s).unwrap_or(PaymentMethodDetailsIdealBank::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsIdealBank); /// The Bank Identifier Code of the customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -128,7 +258,6 @@ pub enum PaymentMethodDetailsIdealBic { Ingbnl2a, Knabnl2h, Moyonl21, - Nnbanl2g, Ntsbdeb1, Rabonl2u, Rbrbnl21, @@ -152,7 +281,6 @@ impl PaymentMethodDetailsIdealBic { Ingbnl2a => "INGBNL2A", Knabnl2h => "KNABNL2H", Moyonl21 => "MOYONL21", - Nnbanl2g => "NNBANL2G", Ntsbdeb1 => "NTSBDEB1", Rabonl2u => "RABONL2U", Rbrbnl21 => "RBRBNL21", @@ -179,7 +307,6 @@ impl std::str::FromStr for PaymentMethodDetailsIdealBic { "INGBNL2A" => Ok(Ingbnl2a), "KNABNL2H" => Ok(Knabnl2h), "MOYONL21" => Ok(Moyonl21), - "NNBANL2G" => Ok(Nnbanl2g), "NTSBDEB1" => Ok(Ntsbdeb1), "RABONL2U" => Ok(Rabonl2u), "RBRBNL21" => Ok(Rbrbnl21), @@ -214,6 +341,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsIdealBic { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodDetailsIdealBic::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsIdealBic { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsIdealBic> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsIdealBic::from_str(s).unwrap_or(PaymentMethodDetailsIdealBic::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsIdealBic); diff --git a/generated/stripe_shared/src/payment_method_details_interac_present.rs b/generated/stripe_shared/src/payment_method_details_interac_present.rs index ac20be016..08ae683f0 100644 --- a/generated/stripe_shared/src/payment_method_details_interac_present.rs +++ b/generated/stripe_shared/src/payment_method_details_interac_present.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsInteracPresent { /// Card brand. Can be `interac`, `mastercard` or `visa`. pub brand: Option<String>, @@ -12,7 +14,6 @@ pub struct PaymentMethodDetailsInteracPresent { pub country: Option<String>, /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// Authorization response cryptogram. pub emv_auth_data: Option<String>, @@ -33,11 +34,9 @@ pub struct PaymentMethodDetailsInteracPresent { pub generated_card: Option<String>, /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, /// The last four digits of the card. pub last4: Option<String>, @@ -51,6 +50,192 @@ pub struct PaymentMethodDetailsInteracPresent { /// A collection of fields required to be displayed on receipts. Only required for EMV transactions. pub receipt: Option<stripe_shared::PaymentMethodDetailsInteracPresentReceipt>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsInteracPresentBuilder { + brand: Option<Option<String>>, + cardholder_name: Option<Option<String>>, + country: Option<Option<String>>, + description: Option<Option<String>>, + emv_auth_data: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + generated_card: Option<Option<String>>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + network: Option<Option<String>>, + preferred_locales: Option<Option<Vec<String>>>, + read_method: Option<Option<PaymentMethodDetailsInteracPresentReadMethod>>, + receipt: Option<Option<stripe_shared::PaymentMethodDetailsInteracPresentReceipt>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsInteracPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsInteracPresent>, + builder: PaymentMethodDetailsInteracPresentBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsInteracPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsInteracPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsInteracPresentBuilder { + type Out = PaymentMethodDetailsInteracPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "brand" => Deserialize::begin(&mut self.brand), + "cardholder_name" => Deserialize::begin(&mut self.cardholder_name), + "country" => Deserialize::begin(&mut self.country), + "description" => Deserialize::begin(&mut self.description), + "emv_auth_data" => Deserialize::begin(&mut self.emv_auth_data), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "generated_card" => Deserialize::begin(&mut self.generated_card), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "network" => Deserialize::begin(&mut self.network), + "preferred_locales" => Deserialize::begin(&mut self.preferred_locales), + "read_method" => Deserialize::begin(&mut self.read_method), + "receipt" => Deserialize::begin(&mut self.receipt), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + brand: Deserialize::default(), + cardholder_name: Deserialize::default(), + country: Deserialize::default(), + description: Deserialize::default(), + emv_auth_data: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + generated_card: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + network: Deserialize::default(), + preferred_locales: Deserialize::default(), + read_method: Deserialize::default(), + receipt: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let brand = self.brand.take()?; + let cardholder_name = self.cardholder_name.take()?; + let country = self.country.take()?; + let description = self.description.take()?; + let emv_auth_data = self.emv_auth_data.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let generated_card = self.generated_card.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let network = self.network.take()?; + let preferred_locales = self.preferred_locales.take()?; + let read_method = self.read_method.take()?; + let receipt = self.receipt.take()?; + + Some(Self::Out { + brand, + cardholder_name, + country, + description, + emv_auth_data, + exp_month, + exp_year, + fingerprint, + funding, + generated_card, + iin, + issuer, + last4, + network, + preferred_locales, + read_method, + receipt, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsInteracPresent { + type Builder = PaymentMethodDetailsInteracPresentBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsInteracPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsInteracPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "cardholder_name" => b.cardholder_name = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "emv_auth_data" => b.emv_auth_data = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "generated_card" => b.generated_card = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "preferred_locales" => b.preferred_locales = Some(FromValueOpt::from_value(v)?), + "read_method" => b.read_method = Some(FromValueOpt::from_value(v)?), + "receipt" => b.receipt = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// How card details were read in this transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsInteracPresentReadMethod { @@ -110,10 +295,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReadMeth fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsInteracPresentReadMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsInteracPresentReadMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReadMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsInteracPresentReadMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsInteracPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReadMethod); diff --git a/generated/stripe_shared/src/payment_method_details_interac_present_receipt.rs b/generated/stripe_shared/src/payment_method_details_interac_present_receipt.rs index 96061144e..769114996 100644 --- a/generated/stripe_shared/src/payment_method_details_interac_present_receipt.rs +++ b/generated/stripe_shared/src/payment_method_details_interac_present_receipt.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsInteracPresentReceipt { /// The type of account being debited or credited - #[serde(skip_serializing_if = "Option::is_none")] pub account_type: Option<PaymentMethodDetailsInteracPresentReceiptAccountType>, /// EMV tag 9F26, cryptogram generated by the integrated circuit chip. pub application_cryptogram: Option<String>, @@ -20,6 +21,144 @@ pub struct PaymentMethodDetailsInteracPresentReceipt { /// An indication of various EMV functions performed during the transaction. pub transaction_status_information: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsInteracPresentReceiptBuilder { + account_type: Option<Option<PaymentMethodDetailsInteracPresentReceiptAccountType>>, + application_cryptogram: Option<Option<String>>, + application_preferred_name: Option<Option<String>>, + authorization_code: Option<Option<String>>, + authorization_response_code: Option<Option<String>>, + cardholder_verification_method: Option<Option<String>>, + dedicated_file_name: Option<Option<String>>, + terminal_verification_results: Option<Option<String>>, + transaction_status_information: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsInteracPresentReceipt { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsInteracPresentReceipt>, + builder: PaymentMethodDetailsInteracPresentReceiptBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsInteracPresentReceipt> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsInteracPresentReceiptBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsInteracPresentReceiptBuilder { + type Out = PaymentMethodDetailsInteracPresentReceipt; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_type" => Deserialize::begin(&mut self.account_type), + "application_cryptogram" => Deserialize::begin(&mut self.application_cryptogram), + "application_preferred_name" => Deserialize::begin(&mut self.application_preferred_name), + "authorization_code" => Deserialize::begin(&mut self.authorization_code), + "authorization_response_code" => Deserialize::begin(&mut self.authorization_response_code), + "cardholder_verification_method" => Deserialize::begin(&mut self.cardholder_verification_method), + "dedicated_file_name" => Deserialize::begin(&mut self.dedicated_file_name), + "terminal_verification_results" => Deserialize::begin(&mut self.terminal_verification_results), + "transaction_status_information" => Deserialize::begin(&mut self.transaction_status_information), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_type: Deserialize::default(), + application_cryptogram: Deserialize::default(), + application_preferred_name: Deserialize::default(), + authorization_code: Deserialize::default(), + authorization_response_code: Deserialize::default(), + cardholder_verification_method: Deserialize::default(), + dedicated_file_name: Deserialize::default(), + terminal_verification_results: Deserialize::default(), + transaction_status_information: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_type = self.account_type.take()?; + let application_cryptogram = self.application_cryptogram.take()?; + let application_preferred_name = self.application_preferred_name.take()?; + let authorization_code = self.authorization_code.take()?; + let authorization_response_code = self.authorization_response_code.take()?; + let cardholder_verification_method = self.cardholder_verification_method.take()?; + let dedicated_file_name = self.dedicated_file_name.take()?; + let terminal_verification_results = self.terminal_verification_results.take()?; + let transaction_status_information = self.transaction_status_information.take()?; + + Some(Self::Out { + account_type, + application_cryptogram, + application_preferred_name, + authorization_code, + authorization_response_code, + cardholder_verification_method, + dedicated_file_name, + terminal_verification_results, + transaction_status_information, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsInteracPresentReceipt { + type Builder = PaymentMethodDetailsInteracPresentReceiptBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsInteracPresentReceipt { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsInteracPresentReceiptBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "application_cryptogram" => b.application_cryptogram = Some(FromValueOpt::from_value(v)?), + "application_preferred_name" => b.application_preferred_name = Some(FromValueOpt::from_value(v)?), + "authorization_code" => b.authorization_code = Some(FromValueOpt::from_value(v)?), + "authorization_response_code" => b.authorization_response_code = Some(FromValueOpt::from_value(v)?), + "cardholder_verification_method" => b.cardholder_verification_method = Some(FromValueOpt::from_value(v)?), + "dedicated_file_name" => b.dedicated_file_name = Some(FromValueOpt::from_value(v)?), + "terminal_verification_results" => b.terminal_verification_results = Some(FromValueOpt::from_value(v)?), + "transaction_status_information" => b.transaction_status_information = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of account being debited or credited #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsInteracPresentReceiptAccountType { @@ -73,10 +212,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReceiptA fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsInteracPresentReceiptAccountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsInteracPresentReceiptAccountType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReceiptAccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsInteracPresentReceiptAccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsInteracPresentReceiptAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReceiptAccountType); diff --git a/generated/stripe_shared/src/payment_method_details_klarna.rs b/generated/stripe_shared/src/payment_method_details_klarna.rs index 47d911fbe..18e5d23c1 100644 --- a/generated/stripe_shared/src/payment_method_details_klarna.rs +++ b/generated/stripe_shared/src/payment_method_details_klarna.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsKlarna { /// The Klarna payment method used for this transaction. /// Can be one of `pay_later`, `pay_now`, `pay_with_financing`, or `pay_in_installments` @@ -7,3 +9,93 @@ pub struct PaymentMethodDetailsKlarna { /// Can be one of `de-AT`, `en-AT`, `nl-BE`, `fr-BE`, `en-BE`, `de-DE`, `en-DE`, `da-DK`, `en-DK`, `es-ES`, `en-ES`, `fi-FI`, `sv-FI`, `en-FI`, `en-GB`, `en-IE`, `it-IT`, `en-IT`, `nl-NL`, `en-NL`, `nb-NO`, `en-NO`, `sv-SE`, `en-SE`, `en-US`, `es-US`, `fr-FR`, `en-FR`, `cs-CZ`, `en-CZ`, `el-GR`, `en-GR`, `en-AU`, `en-NZ`, `en-CA`, `fr-CA`, `pl-PL`, `en-PL`, `pt-PT`, `en-PT`, `de-CH`, `fr-CH`, `it-CH`, or `en-CH`. pub preferred_locale: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsKlarnaBuilder { + payment_method_category: Option<Option<String>>, + preferred_locale: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsKlarna { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsKlarna>, + builder: PaymentMethodDetailsKlarnaBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsKlarna> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsKlarnaBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsKlarnaBuilder { + type Out = PaymentMethodDetailsKlarna; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "payment_method_category" => Deserialize::begin(&mut self.payment_method_category), + "preferred_locale" => Deserialize::begin(&mut self.preferred_locale), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payment_method_category: Deserialize::default(), preferred_locale: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let payment_method_category = self.payment_method_category.take()?; + let preferred_locale = self.preferred_locale.take()?; + + Some(Self::Out { payment_method_category, preferred_locale }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsKlarna { + type Builder = PaymentMethodDetailsKlarnaBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsKlarna { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsKlarnaBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payment_method_category" => b.payment_method_category = Some(FromValueOpt::from_value(v)?), + "preferred_locale" => b.preferred_locale = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_konbini.rs b/generated/stripe_shared/src/payment_method_details_konbini.rs index 8c4c05f1b..07b4cf3f5 100644 --- a/generated/stripe_shared/src/payment_method_details_konbini.rs +++ b/generated/stripe_shared/src/payment_method_details_konbini.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsKonbini { /// If the payment succeeded, this contains the details of the convenience store where the payment was completed. pub store: Option<stripe_shared::PaymentMethodDetailsKonbiniStore>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsKonbiniBuilder { + store: Option<Option<stripe_shared::PaymentMethodDetailsKonbiniStore>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsKonbini { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsKonbini>, + builder: PaymentMethodDetailsKonbiniBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsKonbini> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsKonbiniBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsKonbiniBuilder { + type Out = PaymentMethodDetailsKonbini; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "store" => Deserialize::begin(&mut self.store), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { store: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let store = self.store.take()?; + + Some(Self::Out { store }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsKonbini { + type Builder = PaymentMethodDetailsKonbiniBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsKonbini { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsKonbiniBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "store" => b.store = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_konbini_store.rs b/generated/stripe_shared/src/payment_method_details_konbini_store.rs index 5817a7f7c..b51121369 100644 --- a/generated/stripe_shared/src/payment_method_details_konbini_store.rs +++ b/generated/stripe_shared/src/payment_method_details_konbini_store.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsKonbiniStore { /// The name of the convenience store chain where the payment was completed. pub chain: Option<PaymentMethodDetailsKonbiniStoreChain>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsKonbiniStoreBuilder { + chain: Option<Option<PaymentMethodDetailsKonbiniStoreChain>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsKonbiniStore { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsKonbiniStore>, + builder: PaymentMethodDetailsKonbiniStoreBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsKonbiniStore> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsKonbiniStoreBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsKonbiniStoreBuilder { + type Out = PaymentMethodDetailsKonbiniStore; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "chain" => Deserialize::begin(&mut self.chain), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { chain: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let chain = self.chain.take()?; + + Some(Self::Out { chain }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsKonbiniStore { + type Builder = PaymentMethodDetailsKonbiniStoreBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsKonbiniStore { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsKonbiniStoreBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "chain" => b.chain = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The name of the convenience store chain where the payment was completed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsKonbiniStoreChain { @@ -59,8 +147,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsKonbiniStoreChain { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodDetailsKonbiniStoreChain") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsKonbiniStoreChain")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsKonbiniStoreChain { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsKonbiniStoreChain> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsKonbiniStoreChain::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsKonbiniStoreChain); diff --git a/generated/stripe_shared/src/payment_method_details_link.rs b/generated/stripe_shared/src/payment_method_details_link.rs index 987e76d1d..ae6efeb65 100644 --- a/generated/stripe_shared/src/payment_method_details_link.rs +++ b/generated/stripe_shared/src/payment_method_details_link.rs @@ -1,6 +1,94 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsLink { /// Two-letter ISO code representing the funding source country beneath the Link payment. /// You could use this attribute to get a sense of international fees. pub country: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsLinkBuilder { + country: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsLink>, + builder: PaymentMethodDetailsLinkBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsLinkBuilder { + type Out = PaymentMethodDetailsLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + + Some(Self::Out { country }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsLink { + type Builder = PaymentMethodDetailsLinkBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_multibanco.rs b/generated/stripe_shared/src/payment_method_details_multibanco.rs index 3bf8acff6..3ce9d0b07 100644 --- a/generated/stripe_shared/src/payment_method_details_multibanco.rs +++ b/generated/stripe_shared/src/payment_method_details_multibanco.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsMultibanco { /// Entity number associated with this Multibanco payment. pub entity: Option<String>, /// Reference number associated with this Multibanco payment. pub reference: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsMultibancoBuilder { + entity: Option<Option<String>>, + reference: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsMultibanco { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsMultibanco>, + builder: PaymentMethodDetailsMultibancoBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsMultibanco> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsMultibancoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsMultibancoBuilder { + type Out = PaymentMethodDetailsMultibanco; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "entity" => Deserialize::begin(&mut self.entity), + "reference" => Deserialize::begin(&mut self.reference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { entity: Deserialize::default(), reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let entity = self.entity.take()?; + let reference = self.reference.take()?; + + Some(Self::Out { entity, reference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsMultibanco { + type Builder = PaymentMethodDetailsMultibancoBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsMultibanco { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsMultibancoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "entity" => b.entity = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_oxxo.rs b/generated/stripe_shared/src/payment_method_details_oxxo.rs index 01e27e1a3..ff15046ab 100644 --- a/generated/stripe_shared/src/payment_method_details_oxxo.rs +++ b/generated/stripe_shared/src/payment_method_details_oxxo.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsOxxo { /// OXXO reference number pub number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsOxxoBuilder { + number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsOxxo { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsOxxo>, + builder: PaymentMethodDetailsOxxoBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsOxxo> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsOxxoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsOxxoBuilder { + type Out = PaymentMethodDetailsOxxo; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "number" => Deserialize::begin(&mut self.number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let number = self.number.take()?; + + Some(Self::Out { number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsOxxo { + type Builder = PaymentMethodDetailsOxxoBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsOxxo { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsOxxoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "number" => b.number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_p24.rs b/generated/stripe_shared/src/payment_method_details_p24.rs index 5a69b86ef..6631a3b43 100644 --- a/generated/stripe_shared/src/payment_method_details_p24.rs +++ b/generated/stripe_shared/src/payment_method_details_p24.rs @@ -1,7 +1,9 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsP24 { /// The customer's bank. - /// Can be one of `ing`, `citi_handlowy`, `tmobile_usbugi_bankowe`, `plus_bank`, `etransfer_pocztowy24`, `banki_spbdzielcze`, `bank_nowy_bfg_sa`, `getin_bank`, `velobank`, `blik`, `noble_pay`, `ideabank`, `envelobank`, `santander_przelew24`, `nest_przelew`, `mbank_mtransfer`, `inteligo`, `pbac_z_ipko`, `bnp_paribas`, `credit_agricole`, `toyota_bank`, `bank_pekao_sa`, `volkswagen_bank`, `bank_millennium`, `alior_bank`, or `boz`. + /// Can be one of `ing`, `citi_handlowy`, `tmobile_usbugi_bankowe`, `plus_bank`, `etransfer_pocztowy24`, `banki_spbdzielcze`, `bank_nowy_bfg_sa`, `getin_bank`, `blik`, `noble_pay`, `ideabank`, `envelobank`, `santander_przelew24`, `nest_przelew`, `mbank_mtransfer`, `inteligo`, `pbac_z_ipko`, `bnp_paribas`, `credit_agricole`, `toyota_bank`, `bank_pekao_sa`, `volkswagen_bank`, `bank_millennium`, `alior_bank`, or `boz`. pub bank: Option<PaymentMethodDetailsP24Bank>, /// Unique reference for this Przelewy24 payment. pub reference: Option<String>, @@ -10,8 +12,102 @@ pub struct PaymentMethodDetailsP24 { /// Przelewy24 rarely provides this information so the attribute is usually empty. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsP24Builder { + bank: Option<Option<PaymentMethodDetailsP24Bank>>, + reference: Option<Option<String>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsP24 { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsP24>, + builder: PaymentMethodDetailsP24Builder, + } + + impl Visitor for Place<PaymentMethodDetailsP24> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsP24Builder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsP24Builder { + type Out = PaymentMethodDetailsP24; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + "reference" => Deserialize::begin(&mut self.reference), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default(), reference: Deserialize::default(), verified_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + let reference = self.reference.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank, reference, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsP24 { + type Builder = PaymentMethodDetailsP24Builder; + } + + impl FromValueOpt for PaymentMethodDetailsP24 { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsP24Builder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer's bank. -/// Can be one of `ing`, `citi_handlowy`, `tmobile_usbugi_bankowe`, `plus_bank`, `etransfer_pocztowy24`, `banki_spbdzielcze`, `bank_nowy_bfg_sa`, `getin_bank`, `velobank`, `blik`, `noble_pay`, `ideabank`, `envelobank`, `santander_przelew24`, `nest_przelew`, `mbank_mtransfer`, `inteligo`, `pbac_z_ipko`, `bnp_paribas`, `credit_agricole`, `toyota_bank`, `bank_pekao_sa`, `volkswagen_bank`, `bank_millennium`, `alior_bank`, or `boz`. +/// Can be one of `ing`, `citi_handlowy`, `tmobile_usbugi_bankowe`, `plus_bank`, `etransfer_pocztowy24`, `banki_spbdzielcze`, `bank_nowy_bfg_sa`, `getin_bank`, `blik`, `noble_pay`, `ideabank`, `envelobank`, `santander_przelew24`, `nest_przelew`, `mbank_mtransfer`, `inteligo`, `pbac_z_ipko`, `bnp_paribas`, `credit_agricole`, `toyota_bank`, `bank_pekao_sa`, `volkswagen_bank`, `bank_millennium`, `alior_bank`, or `boz`. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum PaymentMethodDetailsP24Bank { @@ -39,7 +135,6 @@ pub enum PaymentMethodDetailsP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -72,7 +167,6 @@ impl PaymentMethodDetailsP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -108,7 +202,6 @@ impl std::str::FromStr for PaymentMethodDetailsP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -137,6 +230,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsP24Bank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodDetailsP24Bank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsP24Bank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsP24Bank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsP24Bank::from_str(s).unwrap_or(PaymentMethodDetailsP24Bank::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsP24Bank); diff --git a/generated/stripe_shared/src/payment_method_details_paynow.rs b/generated/stripe_shared/src/payment_method_details_paynow.rs index 7dbf13243..7502df424 100644 --- a/generated/stripe_shared/src/payment_method_details_paynow.rs +++ b/generated/stripe_shared/src/payment_method_details_paynow.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsPaynow { /// Reference number associated with this PayNow payment pub reference: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsPaynowBuilder { + reference: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsPaynow { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsPaynow>, + builder: PaymentMethodDetailsPaynowBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsPaynow> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsPaynowBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsPaynowBuilder { + type Out = PaymentMethodDetailsPaynow; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reference = self.reference.take()?; + + Some(Self::Out { reference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsPaynow { + type Builder = PaymentMethodDetailsPaynowBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsPaynow { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsPaynowBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_paypal.rs b/generated/stripe_shared/src/payment_method_details_paypal.rs index c08a36ed2..8397682ab 100644 --- a/generated/stripe_shared/src/payment_method_details_paypal.rs +++ b/generated/stripe_shared/src/payment_method_details_paypal.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsPaypal { /// Owner's email. Values are provided by PayPal directly /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. @@ -13,3 +15,111 @@ pub struct PaymentMethodDetailsPaypal { /// A unique ID generated by PayPal for this transaction. pub transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsPaypalBuilder { + payer_email: Option<Option<String>>, + payer_id: Option<Option<String>>, + payer_name: Option<Option<String>>, + seller_protection: Option<Option<stripe_shared::PaypalSellerProtection>>, + transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsPaypal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsPaypal>, + builder: PaymentMethodDetailsPaypalBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsPaypal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsPaypalBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsPaypalBuilder { + type Out = PaymentMethodDetailsPaypal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "payer_email" => Deserialize::begin(&mut self.payer_email), + "payer_id" => Deserialize::begin(&mut self.payer_id), + "payer_name" => Deserialize::begin(&mut self.payer_name), + "seller_protection" => Deserialize::begin(&mut self.seller_protection), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + payer_email: Deserialize::default(), + payer_id: Deserialize::default(), + payer_name: Deserialize::default(), + seller_protection: Deserialize::default(), + transaction_id: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let payer_email = self.payer_email.take()?; + let payer_id = self.payer_id.take()?; + let payer_name = self.payer_name.take()?; + let seller_protection = self.seller_protection.take()?; + let transaction_id = self.transaction_id.take()?; + + Some(Self::Out { payer_email, payer_id, payer_name, seller_protection, transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsPaypal { + type Builder = PaymentMethodDetailsPaypalBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsPaypal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsPaypalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payer_email" => b.payer_email = Some(FromValueOpt::from_value(v)?), + "payer_id" => b.payer_id = Some(FromValueOpt::from_value(v)?), + "payer_name" => b.payer_name = Some(FromValueOpt::from_value(v)?), + "seller_protection" => b.seller_protection = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_pix.rs b/generated/stripe_shared/src/payment_method_details_pix.rs index a92189d86..f87891c76 100644 --- a/generated/stripe_shared/src/payment_method_details_pix.rs +++ b/generated/stripe_shared/src/payment_method_details_pix.rs @@ -1,6 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsPix { /// Unique transaction id generated by BCB - #[serde(skip_serializing_if = "Option::is_none")] pub bank_transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsPixBuilder { + bank_transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsPix { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsPix>, + builder: PaymentMethodDetailsPixBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsPix> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsPixBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsPixBuilder { + type Out = PaymentMethodDetailsPix; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_transaction_id" => Deserialize::begin(&mut self.bank_transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_transaction_id = self.bank_transaction_id.take()?; + + Some(Self::Out { bank_transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsPix { + type Builder = PaymentMethodDetailsPixBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsPix { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsPixBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_transaction_id" => b.bank_transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_promptpay.rs b/generated/stripe_shared/src/payment_method_details_promptpay.rs index 44b0d772e..2c4004bf8 100644 --- a/generated/stripe_shared/src/payment_method_details_promptpay.rs +++ b/generated/stripe_shared/src/payment_method_details_promptpay.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsPromptpay { /// Bill reference generated by PromptPay pub reference: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsPromptpayBuilder { + reference: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsPromptpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsPromptpay>, + builder: PaymentMethodDetailsPromptpayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsPromptpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsPromptpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsPromptpayBuilder { + type Out = PaymentMethodDetailsPromptpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reference = self.reference.take()?; + + Some(Self::Out { reference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsPromptpay { + type Builder = PaymentMethodDetailsPromptpayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsPromptpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsPromptpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_revolut_pay.rs b/generated/stripe_shared/src/payment_method_details_revolut_pay.rs index 8207d189c..9d3948030 100644 --- a/generated/stripe_shared/src/payment_method_details_revolut_pay.rs +++ b/generated/stripe_shared/src/payment_method_details_revolut_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsRevolutPay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsRevolutPayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsRevolutPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsRevolutPay>, + builder: PaymentMethodDetailsRevolutPayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsRevolutPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsRevolutPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsRevolutPayBuilder { + type Out = PaymentMethodDetailsRevolutPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsRevolutPay { + type Builder = PaymentMethodDetailsRevolutPayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsRevolutPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsRevolutPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_sepa_credit_transfer.rs b/generated/stripe_shared/src/payment_method_details_sepa_credit_transfer.rs index 008b614cc..858a6731c 100644 --- a/generated/stripe_shared/src/payment_method_details_sepa_credit_transfer.rs +++ b/generated/stripe_shared/src/payment_method_details_sepa_credit_transfer.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsSepaCreditTransfer { /// Name of the bank associated with the bank account. pub bank_name: Option<String>, @@ -7,3 +9,97 @@ pub struct PaymentMethodDetailsSepaCreditTransfer { /// IBAN of the bank account to transfer funds to. pub iban: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsSepaCreditTransferBuilder { + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + iban: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsSepaCreditTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsSepaCreditTransfer>, + builder: PaymentMethodDetailsSepaCreditTransferBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsSepaCreditTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsSepaCreditTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsSepaCreditTransferBuilder { + type Out = PaymentMethodDetailsSepaCreditTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "iban" => Deserialize::begin(&mut self.iban), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_name: Deserialize::default(), bic: Deserialize::default(), iban: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let iban = self.iban.take()?; + + Some(Self::Out { bank_name, bic, iban }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsSepaCreditTransfer { + type Builder = PaymentMethodDetailsSepaCreditTransferBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsSepaCreditTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsSepaCreditTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "iban" => b.iban = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_sepa_debit.rs b/generated/stripe_shared/src/payment_method_details_sepa_debit.rs index 8a79283c1..91cd1c2d4 100644 --- a/generated/stripe_shared/src/payment_method_details_sepa_debit.rs +++ b/generated/stripe_shared/src/payment_method_details_sepa_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsSepaDebit { /// Bank code of bank associated with the bank account. pub bank_code: Option<String>, @@ -15,3 +17,116 @@ pub struct PaymentMethodDetailsSepaDebit { /// Use this mandate ID to [retrieve the Mandate](https://stripe.com/docs/api/mandates/retrieve). pub mandate: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsSepaDebitBuilder { + bank_code: Option<Option<String>>, + branch_code: Option<Option<String>>, + country: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + mandate: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsSepaDebit>, + builder: PaymentMethodDetailsSepaDebitBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsSepaDebitBuilder { + type Out = PaymentMethodDetailsSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "branch_code" => Deserialize::begin(&mut self.branch_code), + "country" => Deserialize::begin(&mut self.country), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "mandate" => Deserialize::begin(&mut self.mandate), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + branch_code: Deserialize::default(), + country: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + mandate: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let branch_code = self.branch_code.take()?; + let country = self.country.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let mandate = self.mandate.take()?; + + Some(Self::Out { bank_code, branch_code, country, fingerprint, last4, mandate }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsSepaDebit { + type Builder = PaymentMethodDetailsSepaDebitBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "branch_code" => b.branch_code = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "mandate" => b.mandate = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_sofort.rs b/generated/stripe_shared/src/payment_method_details_sofort.rs index db61df3b6..250d9fdf7 100644 --- a/generated/stripe_shared/src/payment_method_details_sofort.rs +++ b/generated/stripe_shared/src/payment_method_details_sofort.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsSofort { /// Bank code of bank associated with the bank account. pub bank_code: Option<String>, @@ -21,6 +23,134 @@ pub struct PaymentMethodDetailsSofort { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsSofortBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + country: Option<Option<String>>, + generated_sepa_debit: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + generated_sepa_debit_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + iban_last4: Option<Option<String>>, + preferred_language: Option<Option<PaymentMethodDetailsSofortPreferredLanguage>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsSofort { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsSofort>, + builder: PaymentMethodDetailsSofortBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsSofort> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsSofortBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsSofortBuilder { + type Out = PaymentMethodDetailsSofort; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "country" => Deserialize::begin(&mut self.country), + "generated_sepa_debit" => Deserialize::begin(&mut self.generated_sepa_debit), + "generated_sepa_debit_mandate" => Deserialize::begin(&mut self.generated_sepa_debit_mandate), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + bic: Deserialize::default(), + country: Deserialize::default(), + generated_sepa_debit: Deserialize::default(), + generated_sepa_debit_mandate: Deserialize::default(), + iban_last4: Deserialize::default(), + preferred_language: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let country = self.country.take()?; + let generated_sepa_debit = self.generated_sepa_debit.take()?; + let generated_sepa_debit_mandate = self.generated_sepa_debit_mandate.take()?; + let iban_last4 = self.iban_last4.take()?; + let preferred_language = self.preferred_language.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank_code, bank_name, bic, country, generated_sepa_debit, generated_sepa_debit_mandate, iban_last4, preferred_language, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsSofort { + type Builder = PaymentMethodDetailsSofortBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsSofort { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsSofortBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit" => b.generated_sepa_debit = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit_mandate" => b.generated_sepa_debit_mandate = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred language of the SOFORT authorization page that the customer is redirected to. /// Can be one of `de`, `en`, `es`, `fr`, `it`, `nl`, or `pl` #[derive(Copy, Clone, Eq, PartialEq)] @@ -87,10 +217,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsSofortPreferredLanguag fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsSofortPreferredLanguage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsSofortPreferredLanguage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsSofortPreferredLanguage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsSofortPreferredLanguage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsSofortPreferredLanguage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsSofortPreferredLanguage); diff --git a/generated/stripe_shared/src/payment_method_details_stripe_account.rs b/generated/stripe_shared/src/payment_method_details_stripe_account.rs index 730157405..2a22e3358 100644 --- a/generated/stripe_shared/src/payment_method_details_stripe_account.rs +++ b/generated/stripe_shared/src/payment_method_details_stripe_account.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsStripeAccount {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsStripeAccountBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsStripeAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsStripeAccount>, + builder: PaymentMethodDetailsStripeAccountBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsStripeAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsStripeAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsStripeAccountBuilder { + type Out = PaymentMethodDetailsStripeAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsStripeAccount { + type Builder = PaymentMethodDetailsStripeAccountBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsStripeAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsStripeAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_swish.rs b/generated/stripe_shared/src/payment_method_details_swish.rs deleted file mode 100644 index 26525604f..000000000 --- a/generated/stripe_shared/src/payment_method_details_swish.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct PaymentMethodDetailsSwish { - /// Uniquely identifies the payer's Swish account. - /// You can use this attribute to check whether two Swish transactions were paid for by the same payer. - pub fingerprint: Option<String>, - /// Payer bank reference number for the payment - pub payment_reference: Option<String>, - /// The last four digits of the Swish account phone number - pub verified_phone_last4: Option<String>, -} diff --git a/generated/stripe_shared/src/payment_method_details_us_bank_account.rs b/generated/stripe_shared/src/payment_method_details_us_bank_account.rs index a73587c8b..67c74122b 100644 --- a/generated/stripe_shared/src/payment_method_details_us_bank_account.rs +++ b/generated/stripe_shared/src/payment_method_details_us_bank_account.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. pub account_holder_type: Option<PaymentMethodDetailsUsBankAccountAccountHolderType>, @@ -14,6 +16,119 @@ pub struct PaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: Option<Option<PaymentMethodDetailsUsBankAccountAccountHolderType>>, + account_type: Option<Option<PaymentMethodDetailsUsBankAccountAccountType>>, + bank_name: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsUsBankAccount>, + builder: PaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsUsBankAccountBuilder { + type Out = PaymentMethodDetailsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "account_type" => Deserialize::begin(&mut self.account_type), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_type: Deserialize::default(), + account_type: Deserialize::default(), + bank_name: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let account_type = self.account_type.take()?; + let bank_name = self.bank_name.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { account_holder_type, account_type, bank_name, fingerprint, last4, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsUsBankAccount { + type Builder = PaymentMethodDetailsUsBankAccountBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Account holder type: individual or company. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsUsBankAccountAccountHolderType { @@ -64,13 +179,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsUsBankAccountAccountHo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsUsBankAccountAccountHolderType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsUsBankAccountAccountHolderType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsUsBankAccountAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsUsBankAccountAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsUsBankAccountAccountHolderType); /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodDetailsUsBankAccountAccountType { @@ -121,10 +250,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsUsBankAccountAccountTy fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodDetailsUsBankAccountAccountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodDetailsUsBankAccountAccountType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodDetailsUsBankAccountAccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDetailsUsBankAccountAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsUsBankAccountAccountType); diff --git a/generated/stripe_shared/src/payment_method_details_wechat.rs b/generated/stripe_shared/src/payment_method_details_wechat.rs index 33dbea74d..02090350e 100644 --- a/generated/stripe_shared/src/payment_method_details_wechat.rs +++ b/generated/stripe_shared/src/payment_method_details_wechat.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsWechat {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsWechatBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsWechat { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsWechat>, + builder: PaymentMethodDetailsWechatBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsWechat> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsWechatBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsWechatBuilder { + type Out = PaymentMethodDetailsWechat; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsWechat { + type Builder = PaymentMethodDetailsWechatBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsWechat { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsWechatBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_wechat_pay.rs b/generated/stripe_shared/src/payment_method_details_wechat_pay.rs index ab0737345..d6f9c2eef 100644 --- a/generated/stripe_shared/src/payment_method_details_wechat_pay.rs +++ b/generated/stripe_shared/src/payment_method_details_wechat_pay.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsWechatPay { /// Uniquely identifies this particular WeChat Pay account. /// You can use this attribute to check whether two WeChat accounts are the same. @@ -6,3 +8,93 @@ pub struct PaymentMethodDetailsWechatPay { /// Transaction ID of this particular WeChat Pay transaction. pub transaction_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsWechatPayBuilder { + fingerprint: Option<Option<String>>, + transaction_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsWechatPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsWechatPay>, + builder: PaymentMethodDetailsWechatPayBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsWechatPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsWechatPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsWechatPayBuilder { + type Out = PaymentMethodDetailsWechatPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { fingerprint: Deserialize::default(), transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let fingerprint = self.fingerprint.take()?; + let transaction_id = self.transaction_id.take()?; + + Some(Self::Out { fingerprint, transaction_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsWechatPay { + type Builder = PaymentMethodDetailsWechatPayBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsWechatPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsWechatPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_details_zip.rs b/generated/stripe_shared/src/payment_method_details_zip.rs index 4dfd4c934..3aabe76f5 100644 --- a/generated/stripe_shared/src/payment_method_details_zip.rs +++ b/generated/stripe_shared/src/payment_method_details_zip.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodDetailsZip {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodDetailsZipBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsZip { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodDetailsZip>, + builder: PaymentMethodDetailsZipBuilder, + } + + impl Visitor for Place<PaymentMethodDetailsZip> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodDetailsZipBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodDetailsZipBuilder { + type Out = PaymentMethodDetailsZip; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsZip { + type Builder = PaymentMethodDetailsZipBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsZip { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsZipBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_eps.rs b/generated/stripe_shared/src/payment_method_eps.rs index dde24edfb..3af33fa05 100644 --- a/generated/stripe_shared/src/payment_method_eps.rs +++ b/generated/stripe_shared/src/payment_method_eps.rs @@ -1,9 +1,97 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodEps { /// The customer's bank. /// Should be one of `arzte_und_apotheker_bank`, `austrian_anadi_bank_ag`, `bank_austria`, `bankhaus_carl_spangler`, `bankhaus_schelhammer_und_schattera_ag`, `bawag_psk_ag`, `bks_bank_ag`, `brull_kallmus_bank_ag`, `btv_vier_lander_bank`, `capital_bank_grawe_gruppe_ag`, `deutsche_bank_ag`, `dolomitenbank`, `easybank_ag`, `erste_bank_und_sparkassen`, `hypo_alpeadriabank_international_ag`, `hypo_noe_lb_fur_niederosterreich_u_wien`, `hypo_oberosterreich_salzburg_steiermark`, `hypo_tirol_bank_ag`, `hypo_vorarlberg_bank_ag`, `hypo_bank_burgenland_aktiengesellschaft`, `marchfelder_bank`, `oberbank_ag`, `raiffeisen_bankengruppe_osterreich`, `schoellerbank_ag`, `sparda_bank_wien`, `volksbank_gruppe`, `volkskreditbank_ag`, or `vr_bank_braunau`. pub bank: Option<PaymentMethodEpsBank>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodEpsBuilder { + bank: Option<Option<PaymentMethodEpsBank>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodEps { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodEps>, + builder: PaymentMethodEpsBuilder, + } + + impl Visitor for Place<PaymentMethodEps> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodEpsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodEpsBuilder { + type Out = PaymentMethodEps; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + + Some(Self::Out { bank }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodEps { + type Builder = PaymentMethodEpsBuilder; + } + + impl FromValueOpt for PaymentMethodEps { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodEpsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer's bank. /// Should be one of `arzte_und_apotheker_bank`, `austrian_anadi_bank_ag`, `bank_austria`, `bankhaus_carl_spangler`, `bankhaus_schelhammer_und_schattera_ag`, `bawag_psk_ag`, `bks_bank_ag`, `brull_kallmus_bank_ag`, `btv_vier_lander_bank`, `capital_bank_grawe_gruppe_ag`, `deutsche_bank_ag`, `dolomitenbank`, `easybank_ag`, `erste_bank_und_sparkassen`, `hypo_alpeadriabank_international_ag`, `hypo_noe_lb_fur_niederosterreich_u_wien`, `hypo_oberosterreich_salzburg_steiermark`, `hypo_tirol_bank_ag`, `hypo_vorarlberg_bank_ag`, `hypo_bank_burgenland_aktiengesellschaft`, `marchfelder_bank`, `oberbank_ag`, `raiffeisen_bankengruppe_osterreich`, `schoellerbank_ag`, `sparda_bank_wien`, `volksbank_gruppe`, `volkskreditbank_ag`, or `vr_bank_braunau`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -137,6 +225,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodEpsBank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodEpsBank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodEpsBank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodEpsBank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodEpsBank::from_str(s).unwrap_or(PaymentMethodEpsBank::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodEpsBank); diff --git a/generated/stripe_shared/src/payment_method_fpx.rs b/generated/stripe_shared/src/payment_method_fpx.rs index faf3c8fd6..202040cfc 100644 --- a/generated/stripe_shared/src/payment_method_fpx.rs +++ b/generated/stripe_shared/src/payment_method_fpx.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodFpx { /// Account holder type, if provided. Can be one of `individual` or `company`. pub account_holder_type: Option<PaymentMethodFpxAccountHolderType>, @@ -6,6 +8,96 @@ pub struct PaymentMethodFpx { /// Can be one of `affin_bank`, `agrobank`, `alliance_bank`, `ambank`, `bank_islam`, `bank_muamalat`, `bank_rakyat`, `bsn`, `cimb`, `hong_leong_bank`, `hsbc`, `kfh`, `maybank2u`, `ocbc`, `public_bank`, `rhb`, `standard_chartered`, `uob`, `deutsche_bank`, `maybank2e`, `pb_enterprise`, or `bank_of_china`. pub bank: PaymentMethodFpxBank, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodFpxBuilder { + account_holder_type: Option<Option<PaymentMethodFpxAccountHolderType>>, + bank: Option<PaymentMethodFpxBank>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodFpx { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodFpx>, + builder: PaymentMethodFpxBuilder, + } + + impl Visitor for Place<PaymentMethodFpx> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodFpxBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodFpxBuilder { + type Out = PaymentMethodFpx; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "bank" => Deserialize::begin(&mut self.bank), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_holder_type: Deserialize::default(), bank: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let bank = self.bank.take()?; + + Some(Self::Out { account_holder_type, bank }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodFpx { + type Builder = PaymentMethodFpxBuilder; + } + + impl FromValueOpt for PaymentMethodFpx { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodFpxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Account holder type, if provided. Can be one of `individual` or `company`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodFpxAccountHolderType { @@ -56,11 +148,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodFpxAccountHolderType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodFpxAccountHolderType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodFpxAccountHolderType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodFpxAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodFpxAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodFpxAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodFpxAccountHolderType); /// The customer's bank, if provided. /// Can be one of `affin_bank`, `agrobank`, `alliance_bank`, `ambank`, `bank_islam`, `bank_muamalat`, `bank_rakyat`, `bsn`, `cimb`, `hong_leong_bank`, `hsbc`, `kfh`, `maybank2u`, `ocbc`, `public_bank`, `rhb`, `standard_chartered`, `uob`, `deutsche_bank`, `maybank2e`, `pb_enterprise`, or `bank_of_china`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -176,6 +284,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodFpxBank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodFpxBank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodFpxBank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodFpxBank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodFpxBank::from_str(s).unwrap_or(PaymentMethodFpxBank::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodFpxBank); diff --git a/generated/stripe_shared/src/payment_method_giropay.rs b/generated/stripe_shared/src/payment_method_giropay.rs index 1003535de..3deaa545b 100644 --- a/generated/stripe_shared/src/payment_method_giropay.rs +++ b/generated/stripe_shared/src/payment_method_giropay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodGiropay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodGiropayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodGiropay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodGiropay>, + builder: PaymentMethodGiropayBuilder, + } + + impl Visitor for Place<PaymentMethodGiropay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodGiropayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodGiropayBuilder { + type Out = PaymentMethodGiropay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodGiropay { + type Builder = PaymentMethodGiropayBuilder; + } + + impl FromValueOpt for PaymentMethodGiropay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodGiropayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_grabpay.rs b/generated/stripe_shared/src/payment_method_grabpay.rs index 8832df64a..2dfa8248c 100644 --- a/generated/stripe_shared/src/payment_method_grabpay.rs +++ b/generated/stripe_shared/src/payment_method_grabpay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodGrabpay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodGrabpayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodGrabpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodGrabpay>, + builder: PaymentMethodGrabpayBuilder, + } + + impl Visitor for Place<PaymentMethodGrabpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodGrabpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodGrabpayBuilder { + type Out = PaymentMethodGrabpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodGrabpay { + type Builder = PaymentMethodGrabpayBuilder; + } + + impl FromValueOpt for PaymentMethodGrabpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodGrabpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_ideal.rs b/generated/stripe_shared/src/payment_method_ideal.rs index e5c8d7092..883c32025 100644 --- a/generated/stripe_shared/src/payment_method_ideal.rs +++ b/generated/stripe_shared/src/payment_method_ideal.rs @@ -1,13 +1,105 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodIdeal { /// The customer's bank, if provided. - /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. + /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. pub bank: Option<PaymentMethodIdealBank>, /// The Bank Identifier Code of the customer's bank, if the bank was provided. pub bic: Option<PaymentMethodIdealBic>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodIdealBuilder { + bank: Option<Option<PaymentMethodIdealBank>>, + bic: Option<Option<PaymentMethodIdealBic>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodIdeal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodIdeal>, + builder: PaymentMethodIdealBuilder, + } + + impl Visitor for Place<PaymentMethodIdeal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodIdealBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodIdealBuilder { + type Out = PaymentMethodIdeal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + "bic" => Deserialize::begin(&mut self.bic), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default(), bic: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + let bic = self.bic.take()?; + + Some(Self::Out { bank, bic }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodIdeal { + type Builder = PaymentMethodIdealBuilder; + } + + impl FromValueOpt for PaymentMethodIdeal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodIdealBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer's bank, if provided. -/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. +/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum PaymentMethodIdealBank { @@ -19,7 +111,6 @@ pub enum PaymentMethodIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -42,7 +133,6 @@ impl PaymentMethodIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -68,7 +158,6 @@ impl std::str::FromStr for PaymentMethodIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -103,9 +192,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodIdealBank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodIdealBank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodIdealBank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodIdealBank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodIdealBank::from_str(s).unwrap_or(PaymentMethodIdealBank::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodIdealBank); /// The Bank Identifier Code of the customer's bank, if the bank was provided. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -119,7 +226,6 @@ pub enum PaymentMethodIdealBic { Ingbnl2a, Knabnl2h, Moyonl21, - Nnbanl2g, Ntsbdeb1, Rabonl2u, Rbrbnl21, @@ -143,7 +249,6 @@ impl PaymentMethodIdealBic { Ingbnl2a => "INGBNL2A", Knabnl2h => "KNABNL2H", Moyonl21 => "MOYONL21", - Nnbanl2g => "NNBANL2G", Ntsbdeb1 => "NTSBDEB1", Rabonl2u => "RABONL2U", Rbrbnl21 => "RBRBNL21", @@ -170,7 +275,6 @@ impl std::str::FromStr for PaymentMethodIdealBic { "INGBNL2A" => Ok(Ingbnl2a), "KNABNL2H" => Ok(Knabnl2h), "MOYONL21" => Ok(Moyonl21), - "NNBANL2G" => Ok(Nnbanl2g), "NTSBDEB1" => Ok(Ntsbdeb1), "RABONL2U" => Ok(Rabonl2u), "RBRBNL21" => Ok(Rbrbnl21), @@ -205,6 +309,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodIdealBic { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodIdealBic::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodIdealBic { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodIdealBic> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodIdealBic::from_str(s).unwrap_or(PaymentMethodIdealBic::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodIdealBic); diff --git a/generated/stripe_shared/src/payment_method_interac_present.rs b/generated/stripe_shared/src/payment_method_interac_present.rs index 32e84af30..ad81da31d 100644 --- a/generated/stripe_shared/src/payment_method_interac_present.rs +++ b/generated/stripe_shared/src/payment_method_interac_present.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodInteracPresent { /// Card brand. Can be `interac`, `mastercard` or `visa`. pub brand: Option<String>, @@ -12,7 +14,6 @@ pub struct PaymentMethodInteracPresent { pub country: Option<String>, /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// Two-digit number representing the card's expiration month. pub exp_month: i64, @@ -28,11 +29,9 @@ pub struct PaymentMethodInteracPresent { pub funding: Option<String>, /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, /// The last four digits of the card. pub last4: Option<String>, @@ -43,6 +42,159 @@ pub struct PaymentMethodInteracPresent { /// How card details were read in this transaction. pub read_method: Option<PaymentMethodInteracPresentReadMethod>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodInteracPresentBuilder { + brand: Option<Option<String>>, + cardholder_name: Option<Option<String>>, + country: Option<Option<String>>, + description: Option<Option<String>>, + exp_month: Option<i64>, + exp_year: Option<i64>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + networks: Option<Option<stripe_shared::PaymentMethodCardPresentNetworks>>, + preferred_locales: Option<Option<Vec<String>>>, + read_method: Option<Option<PaymentMethodInteracPresentReadMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodInteracPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodInteracPresent>, + builder: PaymentMethodInteracPresentBuilder, + } + + impl Visitor for Place<PaymentMethodInteracPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodInteracPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodInteracPresentBuilder { + type Out = PaymentMethodInteracPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "brand" => Deserialize::begin(&mut self.brand), + "cardholder_name" => Deserialize::begin(&mut self.cardholder_name), + "country" => Deserialize::begin(&mut self.country), + "description" => Deserialize::begin(&mut self.description), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "networks" => Deserialize::begin(&mut self.networks), + "preferred_locales" => Deserialize::begin(&mut self.preferred_locales), + "read_method" => Deserialize::begin(&mut self.read_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + brand: Deserialize::default(), + cardholder_name: Deserialize::default(), + country: Deserialize::default(), + description: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + networks: Deserialize::default(), + preferred_locales: Deserialize::default(), + read_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let brand = self.brand.take()?; + let cardholder_name = self.cardholder_name.take()?; + let country = self.country.take()?; + let description = self.description.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let networks = self.networks.take()?; + let preferred_locales = self.preferred_locales.take()?; + let read_method = self.read_method.take()?; + + Some(Self::Out { brand, cardholder_name, country, description, exp_month, exp_year, fingerprint, funding, iin, issuer, last4, networks, preferred_locales, read_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodInteracPresent { + type Builder = PaymentMethodInteracPresentBuilder; + } + + impl FromValueOpt for PaymentMethodInteracPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodInteracPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "cardholder_name" => b.cardholder_name = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "networks" => b.networks = Some(FromValueOpt::from_value(v)?), + "preferred_locales" => b.preferred_locales = Some(FromValueOpt::from_value(v)?), + "read_method" => b.read_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// How card details were read in this transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodInteracPresentReadMethod { @@ -102,8 +254,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodInteracPresentReadMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodInteracPresentReadMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodInteracPresentReadMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodInteracPresentReadMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodInteracPresentReadMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodInteracPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodInteracPresentReadMethod); diff --git a/generated/stripe_shared/src/payment_method_klarna.rs b/generated/stripe_shared/src/payment_method_klarna.rs index 310d1c2b1..52d693a0a 100644 --- a/generated/stripe_shared/src/payment_method_klarna.rs +++ b/generated/stripe_shared/src/payment_method_klarna.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodKlarna { /// The customer's date of birth, if provided. pub dob: Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsKlarnaDob>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodKlarnaBuilder { + dob: Option<Option<stripe_shared::PaymentFlowsPrivatePaymentMethodsKlarnaDob>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodKlarna { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodKlarna>, + builder: PaymentMethodKlarnaBuilder, + } + + impl Visitor for Place<PaymentMethodKlarna> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodKlarnaBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodKlarnaBuilder { + type Out = PaymentMethodKlarna; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "dob" => Deserialize::begin(&mut self.dob), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { dob: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let dob = self.dob.take()?; + + Some(Self::Out { dob }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodKlarna { + type Builder = PaymentMethodKlarnaBuilder; + } + + impl FromValueOpt for PaymentMethodKlarna { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodKlarnaBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "dob" => b.dob = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_konbini.rs b/generated/stripe_shared/src/payment_method_konbini.rs index 0df2b4210..74f7720f7 100644 --- a/generated/stripe_shared/src/payment_method_konbini.rs +++ b/generated/stripe_shared/src/payment_method_konbini.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodKonbini {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodKonbiniBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodKonbini { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodKonbini>, + builder: PaymentMethodKonbiniBuilder, + } + + impl Visitor for Place<PaymentMethodKonbini> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodKonbiniBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodKonbiniBuilder { + type Out = PaymentMethodKonbini; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodKonbini { + type Builder = PaymentMethodKonbiniBuilder; + } + + impl FromValueOpt for PaymentMethodKonbini { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodKonbiniBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_link.rs b/generated/stripe_shared/src/payment_method_link.rs index 45718fced..b381e5374 100644 --- a/generated/stripe_shared/src/payment_method_link.rs +++ b/generated/stripe_shared/src/payment_method_link.rs @@ -1,8 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodLink { /// Account owner's email address. pub email: Option<String>, /// \[Deprecated\] This is a legacy parameter that no longer has any function. - #[serde(skip_serializing_if = "Option::is_none")] pub persistent_token: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodLinkBuilder { + email: Option<Option<String>>, + persistent_token: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodLink>, + builder: PaymentMethodLinkBuilder, + } + + impl Visitor for Place<PaymentMethodLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodLinkBuilder { + type Out = PaymentMethodLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "email" => Deserialize::begin(&mut self.email), + "persistent_token" => Deserialize::begin(&mut self.persistent_token), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { email: Deserialize::default(), persistent_token: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let email = self.email.take()?; + let persistent_token = self.persistent_token.take()?; + + Some(Self::Out { email, persistent_token }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodLink { + type Builder = PaymentMethodLinkBuilder; + } + + impl FromValueOpt for PaymentMethodLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "persistent_token" => b.persistent_token = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_options_affirm.rs b/generated/stripe_shared/src/payment_method_options_affirm.rs index a78bd6919..2f776f55a 100644 --- a/generated/stripe_shared/src/payment_method_options_affirm.rs +++ b/generated/stripe_shared/src/payment_method_options_affirm.rs @@ -1,10 +1,10 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsAffirm { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<PaymentMethodOptionsAffirmCaptureMethod>, /// Preferred language of the Affirm authorization page that the customer is redirected to. - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_locale: Option<String>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -12,9 +12,102 @@ pub struct PaymentMethodOptionsAffirm { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsAffirmSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsAffirmBuilder { + capture_method: Option<Option<PaymentMethodOptionsAffirmCaptureMethod>>, + preferred_locale: Option<Option<String>>, + setup_future_usage: Option<Option<PaymentMethodOptionsAffirmSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsAffirm { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsAffirm>, + builder: PaymentMethodOptionsAffirmBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsAffirm> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsAffirmBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsAffirmBuilder { + type Out = PaymentMethodOptionsAffirm; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "preferred_locale" => Deserialize::begin(&mut self.preferred_locale), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { capture_method: Deserialize::default(), preferred_locale: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let preferred_locale = self.preferred_locale.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { capture_method, preferred_locale, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsAffirm { + type Builder = PaymentMethodOptionsAffirmBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsAffirm { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsAffirmBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "preferred_locale" => b.preferred_locale = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsAffirmCaptureMethod { @@ -62,11 +155,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAffirmCaptureMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsAffirmCaptureMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsAffirmCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsAffirmCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsAffirmCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsAffirmCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAffirmCaptureMethod); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -119,8 +228,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAffirmSetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsAffirmSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsAffirmSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsAffirmSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsAffirmSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsAffirmSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAffirmSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_afterpay_clearpay.rs b/generated/stripe_shared/src/payment_method_options_afterpay_clearpay.rs index f07f9ec26..5c45c1252 100644 --- a/generated/stripe_shared/src/payment_method_options_afterpay_clearpay.rs +++ b/generated/stripe_shared/src/payment_method_options_afterpay_clearpay.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsAfterpayClearpay { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<PaymentMethodOptionsAfterpayClearpayCaptureMethod>, /// An internal identifier or reference that this payment corresponds to. /// You must limit the identifier to 128 characters, and it can only contain letters, numbers, underscores, backslashes, and dashes. @@ -13,9 +14,102 @@ pub struct PaymentMethodOptionsAfterpayClearpay { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsAfterpayClearpaySetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsAfterpayClearpayBuilder { + capture_method: Option<Option<PaymentMethodOptionsAfterpayClearpayCaptureMethod>>, + reference: Option<Option<String>>, + setup_future_usage: Option<Option<PaymentMethodOptionsAfterpayClearpaySetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsAfterpayClearpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsAfterpayClearpay>, + builder: PaymentMethodOptionsAfterpayClearpayBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsAfterpayClearpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsAfterpayClearpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsAfterpayClearpayBuilder { + type Out = PaymentMethodOptionsAfterpayClearpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "reference" => Deserialize::begin(&mut self.reference), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { capture_method: Deserialize::default(), reference: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let reference = self.reference.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { capture_method, reference, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsAfterpayClearpay { + type Builder = PaymentMethodOptionsAfterpayClearpayBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsAfterpayClearpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsAfterpayClearpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsAfterpayClearpayCaptureMethod { @@ -63,13 +157,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAfterpayClearpayCaptur fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsAfterpayClearpayCaptureMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsAfterpayClearpayCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsAfterpayClearpayCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsAfterpayClearpayCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsAfterpayClearpayCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAfterpayClearpayCaptureMethod); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -122,10 +230,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAfterpayClearpaySetupF fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsAfterpayClearpaySetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsAfterpayClearpaySetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAfterpayClearpaySetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_alipay.rs b/generated/stripe_shared/src/payment_method_options_alipay.rs index 9013c291f..959ef9d90 100644 --- a/generated/stripe_shared/src/payment_method_options_alipay.rs +++ b/generated/stripe_shared/src/payment_method_options_alipay.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsAlipay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsAlipay { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsAlipaySetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsAlipayBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsAlipaySetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsAlipay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsAlipay>, + builder: PaymentMethodOptionsAlipayBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsAlipay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsAlipayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsAlipayBuilder { + type Out = PaymentMethodOptionsAlipay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsAlipay { + type Builder = PaymentMethodOptionsAlipayBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsAlipay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsAlipayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -64,8 +151,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAlipaySetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsAlipaySetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsAlipaySetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsAlipaySetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsAlipaySetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsAlipaySetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAlipaySetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_bacs_debit.rs b/generated/stripe_shared/src/payment_method_options_bacs_debit.rs index b3718bc93..e3d84ed53 100644 --- a/generated/stripe_shared/src/payment_method_options_bacs_debit.rs +++ b/generated/stripe_shared/src/payment_method_options_bacs_debit.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsBacsDebit { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsBacsDebit { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsBacsDebitSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsBacsDebitBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsBacsDebitSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsBacsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsBacsDebit>, + builder: PaymentMethodOptionsBacsDebitBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsBacsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsBacsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsBacsDebitBuilder { + type Out = PaymentMethodOptionsBacsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsBacsDebit { + type Builder = PaymentMethodOptionsBacsDebitBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsBacsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsBacsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -67,10 +154,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBacsDebitSetupFutureUs fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsBacsDebitSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsBacsDebitSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsBacsDebitSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsBacsDebitSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsBacsDebitSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBacsDebitSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_bancontact.rs b/generated/stripe_shared/src/payment_method_options_bancontact.rs index dfc086ae3..e95fcdff8 100644 --- a/generated/stripe_shared/src/payment_method_options_bancontact.rs +++ b/generated/stripe_shared/src/payment_method_options_bancontact.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. pub preferred_language: PaymentMethodOptionsBancontactPreferredLanguage, @@ -8,9 +10,98 @@ pub struct PaymentMethodOptionsBancontact { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsBancontactSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsBancontactBuilder { + preferred_language: Option<PaymentMethodOptionsBancontactPreferredLanguage>, + setup_future_usage: Option<Option<PaymentMethodOptionsBancontactSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsBancontact { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsBancontact>, + builder: PaymentMethodOptionsBancontactBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsBancontact> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsBancontactBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsBancontactBuilder { + type Out = PaymentMethodOptionsBancontact; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { preferred_language: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let preferred_language = self.preferred_language.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { preferred_language, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsBancontact { + type Builder = PaymentMethodOptionsBancontactBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsBancontact { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsBancontactBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred language of the Bancontact authorization page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsBancontactPreferredLanguage { @@ -67,13 +158,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBancontactPreferredLan fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsBancontactPreferredLanguage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsBancontactPreferredLanguage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsBancontactPreferredLanguage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsBancontactPreferredLanguage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsBancontactPreferredLanguage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBancontactPreferredLanguage); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -129,10 +234,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBancontactSetupFutureU fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsBancontactSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsBancontactSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsBancontactSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsBancontactSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsBancontactSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBancontactSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_boleto.rs b/generated/stripe_shared/src/payment_method_options_boleto.rs index 3e72deb93..c59940a38 100644 --- a/generated/stripe_shared/src/payment_method_options_boleto.rs +++ b/generated/stripe_shared/src/payment_method_options_boleto.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsBoleto { /// The number of calendar days before a Boleto voucher expires. /// For example, if you create a Boleto voucher on Monday and you set expires_after_days to 2, the Boleto voucher will expire on Wednesday at 23:59 America/Sao_Paulo time. @@ -9,9 +11,98 @@ pub struct PaymentMethodOptionsBoleto { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsBoletoSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsBoletoBuilder { + expires_after_days: Option<u32>, + setup_future_usage: Option<Option<PaymentMethodOptionsBoletoSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsBoleto { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsBoleto>, + builder: PaymentMethodOptionsBoletoBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsBoleto> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsBoletoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsBoletoBuilder { + type Out = PaymentMethodOptionsBoleto; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after_days" => Deserialize::begin(&mut self.expires_after_days), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_days: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after_days = self.expires_after_days.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { expires_after_days, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsBoleto { + type Builder = PaymentMethodOptionsBoletoBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsBoleto { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsBoletoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after_days" => b.expires_after_days = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -70,8 +161,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBoletoSetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsBoletoSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsBoletoSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsBoletoSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsBoletoSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsBoletoSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBoletoSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_card_installments.rs b/generated/stripe_shared/src/payment_method_options_card_installments.rs index 067cea0d8..e15680956 100644 --- a/generated/stripe_shared/src/payment_method_options_card_installments.rs +++ b/generated/stripe_shared/src/payment_method_options_card_installments.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsCardInstallments { /// Installment plans that may be selected for this PaymentIntent. pub available_plans: Option<Vec<stripe_shared::PaymentMethodDetailsCardInstallmentsPlan>>, @@ -7,3 +9,97 @@ pub struct PaymentMethodOptionsCardInstallments { /// Installment plan selected for this PaymentIntent. pub plan: Option<stripe_shared::PaymentMethodDetailsCardInstallmentsPlan>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsCardInstallmentsBuilder { + available_plans: Option<Option<Vec<stripe_shared::PaymentMethodDetailsCardInstallmentsPlan>>>, + enabled: Option<bool>, + plan: Option<Option<stripe_shared::PaymentMethodDetailsCardInstallmentsPlan>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsCardInstallments { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsCardInstallments>, + builder: PaymentMethodOptionsCardInstallmentsBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsCardInstallments> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsCardInstallmentsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsCardInstallmentsBuilder { + type Out = PaymentMethodOptionsCardInstallments; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available_plans" => Deserialize::begin(&mut self.available_plans), + "enabled" => Deserialize::begin(&mut self.enabled), + "plan" => Deserialize::begin(&mut self.plan), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available_plans: Deserialize::default(), enabled: Deserialize::default(), plan: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available_plans = self.available_plans.take()?; + let enabled = self.enabled.take()?; + let plan = self.plan.take()?; + + Some(Self::Out { available_plans, enabled, plan }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsCardInstallments { + type Builder = PaymentMethodOptionsCardInstallmentsBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsCardInstallments { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsCardInstallmentsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available_plans" => b.available_plans = Some(FromValueOpt::from_value(v)?), + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "plan" => b.plan = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_options_card_mandate_options.rs b/generated/stripe_shared/src/payment_method_options_card_mandate_options.rs index b6c34f699..350ad9506 100644 --- a/generated/stripe_shared/src/payment_method_options_card_mandate_options.rs +++ b/generated/stripe_shared/src/payment_method_options_card_mandate_options.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsCardMandateOptions { /// Amount to be charged for future payments. pub amount: i64, @@ -26,6 +28,134 @@ pub struct PaymentMethodOptionsCardMandateOptions { /// Specifies the type of mandates supported. Possible values are `india`. pub supported_types: Option<Vec<PaymentMethodOptionsCardMandateOptionsSupportedTypes>>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsCardMandateOptionsBuilder { + amount: Option<i64>, + amount_type: Option<PaymentMethodOptionsCardMandateOptionsAmountType>, + description: Option<Option<String>>, + end_date: Option<Option<stripe_types::Timestamp>>, + interval: Option<PaymentMethodOptionsCardMandateOptionsInterval>, + interval_count: Option<Option<u64>>, + reference: Option<String>, + start_date: Option<stripe_types::Timestamp>, + supported_types: Option<Option<Vec<PaymentMethodOptionsCardMandateOptionsSupportedTypes>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsCardMandateOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsCardMandateOptions>, + builder: PaymentMethodOptionsCardMandateOptionsBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsCardMandateOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsCardMandateOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsCardMandateOptionsBuilder { + type Out = PaymentMethodOptionsCardMandateOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_type" => Deserialize::begin(&mut self.amount_type), + "description" => Deserialize::begin(&mut self.description), + "end_date" => Deserialize::begin(&mut self.end_date), + "interval" => Deserialize::begin(&mut self.interval), + "interval_count" => Deserialize::begin(&mut self.interval_count), + "reference" => Deserialize::begin(&mut self.reference), + "start_date" => Deserialize::begin(&mut self.start_date), + "supported_types" => Deserialize::begin(&mut self.supported_types), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_type: Deserialize::default(), + description: Deserialize::default(), + end_date: Deserialize::default(), + interval: Deserialize::default(), + interval_count: Deserialize::default(), + reference: Deserialize::default(), + start_date: Deserialize::default(), + supported_types: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_type = self.amount_type.take()?; + let description = self.description.take()?; + let end_date = self.end_date.take()?; + let interval = self.interval.take()?; + let interval_count = self.interval_count.take()?; + let reference = self.reference.take()?; + let start_date = self.start_date.take()?; + let supported_types = self.supported_types.take()?; + + Some(Self::Out { amount, amount_type, description, end_date, interval, interval_count, reference, start_date, supported_types }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsCardMandateOptions { + type Builder = PaymentMethodOptionsCardMandateOptionsBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsCardMandateOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsCardMandateOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_type" => b.amount_type = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "end_date" => b.end_date = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "interval_count" => b.interval_count = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "start_date" => b.start_date = Some(FromValueOpt::from_value(v)?), + "supported_types" => b.supported_types = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// One of `fixed` or `maximum`. /// If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. /// If `maximum`, the amount charged can be up to the value passed for the `amount` param. @@ -78,13 +208,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCardMandateOptionsAmou fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCardMandateOptionsAmountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCardMandateOptionsAmountType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCardMandateOptionsAmountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCardMandateOptionsAmountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCardMandateOptionsAmountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCardMandateOptionsAmountType); /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsCardMandateOptionsInterval { @@ -144,13 +288,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCardMandateOptionsInte fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCardMandateOptionsInterval", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCardMandateOptionsInterval")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCardMandateOptionsInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCardMandateOptionsInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCardMandateOptionsInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCardMandateOptionsInterval); /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -198,10 +356,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCardMandateOptionsSupp fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCardMandateOptionsSupportedTypes", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCardMandateOptionsSupportedTypes")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCardMandateOptionsSupportedTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCardMandateOptionsSupportedTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCardMandateOptionsSupportedTypes::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCardMandateOptionsSupportedTypes); diff --git a/generated/stripe_shared/src/payment_method_options_card_present.rs b/generated/stripe_shared/src/payment_method_options_card_present.rs index 3353636b5..126397b1a 100644 --- a/generated/stripe_shared/src/payment_method_options_card_present.rs +++ b/generated/stripe_shared/src/payment_method_options_card_present.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsCardPresent { /// Request ability to capture this payment beyond the standard [authorization validity window](https://stripe.com/docs/terminal/features/extended-authorizations#authorization-validity). pub request_extended_authorization: Option<bool>, @@ -6,3 +8,93 @@ pub struct PaymentMethodOptionsCardPresent { /// Check [incremental_authorization_supported](https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-card_present-incremental_authorization_supported) in the [Confirm](https://stripe.com/docs/api/payment_intents/confirm) response to verify support. pub request_incremental_authorization_support: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsCardPresentBuilder { + request_extended_authorization: Option<Option<bool>>, + request_incremental_authorization_support: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsCardPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsCardPresent>, + builder: PaymentMethodOptionsCardPresentBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsCardPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsCardPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsCardPresentBuilder { + type Out = PaymentMethodOptionsCardPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "request_extended_authorization" => Deserialize::begin(&mut self.request_extended_authorization), + "request_incremental_authorization_support" => Deserialize::begin(&mut self.request_incremental_authorization_support), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { request_extended_authorization: Deserialize::default(), request_incremental_authorization_support: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let request_extended_authorization = self.request_extended_authorization.take()?; + let request_incremental_authorization_support = self.request_incremental_authorization_support.take()?; + + Some(Self::Out { request_extended_authorization, request_incremental_authorization_support }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsCardPresent { + type Builder = PaymentMethodOptionsCardPresentBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsCardPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsCardPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "request_extended_authorization" => b.request_extended_authorization = Some(FromValueOpt::from_value(v)?), + "request_incremental_authorization_support" => b.request_incremental_authorization_support = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_options_cashapp.rs b/generated/stripe_shared/src/payment_method_options_cashapp.rs index 09a6b462d..c17b98d40 100644 --- a/generated/stripe_shared/src/payment_method_options_cashapp.rs +++ b/generated/stripe_shared/src/payment_method_options_cashapp.rs @@ -1,7 +1,8 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsCashapp { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<PaymentMethodOptionsCashappCaptureMethod>, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -9,9 +10,98 @@ pub struct PaymentMethodOptionsCashapp { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsCashappSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsCashappBuilder { + capture_method: Option<Option<PaymentMethodOptionsCashappCaptureMethod>>, + setup_future_usage: Option<Option<PaymentMethodOptionsCashappSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsCashapp { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsCashapp>, + builder: PaymentMethodOptionsCashappBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsCashapp> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsCashappBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsCashappBuilder { + type Out = PaymentMethodOptionsCashapp; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { capture_method: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { capture_method, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsCashapp { + type Builder = PaymentMethodOptionsCashappBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsCashapp { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsCashappBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsCashappCaptureMethod { @@ -59,11 +149,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCashappCaptureMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsCashappCaptureMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCashappCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCashappCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCashappCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCashappCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCashappCaptureMethod); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -122,10 +228,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCashappSetupFutureUsag fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCashappSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCashappSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCashappSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCashappSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCashappSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCashappSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_customer_balance.rs b/generated/stripe_shared/src/payment_method_options_customer_balance.rs index c21b5e5e7..2c40b6707 100644 --- a/generated/stripe_shared/src/payment_method_options_customer_balance.rs +++ b/generated/stripe_shared/src/payment_method_options_customer_balance.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsCustomerBalance { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_transfer: Option<stripe_shared::PaymentMethodOptionsCustomerBalanceBankTransfer>, /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. @@ -11,9 +12,102 @@ pub struct PaymentMethodOptionsCustomerBalance { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsCustomerBalanceSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsCustomerBalanceBuilder { + bank_transfer: Option<Option<stripe_shared::PaymentMethodOptionsCustomerBalanceBankTransfer>>, + funding_type: Option<Option<PaymentMethodOptionsCustomerBalanceFundingType>>, + setup_future_usage: Option<Option<PaymentMethodOptionsCustomerBalanceSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsCustomerBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsCustomerBalance>, + builder: PaymentMethodOptionsCustomerBalanceBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsCustomerBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsCustomerBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsCustomerBalanceBuilder { + type Out = PaymentMethodOptionsCustomerBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_transfer" => Deserialize::begin(&mut self.bank_transfer), + "funding_type" => Deserialize::begin(&mut self.funding_type), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transfer: Deserialize::default(), funding_type: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_transfer = self.bank_transfer.take()?; + let funding_type = self.funding_type.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { bank_transfer, funding_type, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsCustomerBalance { + type Builder = PaymentMethodOptionsCustomerBalanceBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsCustomerBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsCustomerBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_transfer" => b.bank_transfer = Some(FromValueOpt::from_value(v)?), + "funding_type" => b.funding_type = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The funding method type to be used when there are not enough funds in the customer balance. /// Permitted values include: `bank_transfer`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -62,13 +156,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceFunding fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCustomerBalanceFundingType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCustomerBalanceFundingType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceFundingType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCustomerBalanceFundingType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCustomerBalanceFundingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceFundingType); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -121,10 +229,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceSetupFu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCustomerBalanceSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCustomerBalanceSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCustomerBalanceSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCustomerBalanceSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_customer_balance_bank_transfer.rs b/generated/stripe_shared/src/payment_method_options_customer_balance_bank_transfer.rs index 1ddd80ee7..ad75f37dd 100644 --- a/generated/stripe_shared/src/payment_method_options_customer_balance_bank_transfer.rs +++ b/generated/stripe_shared/src/payment_method_options_customer_balance_bank_transfer.rs @@ -1,18 +1,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsCustomerBalanceBankTransfer { - #[serde(skip_serializing_if = "Option::is_none")] pub eu_bank_transfer: Option<stripe_shared::PaymentMethodOptionsCustomerBalanceEuBankAccount>, /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. - #[serde(skip_serializing_if = "Option::is_none")] - pub requested_address_types: - Option<Vec<PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes>>, + pub requested_address_types: Option<Vec<PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes>>, /// The bank transfer type that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<PaymentMethodOptionsCustomerBalanceBankTransferType>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsCustomerBalanceBankTransferBuilder { + eu_bank_transfer: Option<Option<stripe_shared::PaymentMethodOptionsCustomerBalanceEuBankAccount>>, + requested_address_types: Option<Option<Vec<PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes>>>, + type_: Option<Option<PaymentMethodOptionsCustomerBalanceBankTransferType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsCustomerBalanceBankTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsCustomerBalanceBankTransfer>, + builder: PaymentMethodOptionsCustomerBalanceBankTransferBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsCustomerBalanceBankTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsCustomerBalanceBankTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsCustomerBalanceBankTransferBuilder { + type Out = PaymentMethodOptionsCustomerBalanceBankTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "eu_bank_transfer" => Deserialize::begin(&mut self.eu_bank_transfer), + "requested_address_types" => Deserialize::begin(&mut self.requested_address_types), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eu_bank_transfer: Deserialize::default(), requested_address_types: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let eu_bank_transfer = self.eu_bank_transfer.take()?; + let requested_address_types = self.requested_address_types.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { eu_bank_transfer, requested_address_types, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsCustomerBalanceBankTransfer { + type Builder = PaymentMethodOptionsCustomerBalanceBankTransferBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsCustomerBalanceBankTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsCustomerBalanceBankTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "eu_bank_transfer" => b.eu_bank_transfer = Some(FromValueOpt::from_value(v)?), + "requested_address_types" => b.requested_address_types = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// List of address types that should be returned in the financial_addresses response. /// If not specified, all valid types will be returned. /// @@ -77,15 +170,31 @@ impl serde::Serialize for PaymentMethodOptionsCustomerBalanceBankTransferRequest serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes -{ +impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes); /// The bank transfer type that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, `mx_bank_transfer`, or `us_bank_transfer`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsCustomerBalanceBankTransferType { @@ -145,10 +254,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceBankTra fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCustomerBalanceBankTransferType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCustomerBalanceBankTransferType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceBankTransferType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCustomerBalanceBankTransferType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCustomerBalanceBankTransferType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceBankTransferType); diff --git a/generated/stripe_shared/src/payment_method_options_customer_balance_eu_bank_account.rs b/generated/stripe_shared/src/payment_method_options_customer_balance_eu_bank_account.rs index 65c8f3252..98865f074 100644 --- a/generated/stripe_shared/src/payment_method_options_customer_balance_eu_bank_account.rs +++ b/generated/stripe_shared/src/payment_method_options_customer_balance_eu_bank_account.rs @@ -1,9 +1,97 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsCustomerBalanceEuBankAccount { /// The desired country code of the bank account information. /// Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`. pub country: PaymentMethodOptionsCustomerBalanceEuBankAccountCountry, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder { + country: Option<PaymentMethodOptionsCustomerBalanceEuBankAccountCountry>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsCustomerBalanceEuBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsCustomerBalanceEuBankAccount>, + builder: PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsCustomerBalanceEuBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder { + type Out = PaymentMethodOptionsCustomerBalanceEuBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + + Some(Self::Out { country }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsCustomerBalanceEuBankAccount { + type Builder = PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsCustomerBalanceEuBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The desired country code of the bank account information. /// Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -67,10 +155,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceEuBankA fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsCustomerBalanceEuBankAccountCountry> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsCustomerBalanceEuBankAccountCountry::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceEuBankAccountCountry); diff --git a/generated/stripe_shared/src/payment_method_options_fpx.rs b/generated/stripe_shared/src/payment_method_options_fpx.rs index 785d95521..34a1acb9a 100644 --- a/generated/stripe_shared/src/payment_method_options_fpx.rs +++ b/generated/stripe_shared/src/payment_method_options_fpx.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsFpx { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsFpx { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsFpxSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsFpxBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsFpxSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsFpx { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsFpx>, + builder: PaymentMethodOptionsFpxBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsFpx> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsFpxBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsFpxBuilder { + type Out = PaymentMethodOptionsFpx; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsFpx { + type Builder = PaymentMethodOptionsFpxBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsFpx { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsFpxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,8 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsFpxSetupFutureUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsFpxSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsFpxSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsFpxSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsFpxSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsFpxSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsFpxSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_giropay.rs b/generated/stripe_shared/src/payment_method_options_giropay.rs index 27b1695f9..b388fe508 100644 --- a/generated/stripe_shared/src/payment_method_options_giropay.rs +++ b/generated/stripe_shared/src/payment_method_options_giropay.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsGiropay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsGiropay { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsGiropaySetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsGiropayBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsGiropaySetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsGiropay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsGiropay>, + builder: PaymentMethodOptionsGiropayBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsGiropay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsGiropayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsGiropayBuilder { + type Out = PaymentMethodOptionsGiropay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsGiropay { + type Builder = PaymentMethodOptionsGiropayBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsGiropay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsGiropayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsGiropaySetupFutureUsag fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsGiropaySetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsGiropaySetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsGiropaySetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsGiropaySetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsGiropaySetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsGiropaySetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_grabpay.rs b/generated/stripe_shared/src/payment_method_options_grabpay.rs index 9254d1f9d..6d9d6fe2a 100644 --- a/generated/stripe_shared/src/payment_method_options_grabpay.rs +++ b/generated/stripe_shared/src/payment_method_options_grabpay.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsGrabpay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsGrabpay { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsGrabpaySetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsGrabpayBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsGrabpaySetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsGrabpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsGrabpay>, + builder: PaymentMethodOptionsGrabpayBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsGrabpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsGrabpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsGrabpayBuilder { + type Out = PaymentMethodOptionsGrabpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsGrabpay { + type Builder = PaymentMethodOptionsGrabpayBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsGrabpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsGrabpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsGrabpaySetupFutureUsag fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsGrabpaySetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsGrabpaySetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsGrabpaySetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsGrabpaySetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsGrabpaySetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsGrabpaySetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_ideal.rs b/generated/stripe_shared/src/payment_method_options_ideal.rs index 7be10d3a4..c3938b95e 100644 --- a/generated/stripe_shared/src/payment_method_options_ideal.rs +++ b/generated/stripe_shared/src/payment_method_options_ideal.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsIdeal { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsIdeal { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsIdealSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsIdealBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsIdealSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsIdeal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsIdeal>, + builder: PaymentMethodOptionsIdealBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsIdeal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsIdealBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsIdealBuilder { + type Out = PaymentMethodOptionsIdeal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsIdeal { + type Builder = PaymentMethodOptionsIdealBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsIdeal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsIdealBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -64,8 +151,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsIdealSetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsIdealSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsIdealSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsIdealSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsIdealSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsIdealSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsIdealSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_interac_present.rs b/generated/stripe_shared/src/payment_method_options_interac_present.rs index 702a90947..4e6cc20fd 100644 --- a/generated/stripe_shared/src/payment_method_options_interac_present.rs +++ b/generated/stripe_shared/src/payment_method_options_interac_present.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsInteracPresent {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsInteracPresentBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsInteracPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsInteracPresent>, + builder: PaymentMethodOptionsInteracPresentBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsInteracPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsInteracPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsInteracPresentBuilder { + type Out = PaymentMethodOptionsInteracPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsInteracPresent { + type Builder = PaymentMethodOptionsInteracPresentBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsInteracPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsInteracPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_options_klarna.rs b/generated/stripe_shared/src/payment_method_options_klarna.rs index 38cc09e99..320eebee7 100644 --- a/generated/stripe_shared/src/payment_method_options_klarna.rs +++ b/generated/stripe_shared/src/payment_method_options_klarna.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsKlarna { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<PaymentMethodOptionsKlarnaCaptureMethod>, /// Preferred locale of the Klarna checkout page that the customer is redirected to. pub preferred_locale: Option<String>, @@ -11,9 +12,102 @@ pub struct PaymentMethodOptionsKlarna { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsKlarnaSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsKlarnaBuilder { + capture_method: Option<Option<PaymentMethodOptionsKlarnaCaptureMethod>>, + preferred_locale: Option<Option<String>>, + setup_future_usage: Option<Option<PaymentMethodOptionsKlarnaSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsKlarna { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsKlarna>, + builder: PaymentMethodOptionsKlarnaBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsKlarna> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsKlarnaBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsKlarnaBuilder { + type Out = PaymentMethodOptionsKlarna; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "preferred_locale" => Deserialize::begin(&mut self.preferred_locale), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { capture_method: Deserialize::default(), preferred_locale: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let preferred_locale = self.preferred_locale.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { capture_method, preferred_locale, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsKlarna { + type Builder = PaymentMethodOptionsKlarnaBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsKlarna { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsKlarnaBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "preferred_locale" => b.preferred_locale = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsKlarnaCaptureMethod { @@ -61,11 +155,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKlarnaCaptureMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsKlarnaCaptureMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsKlarnaCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsKlarnaCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsKlarnaCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsKlarnaCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKlarnaCaptureMethod); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -118,8 +228,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKlarnaSetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsKlarnaSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsKlarnaSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsKlarnaSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsKlarnaSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsKlarnaSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKlarnaSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_konbini.rs b/generated/stripe_shared/src/payment_method_options_konbini.rs index 7efd4c2f4..ab8f599ec 100644 --- a/generated/stripe_shared/src/payment_method_options_konbini.rs +++ b/generated/stripe_shared/src/payment_method_options_konbini.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsKonbini { /// An optional 10 to 11 digit numeric-only string determining the confirmation code at applicable convenience stores. pub confirmation_number: Option<String>, @@ -16,9 +18,116 @@ pub struct PaymentMethodOptionsKonbini { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsKonbiniSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsKonbiniBuilder { + confirmation_number: Option<Option<String>>, + expires_after_days: Option<Option<u32>>, + expires_at: Option<Option<stripe_types::Timestamp>>, + product_description: Option<Option<String>>, + setup_future_usage: Option<Option<PaymentMethodOptionsKonbiniSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsKonbini { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsKonbini>, + builder: PaymentMethodOptionsKonbiniBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsKonbini> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsKonbiniBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsKonbiniBuilder { + type Out = PaymentMethodOptionsKonbini; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "confirmation_number" => Deserialize::begin(&mut self.confirmation_number), + "expires_after_days" => Deserialize::begin(&mut self.expires_after_days), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "product_description" => Deserialize::begin(&mut self.product_description), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + confirmation_number: Deserialize::default(), + expires_after_days: Deserialize::default(), + expires_at: Deserialize::default(), + product_description: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let confirmation_number = self.confirmation_number.take()?; + let expires_after_days = self.expires_after_days.take()?; + let expires_at = self.expires_at.take()?; + let product_description = self.product_description.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { confirmation_number, expires_after_days, expires_at, product_description, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsKonbini { + type Builder = PaymentMethodOptionsKonbiniBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsKonbini { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsKonbiniBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "confirmation_number" => b.confirmation_number = Some(FromValueOpt::from_value(v)?), + "expires_after_days" => b.expires_after_days = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "product_description" => b.product_description = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -71,10 +180,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKonbiniSetupFutureUsag fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsKonbiniSetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsKonbiniSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsKonbiniSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsKonbiniSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsKonbiniSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKonbiniSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_oxxo.rs b/generated/stripe_shared/src/payment_method_options_oxxo.rs index a1867c77e..a5f60e941 100644 --- a/generated/stripe_shared/src/payment_method_options_oxxo.rs +++ b/generated/stripe_shared/src/payment_method_options_oxxo.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsOxxo { /// The number of calendar days before an OXXO invoice expires. /// For example, if you create an OXXO invoice on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time. @@ -9,9 +11,98 @@ pub struct PaymentMethodOptionsOxxo { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsOxxoSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsOxxoBuilder { + expires_after_days: Option<u32>, + setup_future_usage: Option<Option<PaymentMethodOptionsOxxoSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsOxxo { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsOxxo>, + builder: PaymentMethodOptionsOxxoBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsOxxo> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsOxxoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsOxxoBuilder { + type Out = PaymentMethodOptionsOxxo; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after_days" => Deserialize::begin(&mut self.expires_after_days), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_days: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after_days = self.expires_after_days.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { expires_after_days, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsOxxo { + type Builder = PaymentMethodOptionsOxxoBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsOxxo { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsOxxoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after_days" => b.expires_after_days = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -64,8 +155,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsOxxoSetupFutureUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsOxxoSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsOxxoSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsOxxoSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsOxxoSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsOxxoSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsOxxoSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_p24.rs b/generated/stripe_shared/src/payment_method_options_p24.rs index 3ba6d5541..c6b04dab1 100644 --- a/generated/stripe_shared/src/payment_method_options_p24.rs +++ b/generated/stripe_shared/src/payment_method_options_p24.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsP24 { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsP24 { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsP24SetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsP24Builder { + setup_future_usage: Option<Option<PaymentMethodOptionsP24SetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsP24 { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsP24>, + builder: PaymentMethodOptionsP24Builder, + } + + impl Visitor for Place<PaymentMethodOptionsP24> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsP24Builder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsP24Builder { + type Out = PaymentMethodOptionsP24; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsP24 { + type Builder = PaymentMethodOptionsP24Builder; + } + + impl FromValueOpt for PaymentMethodOptionsP24 { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsP24Builder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,8 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsP24SetupFutureUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsP24SetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsP24SetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsP24SetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsP24SetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsP24SetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsP24SetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_paynow.rs b/generated/stripe_shared/src/payment_method_options_paynow.rs index 654aa47da..96fea0f09 100644 --- a/generated/stripe_shared/src/payment_method_options_paynow.rs +++ b/generated/stripe_shared/src/payment_method_options_paynow.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsPaynow { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsPaynow { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsPaynowSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsPaynowBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsPaynowSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsPaynow { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsPaynow>, + builder: PaymentMethodOptionsPaynowBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsPaynow> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsPaynowBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsPaynowBuilder { + type Out = PaymentMethodOptionsPaynow; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsPaynow { + type Builder = PaymentMethodOptionsPaynowBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsPaynow { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsPaynowBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,8 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaynowSetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaynowSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaynowSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsPaynowSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsPaynowSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsPaynowSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaynowSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_paypal.rs b/generated/stripe_shared/src/payment_method_options_paypal.rs index 241d948c6..ff442eed6 100644 --- a/generated/stripe_shared/src/payment_method_options_paypal.rs +++ b/generated/stripe_shared/src/payment_method_options_paypal.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsPaypal { /// Controls when the funds will be captured from the customer's account. - #[serde(skip_serializing_if = "Option::is_none")] pub capture_method: Option<PaymentMethodOptionsPaypalCaptureMethod>, /// Preferred locale of the PayPal checkout page that the customer is redirected to. pub preferred_locale: Option<String>, @@ -14,9 +15,106 @@ pub struct PaymentMethodOptionsPaypal { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsPaypalSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsPaypalBuilder { + capture_method: Option<Option<PaymentMethodOptionsPaypalCaptureMethod>>, + preferred_locale: Option<Option<String>>, + reference: Option<Option<String>>, + setup_future_usage: Option<Option<PaymentMethodOptionsPaypalSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsPaypal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsPaypal>, + builder: PaymentMethodOptionsPaypalBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsPaypal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsPaypalBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsPaypalBuilder { + type Out = PaymentMethodOptionsPaypal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_method" => Deserialize::begin(&mut self.capture_method), + "preferred_locale" => Deserialize::begin(&mut self.preferred_locale), + "reference" => Deserialize::begin(&mut self.reference), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { capture_method: Deserialize::default(), preferred_locale: Deserialize::default(), reference: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let capture_method = self.capture_method.take()?; + let preferred_locale = self.preferred_locale.take()?; + let reference = self.reference.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { capture_method, preferred_locale, reference, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsPaypal { + type Builder = PaymentMethodOptionsPaypalBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsPaypal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsPaypalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_method" => b.capture_method = Some(FromValueOpt::from_value(v)?), + "preferred_locale" => b.preferred_locale = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Controls when the funds will be captured from the customer's account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsPaypalCaptureMethod { @@ -64,11 +162,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalCaptureMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalCaptureMethod") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalCaptureMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsPaypalCaptureMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsPaypalCaptureMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsPaypalCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalCaptureMethod); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -124,8 +238,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalSetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsPaypalSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsPaypalSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsPaypalSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsPaypalSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_pix.rs b/generated/stripe_shared/src/payment_method_options_pix.rs index 6f79294d5..6b0d6016b 100644 --- a/generated/stripe_shared/src/payment_method_options_pix.rs +++ b/generated/stripe_shared/src/payment_method_options_pix.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsPix { /// The number of seconds (between 10 and 1209600) after which Pix payment will expire. pub expires_after_seconds: Option<i64>, @@ -10,9 +12,102 @@ pub struct PaymentMethodOptionsPix { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsPixSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsPixBuilder { + expires_after_seconds: Option<Option<i64>>, + expires_at: Option<Option<i64>>, + setup_future_usage: Option<Option<PaymentMethodOptionsPixSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsPix { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsPix>, + builder: PaymentMethodOptionsPixBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsPix> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsPixBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsPixBuilder { + type Out = PaymentMethodOptionsPix; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "expires_after_seconds" => Deserialize::begin(&mut self.expires_after_seconds), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_seconds: Deserialize::default(), expires_at: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let expires_after_seconds = self.expires_after_seconds.take()?; + let expires_at = self.expires_at.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { expires_after_seconds, expires_at, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsPix { + type Builder = PaymentMethodOptionsPixBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsPix { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsPixBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "expires_after_seconds" => b.expires_after_seconds = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -65,8 +160,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPixSetupFutureUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsPixSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsPixSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsPixSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsPixSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsPixSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPixSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_promptpay.rs b/generated/stripe_shared/src/payment_method_options_promptpay.rs index a09bb6f57..42a2b7b81 100644 --- a/generated/stripe_shared/src/payment_method_options_promptpay.rs +++ b/generated/stripe_shared/src/payment_method_options_promptpay.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsPromptpay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsPromptpay { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsPromptpaySetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsPromptpayBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsPromptpaySetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsPromptpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsPromptpay>, + builder: PaymentMethodOptionsPromptpayBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsPromptpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsPromptpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsPromptpayBuilder { + type Out = PaymentMethodOptionsPromptpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsPromptpay { + type Builder = PaymentMethodOptionsPromptpayBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsPromptpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsPromptpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,10 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPromptpaySetupFutureUs fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsPromptpaySetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsPromptpaySetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsPromptpaySetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsPromptpaySetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsPromptpaySetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPromptpaySetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_revolut_pay.rs b/generated/stripe_shared/src/payment_method_options_revolut_pay.rs index 75f50f7a6..95f875ec2 100644 --- a/generated/stripe_shared/src/payment_method_options_revolut_pay.rs +++ b/generated/stripe_shared/src/payment_method_options_revolut_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsRevolutPay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsRevolutPayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsRevolutPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsRevolutPay>, + builder: PaymentMethodOptionsRevolutPayBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsRevolutPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsRevolutPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsRevolutPayBuilder { + type Out = PaymentMethodOptionsRevolutPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsRevolutPay { + type Builder = PaymentMethodOptionsRevolutPayBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsRevolutPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsRevolutPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_options_sofort.rs b/generated/stripe_shared/src/payment_method_options_sofort.rs index cfdc26e2d..dedc31873 100644 --- a/generated/stripe_shared/src/payment_method_options_sofort.rs +++ b/generated/stripe_shared/src/payment_method_options_sofort.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsSofort { /// Preferred language of the SOFORT authorization page that the customer is redirected to. pub preferred_language: Option<PaymentMethodOptionsSofortPreferredLanguage>, @@ -8,9 +10,98 @@ pub struct PaymentMethodOptionsSofort { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsSofortSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsSofortBuilder { + preferred_language: Option<Option<PaymentMethodOptionsSofortPreferredLanguage>>, + setup_future_usage: Option<Option<PaymentMethodOptionsSofortSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsSofort { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsSofort>, + builder: PaymentMethodOptionsSofortBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsSofort> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsSofortBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsSofortBuilder { + type Out = PaymentMethodOptionsSofort; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { preferred_language: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let preferred_language = self.preferred_language.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { preferred_language, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsSofort { + type Builder = PaymentMethodOptionsSofortBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsSofort { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsSofortBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred language of the SOFORT authorization page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsSofortPreferredLanguage { @@ -76,13 +167,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsSofortPreferredLanguag fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsSofortPreferredLanguage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsSofortPreferredLanguage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsSofortPreferredLanguage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsSofortPreferredLanguage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsSofortPreferredLanguage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsSofortPreferredLanguage); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -138,8 +243,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsSofortSetupFutureUsage fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsSofortSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsSofortSetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsSofortSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsSofortSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsSofortSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsSofortSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_us_bank_account_mandate_options.rs b/generated/stripe_shared/src/payment_method_options_us_bank_account_mandate_options.rs deleted file mode 100644 index f7b0781c8..000000000 --- a/generated/stripe_shared/src/payment_method_options_us_bank_account_mandate_options.rs +++ /dev/null @@ -1,62 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct PaymentMethodOptionsUsBankAccountMandateOptions { - /// Mandate collection method - #[serde(skip_serializing_if = "Option::is_none")] - pub collection_method: Option<PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod>, -} -/// Mandate collection method -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - Paper, -} -impl PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - pub fn as_str(self) -> &'static str { - use PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match self { - Paper => "paper", - } - } -} - -impl std::str::FromStr for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::*; - match s { - "paper" => Ok(Paper), - _ => Err(()), - } - } -} -impl std::fmt::Display for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> - for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod -{ - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod", - ) - }) - } -} diff --git a/generated/stripe_shared/src/payment_method_options_wechat_pay.rs b/generated/stripe_shared/src/payment_method_options_wechat_pay.rs index 6824715de..7b0db4642 100644 --- a/generated/stripe_shared/src/payment_method_options_wechat_pay.rs +++ b/generated/stripe_shared/src/payment_method_options_wechat_pay.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsWechatPay { /// The app ID registered with WeChat Pay. Only required when client is ios or android. pub app_id: Option<String>, @@ -10,9 +12,102 @@ pub struct PaymentMethodOptionsWechatPay { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsWechatPaySetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsWechatPayBuilder { + app_id: Option<Option<String>>, + client: Option<Option<PaymentMethodOptionsWechatPayClient>>, + setup_future_usage: Option<Option<PaymentMethodOptionsWechatPaySetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsWechatPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsWechatPay>, + builder: PaymentMethodOptionsWechatPayBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsWechatPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsWechatPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsWechatPayBuilder { + type Out = PaymentMethodOptionsWechatPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "app_id" => Deserialize::begin(&mut self.app_id), + "client" => Deserialize::begin(&mut self.client), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { app_id: Deserialize::default(), client: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let app_id = self.app_id.take()?; + let client = self.client.take()?; + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { app_id, client, setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsWechatPay { + type Builder = PaymentMethodOptionsWechatPayBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsWechatPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsWechatPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "app_id" => b.app_id = Some(FromValueOpt::from_value(v)?), + "client" => b.client = Some(FromValueOpt::from_value(v)?), + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The client type that the end customer will pay from #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsWechatPayClient { @@ -66,11 +161,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsWechatPayClient { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsWechatPayClient") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsWechatPayClient")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsWechatPayClient { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsWechatPayClient> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsWechatPayClient::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsWechatPayClient); /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -123,10 +234,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsWechatPaySetupFutureUs fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodOptionsWechatPaySetupFutureUsage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsWechatPaySetupFutureUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsWechatPaySetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsWechatPaySetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsWechatPaySetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsWechatPaySetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_options_zip.rs b/generated/stripe_shared/src/payment_method_options_zip.rs index 6a09ea1f5..ad14450c1 100644 --- a/generated/stripe_shared/src/payment_method_options_zip.rs +++ b/generated/stripe_shared/src/payment_method_options_zip.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOptionsZip { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,94 @@ pub struct PaymentMethodOptionsZip { /// If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. /// /// When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - #[serde(skip_serializing_if = "Option::is_none")] pub setup_future_usage: Option<PaymentMethodOptionsZipSetupFutureUsage>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOptionsZipBuilder { + setup_future_usage: Option<Option<PaymentMethodOptionsZipSetupFutureUsage>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsZip { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOptionsZip>, + builder: PaymentMethodOptionsZipBuilder, + } + + impl Visitor for Place<PaymentMethodOptionsZip> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOptionsZipBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOptionsZipBuilder { + type Out = PaymentMethodOptionsZip; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let setup_future_usage = self.setup_future_usage.take()?; + + Some(Self::Out { setup_future_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOptionsZip { + type Builder = PaymentMethodOptionsZipBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsZip { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsZipBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "setup_future_usage" => b.setup_future_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// /// Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. @@ -61,8 +148,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsZipSetupFutureUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodOptionsZipSetupFutureUsage") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodOptionsZipSetupFutureUsage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodOptionsZipSetupFutureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodOptionsZipSetupFutureUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodOptionsZipSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsZipSetupFutureUsage); diff --git a/generated/stripe_shared/src/payment_method_oxxo.rs b/generated/stripe_shared/src/payment_method_oxxo.rs index 5680d3a17..b09f327a2 100644 --- a/generated/stripe_shared/src/payment_method_oxxo.rs +++ b/generated/stripe_shared/src/payment_method_oxxo.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodOxxo {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodOxxoBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOxxo { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodOxxo>, + builder: PaymentMethodOxxoBuilder, + } + + impl Visitor for Place<PaymentMethodOxxo> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodOxxoBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodOxxoBuilder { + type Out = PaymentMethodOxxo; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodOxxo { + type Builder = PaymentMethodOxxoBuilder; + } + + impl FromValueOpt for PaymentMethodOxxo { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOxxoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_p24.rs b/generated/stripe_shared/src/payment_method_p24.rs index 733b760de..04c36137a 100644 --- a/generated/stripe_shared/src/payment_method_p24.rs +++ b/generated/stripe_shared/src/payment_method_p24.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodP24 { /// The customer's bank, if provided. pub bank: Option<PaymentMethodP24Bank>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodP24Builder { + bank: Option<Option<PaymentMethodP24Bank>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodP24 { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodP24>, + builder: PaymentMethodP24Builder, + } + + impl Visitor for Place<PaymentMethodP24> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodP24Builder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodP24Builder { + type Out = PaymentMethodP24; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + + Some(Self::Out { bank }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodP24 { + type Builder = PaymentMethodP24Builder; + } + + impl FromValueOpt for PaymentMethodP24 { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodP24Builder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer's bank, if provided. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -31,7 +119,6 @@ pub enum PaymentMethodP24Bank { SantanderPrzelew24, TmobileUsbugiBankowe, ToyotaBank, - Velobank, VolkswagenBank, /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, @@ -64,7 +151,6 @@ impl PaymentMethodP24Bank { SantanderPrzelew24 => "santander_przelew24", TmobileUsbugiBankowe => "tmobile_usbugi_bankowe", ToyotaBank => "toyota_bank", - Velobank => "velobank", VolkswagenBank => "volkswagen_bank", Unknown => "unknown", } @@ -100,7 +186,6 @@ impl std::str::FromStr for PaymentMethodP24Bank { "santander_przelew24" => Ok(SantanderPrzelew24), "tmobile_usbugi_bankowe" => Ok(TmobileUsbugiBankowe), "toyota_bank" => Ok(ToyotaBank), - "velobank" => Ok(Velobank), "volkswagen_bank" => Ok(VolkswagenBank), _ => Err(()), } @@ -129,6 +214,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodP24Bank { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(PaymentMethodP24Bank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodP24Bank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodP24Bank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodP24Bank::from_str(s).unwrap_or(PaymentMethodP24Bank::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodP24Bank); diff --git a/generated/stripe_shared/src/payment_method_paynow.rs b/generated/stripe_shared/src/payment_method_paynow.rs index e48602eee..22004347b 100644 --- a/generated/stripe_shared/src/payment_method_paynow.rs +++ b/generated/stripe_shared/src/payment_method_paynow.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodPaynow {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodPaynowBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodPaynow { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodPaynow>, + builder: PaymentMethodPaynowBuilder, + } + + impl Visitor for Place<PaymentMethodPaynow> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodPaynowBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodPaynowBuilder { + type Out = PaymentMethodPaynow; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodPaynow { + type Builder = PaymentMethodPaynowBuilder; + } + + impl FromValueOpt for PaymentMethodPaynow { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodPaynowBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_paypal.rs b/generated/stripe_shared/src/payment_method_paypal.rs index 2f453f1b4..85410b150 100644 --- a/generated/stripe_shared/src/payment_method_paypal.rs +++ b/generated/stripe_shared/src/payment_method_paypal.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodPaypal { /// Owner's email. Values are provided by PayPal directly /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. @@ -6,3 +8,93 @@ pub struct PaymentMethodPaypal { /// PayPal account PayerID. This identifier uniquely identifies the PayPal customer. pub payer_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodPaypalBuilder { + payer_email: Option<Option<String>>, + payer_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodPaypal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodPaypal>, + builder: PaymentMethodPaypalBuilder, + } + + impl Visitor for Place<PaymentMethodPaypal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodPaypalBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodPaypalBuilder { + type Out = PaymentMethodPaypal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "payer_email" => Deserialize::begin(&mut self.payer_email), + "payer_id" => Deserialize::begin(&mut self.payer_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payer_email: Deserialize::default(), payer_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let payer_email = self.payer_email.take()?; + let payer_id = self.payer_id.take()?; + + Some(Self::Out { payer_email, payer_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodPaypal { + type Builder = PaymentMethodPaypalBuilder; + } + + impl FromValueOpt for PaymentMethodPaypal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodPaypalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payer_email" => b.payer_email = Some(FromValueOpt::from_value(v)?), + "payer_id" => b.payer_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_pix.rs b/generated/stripe_shared/src/payment_method_pix.rs index d85b9e220..f541075ec 100644 --- a/generated/stripe_shared/src/payment_method_pix.rs +++ b/generated/stripe_shared/src/payment_method_pix.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodPix {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodPixBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodPix { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodPix>, + builder: PaymentMethodPixBuilder, + } + + impl Visitor for Place<PaymentMethodPix> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodPixBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodPixBuilder { + type Out = PaymentMethodPix; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodPix { + type Builder = PaymentMethodPixBuilder; + } + + impl FromValueOpt for PaymentMethodPix { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodPixBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_promptpay.rs b/generated/stripe_shared/src/payment_method_promptpay.rs index 6f706eb99..784514fc4 100644 --- a/generated/stripe_shared/src/payment_method_promptpay.rs +++ b/generated/stripe_shared/src/payment_method_promptpay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodPromptpay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodPromptpayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodPromptpay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodPromptpay>, + builder: PaymentMethodPromptpayBuilder, + } + + impl Visitor for Place<PaymentMethodPromptpay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodPromptpayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodPromptpayBuilder { + type Out = PaymentMethodPromptpay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodPromptpay { + type Builder = PaymentMethodPromptpayBuilder; + } + + impl FromValueOpt for PaymentMethodPromptpay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodPromptpayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_revolut_pay.rs b/generated/stripe_shared/src/payment_method_revolut_pay.rs index d51e34e8a..ef24d599d 100644 --- a/generated/stripe_shared/src/payment_method_revolut_pay.rs +++ b/generated/stripe_shared/src/payment_method_revolut_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodRevolutPay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodRevolutPayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodRevolutPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodRevolutPay>, + builder: PaymentMethodRevolutPayBuilder, + } + + impl Visitor for Place<PaymentMethodRevolutPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodRevolutPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodRevolutPayBuilder { + type Out = PaymentMethodRevolutPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodRevolutPay { + type Builder = PaymentMethodRevolutPayBuilder; + } + + impl FromValueOpt for PaymentMethodRevolutPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodRevolutPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_sepa_debit.rs b/generated/stripe_shared/src/payment_method_sepa_debit.rs index c68ab553e..04ac552bd 100644 --- a/generated/stripe_shared/src/payment_method_sepa_debit.rs +++ b/generated/stripe_shared/src/payment_method_sepa_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodSepaDebit { /// Bank code of bank associated with the bank account. pub bank_code: Option<String>, @@ -14,3 +16,116 @@ pub struct PaymentMethodSepaDebit { /// Last four characters of the IBAN. pub last4: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodSepaDebitBuilder { + bank_code: Option<Option<String>>, + branch_code: Option<Option<String>>, + country: Option<Option<String>>, + fingerprint: Option<Option<String>>, + generated_from: Option<Option<stripe_shared::SepaDebitGeneratedFrom>>, + last4: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodSepaDebit>, + builder: PaymentMethodSepaDebitBuilder, + } + + impl Visitor for Place<PaymentMethodSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodSepaDebitBuilder { + type Out = PaymentMethodSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "branch_code" => Deserialize::begin(&mut self.branch_code), + "country" => Deserialize::begin(&mut self.country), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "generated_from" => Deserialize::begin(&mut self.generated_from), + "last4" => Deserialize::begin(&mut self.last4), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + branch_code: Deserialize::default(), + country: Deserialize::default(), + fingerprint: Deserialize::default(), + generated_from: Deserialize::default(), + last4: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let branch_code = self.branch_code.take()?; + let country = self.country.take()?; + let fingerprint = self.fingerprint.take()?; + let generated_from = self.generated_from.take()?; + let last4 = self.last4.take()?; + + Some(Self::Out { bank_code, branch_code, country, fingerprint, generated_from, last4 }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodSepaDebit { + type Builder = PaymentMethodSepaDebitBuilder; + } + + impl FromValueOpt for PaymentMethodSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "branch_code" => b.branch_code = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "generated_from" => b.generated_from = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_sofort.rs b/generated/stripe_shared/src/payment_method_sofort.rs index 5932ff7bd..f3fb75a41 100644 --- a/generated/stripe_shared/src/payment_method_sofort.rs +++ b/generated/stripe_shared/src/payment_method_sofort.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodSofort { /// Two-letter ISO code representing the country the bank account is located in. pub country: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodSofortBuilder { + country: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodSofort { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodSofort>, + builder: PaymentMethodSofortBuilder, + } + + impl Visitor for Place<PaymentMethodSofort> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodSofortBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodSofortBuilder { + type Out = PaymentMethodSofort; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + + Some(Self::Out { country }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodSofort { + type Builder = PaymentMethodSofortBuilder; + } + + impl FromValueOpt for PaymentMethodSofort { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodSofortBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_swish.rs b/generated/stripe_shared/src/payment_method_swish.rs deleted file mode 100644 index e47969890..000000000 --- a/generated/stripe_shared/src/payment_method_swish.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct PaymentMethodSwish {} diff --git a/generated/stripe_shared/src/payment_method_us_bank_account.rs b/generated/stripe_shared/src/payment_method_us_bank_account.rs index a485b4f71..eed90459b 100644 --- a/generated/stripe_shared/src/payment_method_us_bank_account.rs +++ b/generated/stripe_shared/src/payment_method_us_bank_account.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodUsBankAccount { /// Account holder type: individual or company. pub account_holder_type: Option<PaymentMethodUsBankAccountAccountHolderType>, @@ -20,6 +22,134 @@ pub struct PaymentMethodUsBankAccount { /// Contains information about the future reusability of this PaymentMethod. pub status_details: Option<stripe_shared::PaymentMethodUsBankAccountStatusDetails>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodUsBankAccountBuilder { + account_holder_type: Option<Option<PaymentMethodUsBankAccountAccountHolderType>>, + account_type: Option<Option<PaymentMethodUsBankAccountAccountType>>, + bank_name: Option<Option<String>>, + financial_connections_account: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + networks: Option<Option<stripe_shared::UsBankAccountNetworks>>, + routing_number: Option<Option<String>>, + status_details: Option<Option<stripe_shared::PaymentMethodUsBankAccountStatusDetails>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodUsBankAccount>, + builder: PaymentMethodUsBankAccountBuilder, + } + + impl Visitor for Place<PaymentMethodUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodUsBankAccountBuilder { + type Out = PaymentMethodUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "account_type" => Deserialize::begin(&mut self.account_type), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "financial_connections_account" => Deserialize::begin(&mut self.financial_connections_account), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "networks" => Deserialize::begin(&mut self.networks), + "routing_number" => Deserialize::begin(&mut self.routing_number), + "status_details" => Deserialize::begin(&mut self.status_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_type: Deserialize::default(), + account_type: Deserialize::default(), + bank_name: Deserialize::default(), + financial_connections_account: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + networks: Deserialize::default(), + routing_number: Deserialize::default(), + status_details: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let account_type = self.account_type.take()?; + let bank_name = self.bank_name.take()?; + let financial_connections_account = self.financial_connections_account.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let networks = self.networks.take()?; + let routing_number = self.routing_number.take()?; + let status_details = self.status_details.take()?; + + Some(Self::Out { account_holder_type, account_type, bank_name, financial_connections_account, fingerprint, last4, networks, routing_number, status_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodUsBankAccount { + type Builder = PaymentMethodUsBankAccountBuilder; + } + + impl FromValueOpt for PaymentMethodUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "financial_connections_account" => b.financial_connections_account = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "networks" => b.networks = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + "status_details" => b.status_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Account holder type: individual or company. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodUsBankAccountAccountHolderType { @@ -70,13 +200,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountAccountHolderTyp fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodUsBankAccountAccountHolderType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodUsBankAccountAccountHolderType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodUsBankAccountAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodUsBankAccountAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodUsBankAccountAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountAccountHolderType); /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodUsBankAccountAccountType { @@ -127,8 +271,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountAccountType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodUsBankAccountAccountType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodUsBankAccountAccountType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodUsBankAccountAccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodUsBankAccountAccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodUsBankAccountAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountAccountType); diff --git a/generated/stripe_shared/src/payment_method_us_bank_account_blocked.rs b/generated/stripe_shared/src/payment_method_us_bank_account_blocked.rs index f48ef46f3..dc50e4bd2 100644 --- a/generated/stripe_shared/src/payment_method_us_bank_account_blocked.rs +++ b/generated/stripe_shared/src/payment_method_us_bank_account_blocked.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodUsBankAccountBlocked { /// The ACH network code that resulted in this block. pub network_code: Option<PaymentMethodUsBankAccountBlockedNetworkCode>, /// The reason why this PaymentMethod's fingerprint has been blocked pub reason: Option<PaymentMethodUsBankAccountBlockedReason>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodUsBankAccountBlockedBuilder { + network_code: Option<Option<PaymentMethodUsBankAccountBlockedNetworkCode>>, + reason: Option<Option<PaymentMethodUsBankAccountBlockedReason>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodUsBankAccountBlocked { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodUsBankAccountBlocked>, + builder: PaymentMethodUsBankAccountBlockedBuilder, + } + + impl Visitor for Place<PaymentMethodUsBankAccountBlocked> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodUsBankAccountBlockedBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodUsBankAccountBlockedBuilder { + type Out = PaymentMethodUsBankAccountBlocked; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "network_code" => Deserialize::begin(&mut self.network_code), + "reason" => Deserialize::begin(&mut self.reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { network_code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let network_code = self.network_code.take()?; + let reason = self.reason.take()?; + + Some(Self::Out { network_code, reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodUsBankAccountBlocked { + type Builder = PaymentMethodUsBankAccountBlockedBuilder; + } + + impl FromValueOpt for PaymentMethodUsBankAccountBlocked { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodUsBankAccountBlockedBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "network_code" => b.network_code = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The ACH network code that resulted in this block. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodUsBankAccountBlockedNetworkCode { @@ -85,13 +177,27 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountBlockedNetworkCo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for PaymentMethodUsBankAccountBlockedNetworkCode", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodUsBankAccountBlockedNetworkCode")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodUsBankAccountBlockedNetworkCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodUsBankAccountBlockedNetworkCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodUsBankAccountBlockedNetworkCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountBlockedNetworkCode); /// The reason why this PaymentMethod's fingerprint has been blocked #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodUsBankAccountBlockedReason { @@ -154,8 +260,24 @@ impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountBlockedReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaymentMethodUsBankAccountBlockedReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaymentMethodUsBankAccountBlockedReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaymentMethodUsBankAccountBlockedReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaymentMethodUsBankAccountBlockedReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodUsBankAccountBlockedReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountBlockedReason); diff --git a/generated/stripe_shared/src/payment_method_us_bank_account_status_details.rs b/generated/stripe_shared/src/payment_method_us_bank_account_status_details.rs index c721bac94..62356036c 100644 --- a/generated/stripe_shared/src/payment_method_us_bank_account_status_details.rs +++ b/generated/stripe_shared/src/payment_method_us_bank_account_status_details.rs @@ -1,5 +1,92 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodUsBankAccountStatusDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub blocked: Option<stripe_shared::PaymentMethodUsBankAccountBlocked>, } +#[cfg(feature = "min-ser")] +pub struct PaymentMethodUsBankAccountStatusDetailsBuilder { + blocked: Option<Option<stripe_shared::PaymentMethodUsBankAccountBlocked>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodUsBankAccountStatusDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodUsBankAccountStatusDetails>, + builder: PaymentMethodUsBankAccountStatusDetailsBuilder, + } + + impl Visitor for Place<PaymentMethodUsBankAccountStatusDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodUsBankAccountStatusDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodUsBankAccountStatusDetailsBuilder { + type Out = PaymentMethodUsBankAccountStatusDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "blocked" => Deserialize::begin(&mut self.blocked), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { blocked: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let blocked = self.blocked.take()?; + + Some(Self::Out { blocked }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodUsBankAccountStatusDetails { + type Builder = PaymentMethodUsBankAccountStatusDetailsBuilder; + } + + impl FromValueOpt for PaymentMethodUsBankAccountStatusDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodUsBankAccountStatusDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "blocked" => b.blocked = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_wechat_pay.rs b/generated/stripe_shared/src/payment_method_wechat_pay.rs index 704c7830c..78e3a6d77 100644 --- a/generated/stripe_shared/src/payment_method_wechat_pay.rs +++ b/generated/stripe_shared/src/payment_method_wechat_pay.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodWechatPay {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodWechatPayBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodWechatPay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodWechatPay>, + builder: PaymentMethodWechatPayBuilder, + } + + impl Visitor for Place<PaymentMethodWechatPay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodWechatPayBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodWechatPayBuilder { + type Out = PaymentMethodWechatPay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodWechatPay { + type Builder = PaymentMethodWechatPayBuilder; + } + + impl FromValueOpt for PaymentMethodWechatPay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodWechatPayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_method_zip.rs b/generated/stripe_shared/src/payment_method_zip.rs index 425e0d65f..1f2326a71 100644 --- a/generated/stripe_shared/src/payment_method_zip.rs +++ b/generated/stripe_shared/src/payment_method_zip.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaymentMethodZip {} +#[cfg(feature = "min-ser")] +pub struct PaymentMethodZipBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodZip { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaymentMethodZip>, + builder: PaymentMethodZipBuilder, + } + + impl Visitor for Place<PaymentMethodZip> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaymentMethodZipBuilder::deser_default() })) + } + } + + impl MapBuilder for PaymentMethodZipBuilder { + type Out = PaymentMethodZip; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodZip { + type Builder = PaymentMethodZipBuilder; + } + + impl FromValueOpt for PaymentMethodZip { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodZipBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/payment_source.rs b/generated/stripe_shared/src/payment_source.rs index 27ae89f32..23dbb7107 100644 --- a/generated/stripe_shared/src/payment_source.rs +++ b/generated/stripe_shared/src/payment_source.rs @@ -1,16 +1,105 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum PaymentSource { - #[serde(rename = "account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "account"))] Account(stripe_shared::Account), - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct PaymentSourceBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<PaymentSource>, + builder: PaymentSourceBuilder, + } + + impl Deserialize for PaymentSource { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<PaymentSource> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for PaymentSourceBuilder { + type Out = PaymentSource; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + PaymentSource::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for PaymentSource { + type Builder = PaymentSourceBuilder; + } + impl PaymentSource { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "account" => Self::Account(FromValueOpt::from_value(Value::Object(o))?), + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for PaymentSource { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + impl stripe_types::Object for PaymentSource { type Id = smol_str::SmolStr; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/payout.rs b/generated/stripe_shared/src/payout.rs index 2bed66d8f..d27301e40 100644 --- a/generated/stripe_shared/src/payout.rs +++ b/generated/stripe_shared/src/payout.rs @@ -8,7 +8,9 @@ /// Related guide: [Receiving payouts](https://stripe.com/docs/payouts) /// /// For more details see <<https://stripe.com/docs/api/payouts/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Payout { /// The amount (in cents (or local equivalent)) that transfers to your bank account or debit card. pub amount: i64, @@ -29,8 +31,7 @@ pub struct Payout { /// ID of the bank account or card the payout is sent to. pub destination: Option<stripe_types::Expandable<stripe_shared::ExternalAccount>>, /// If the payout fails or cancels, this is the ID of the balance transaction that reverses the initial balance transaction and returns the funds from the failed payout back in your balance. - pub failure_balance_transaction: - Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, + pub failure_balance_transaction: Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, /// Error code that provides a reason for a payout failure, if available. /// View our [list of failure codes](https://stripe.com/docs/api#payout_failures). pub failure_code: Option<String>, @@ -63,9 +64,225 @@ pub struct Payout { /// Some payouts that fail might initially show as `paid`, then change to `failed`. pub status: String, /// Can be `bank_account` or `card`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: PayoutType, } +#[cfg(feature = "min-ser")] +pub struct PayoutBuilder { + amount: Option<i64>, + arrival_date: Option<stripe_types::Timestamp>, + automatic: Option<bool>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + destination: Option<Option<stripe_types::Expandable<stripe_shared::ExternalAccount>>>, + failure_balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + failure_code: Option<Option<String>>, + failure_message: Option<Option<String>>, + id: Option<stripe_shared::PayoutId>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + method: Option<String>, + original_payout: Option<Option<stripe_types::Expandable<stripe_shared::Payout>>>, + reconciliation_status: Option<PayoutReconciliationStatus>, + reversed_by: Option<Option<stripe_types::Expandable<stripe_shared::Payout>>>, + source_type: Option<String>, + statement_descriptor: Option<Option<String>>, + status: Option<String>, + type_: Option<PayoutType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Payout { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Payout>, + builder: PayoutBuilder, + } + + impl Visitor for Place<Payout> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PayoutBuilder::deser_default() })) + } + } + + impl MapBuilder for PayoutBuilder { + type Out = Payout; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "arrival_date" => Deserialize::begin(&mut self.arrival_date), + "automatic" => Deserialize::begin(&mut self.automatic), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "destination" => Deserialize::begin(&mut self.destination), + "failure_balance_transaction" => Deserialize::begin(&mut self.failure_balance_transaction), + "failure_code" => Deserialize::begin(&mut self.failure_code), + "failure_message" => Deserialize::begin(&mut self.failure_message), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "method" => Deserialize::begin(&mut self.method), + "original_payout" => Deserialize::begin(&mut self.original_payout), + "reconciliation_status" => Deserialize::begin(&mut self.reconciliation_status), + "reversed_by" => Deserialize::begin(&mut self.reversed_by), + "source_type" => Deserialize::begin(&mut self.source_type), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + arrival_date: Deserialize::default(), + automatic: Deserialize::default(), + balance_transaction: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + destination: Deserialize::default(), + failure_balance_transaction: Deserialize::default(), + failure_code: Deserialize::default(), + failure_message: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + method: Deserialize::default(), + original_payout: Deserialize::default(), + reconciliation_status: Deserialize::default(), + reversed_by: Deserialize::default(), + source_type: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let arrival_date = self.arrival_date.take()?; + let automatic = self.automatic.take()?; + let balance_transaction = self.balance_transaction.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let destination = self.destination.take()?; + let failure_balance_transaction = self.failure_balance_transaction.take()?; + let failure_code = self.failure_code.take()?; + let failure_message = self.failure_message.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let method = self.method.take()?; + let original_payout = self.original_payout.take()?; + let reconciliation_status = self.reconciliation_status.take()?; + let reversed_by = self.reversed_by.take()?; + let source_type = self.source_type.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { + amount, + arrival_date, + automatic, + balance_transaction, + created, + currency, + description, + destination, + failure_balance_transaction, + failure_code, + failure_message, + id, + livemode, + metadata, + method, + original_payout, + reconciliation_status, + reversed_by, + source_type, + statement_descriptor, + status, + type_, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Payout { + type Builder = PayoutBuilder; + } + + impl FromValueOpt for Payout { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PayoutBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "arrival_date" => b.arrival_date = Some(FromValueOpt::from_value(v)?), + "automatic" => b.automatic = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + "failure_balance_transaction" => b.failure_balance_transaction = Some(FromValueOpt::from_value(v)?), + "failure_code" => b.failure_code = Some(FromValueOpt::from_value(v)?), + "failure_message" => b.failure_message = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "method" => b.method = Some(FromValueOpt::from_value(v)?), + "original_payout" => b.original_payout = Some(FromValueOpt::from_value(v)?), + "reconciliation_status" => b.reconciliation_status = Some(FromValueOpt::from_value(v)?), + "reversed_by" => b.reversed_by = Some(FromValueOpt::from_value(v)?), + "source_type" => b.source_type = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// If `completed`, you can use the [Balance Transactions API](https://stripe.com/docs/api/balance_transactions/list#balance_transaction_list-payout) to list all balance transactions that are paid out in this payout. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PayoutReconciliationStatus { @@ -119,10 +336,27 @@ impl<'de> serde::Deserialize<'de> for PayoutReconciliationStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PayoutReconciliationStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PayoutReconciliationStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PayoutReconciliationStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PayoutReconciliationStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PayoutReconciliationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PayoutReconciliationStatus); /// Can be `bank_account` or `card`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PayoutType { @@ -176,6 +410,24 @@ impl<'de> serde::Deserialize<'de> for PayoutType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PayoutType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PayoutType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PayoutType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PayoutType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PayoutType); impl stripe_types::Object for Payout { type Id = stripe_shared::PayoutId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/paypal_seller_protection.rs b/generated/stripe_shared/src/paypal_seller_protection.rs index cf524141f..bee45a9e5 100644 --- a/generated/stripe_shared/src/paypal_seller_protection.rs +++ b/generated/stripe_shared/src/paypal_seller_protection.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PaypalSellerProtection { /// An array of conditions that are covered for the transaction, if applicable. pub dispute_categories: Option<Vec<PaypalSellerProtectionDisputeCategories>>, /// Indicates whether the transaction is eligible for PayPal's seller protection. pub status: PaypalSellerProtectionStatus, } +#[cfg(feature = "min-ser")] +pub struct PaypalSellerProtectionBuilder { + dispute_categories: Option<Option<Vec<PaypalSellerProtectionDisputeCategories>>>, + status: Option<PaypalSellerProtectionStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaypalSellerProtection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PaypalSellerProtection>, + builder: PaypalSellerProtectionBuilder, + } + + impl Visitor for Place<PaypalSellerProtection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PaypalSellerProtectionBuilder::deser_default() })) + } + } + + impl MapBuilder for PaypalSellerProtectionBuilder { + type Out = PaypalSellerProtection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "dispute_categories" => Deserialize::begin(&mut self.dispute_categories), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { dispute_categories: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let dispute_categories = self.dispute_categories.take()?; + let status = self.status.take()?; + + Some(Self::Out { dispute_categories, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaypalSellerProtection { + type Builder = PaypalSellerProtectionBuilder; + } + + impl FromValueOpt for PaypalSellerProtection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaypalSellerProtectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "dispute_categories" => b.dispute_categories = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// An array of conditions that are covered for the transaction, if applicable. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaypalSellerProtectionDisputeCategories { @@ -55,11 +147,27 @@ impl<'de> serde::Deserialize<'de> for PaypalSellerProtectionDisputeCategories { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for PaypalSellerProtectionDisputeCategories") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaypalSellerProtectionDisputeCategories")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaypalSellerProtectionDisputeCategories { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaypalSellerProtectionDisputeCategories> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaypalSellerProtectionDisputeCategories::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaypalSellerProtectionDisputeCategories); /// Indicates whether the transaction is eligible for PayPal's seller protection. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaypalSellerProtectionStatus { @@ -113,7 +221,24 @@ impl<'de> serde::Deserialize<'de> for PaypalSellerProtectionStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PaypalSellerProtectionStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PaypalSellerProtectionStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PaypalSellerProtectionStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PaypalSellerProtectionStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaypalSellerProtectionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PaypalSellerProtectionStatus); diff --git a/generated/stripe_shared/src/period.rs b/generated/stripe_shared/src/period.rs index 5dd14f7fd..070a51ebd 100644 --- a/generated/stripe_shared/src/period.rs +++ b/generated/stripe_shared/src/period.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Period { /// The end date of this usage period. All usage up to and including this point in time is included. pub end: Option<stripe_types::Timestamp>, /// The start date of this usage period. All usage after this point in time is included. pub start: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct PeriodBuilder { + end: Option<Option<stripe_types::Timestamp>>, + start: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Period { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Period>, + builder: PeriodBuilder, + } + + impl Visitor for Place<Period> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PeriodBuilder::deser_default() })) + } + } + + impl MapBuilder for PeriodBuilder { + type Out = Period; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "end" => Deserialize::begin(&mut self.end), + "start" => Deserialize::begin(&mut self.start), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end: Deserialize::default(), start: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let end = self.end.take()?; + let start = self.start.take()?; + + Some(Self::Out { end, start }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Period { + type Builder = PeriodBuilder; + } + + impl FromValueOpt for Period { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PeriodBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "end" => b.end = Some(FromValueOpt::from_value(v)?), + "start" => b.start = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/person.rs b/generated/stripe_shared/src/person.rs index 9389f82c4..a7ac5235b 100644 --- a/generated/stripe_shared/src/person.rs +++ b/generated/stripe_shared/src/person.rs @@ -6,94 +6,332 @@ /// Related guide: [Handling identity verification with the API](https://stripe.com/docs/connect/handling-api-verification#person-information). /// /// For more details see <<https://stripe.com/docs/api/persons/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Person { /// The account the person is associated with. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub additional_tos_acceptances: Option<stripe_shared::PersonAdditionalTosAcceptances>, - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<stripe_shared::Address>, /// The Kana variation of the person's address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kana: Option<stripe_shared::LegalEntityJapanAddress>, /// The Kanji variation of the person's address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kanji: Option<stripe_shared::LegalEntityJapanAddress>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, - #[serde(skip_serializing_if = "Option::is_none")] pub dob: Option<stripe_shared::LegalEntityDob>, /// The person's email address. - #[serde(skip_serializing_if = "Option::is_none")] pub email: Option<String>, /// The person's first name. - #[serde(skip_serializing_if = "Option::is_none")] pub first_name: Option<String>, /// The Kana variation of the person's first name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub first_name_kana: Option<String>, /// The Kanji variation of the person's first name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub first_name_kanji: Option<String>, /// A list of alternate names or aliases that the person is known by. - #[serde(skip_serializing_if = "Option::is_none")] pub full_name_aliases: Option<Vec<String>>, /// Information about the [upcoming new requirements for this person](https://stripe.com/docs/connect/custom-accounts/future-requirements), including what information needs to be collected, and by when. - #[serde(skip_serializing_if = "Option::is_none")] pub future_requirements: Option<stripe_shared::PersonFutureRequirements>, /// The person's gender (International regulations require either "male" or "female"). - #[serde(skip_serializing_if = "Option::is_none")] pub gender: Option<String>, /// Unique identifier for the object. pub id: stripe_shared::PersonId, /// Whether the person's `id_number` was provided. /// True if either the full ID number was provided or if only the required part of the ID number was provided (ex. /// last four of an individual's SSN for the US indicated by `ssn_last_4_provided`). - #[serde(skip_serializing_if = "Option::is_none")] pub id_number_provided: Option<bool>, /// Whether the person's `id_number_secondary` was provided. - #[serde(skip_serializing_if = "Option::is_none")] pub id_number_secondary_provided: Option<bool>, /// The person's last name. - #[serde(skip_serializing_if = "Option::is_none")] pub last_name: Option<String>, /// The Kana variation of the person's last name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub last_name_kana: Option<String>, /// The Kanji variation of the person's last name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub last_name_kanji: Option<String>, /// The person's maiden name. - #[serde(skip_serializing_if = "Option::is_none")] pub maiden_name: Option<String>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. - #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<std::collections::HashMap<String, String>>, /// The country where the person is a national. - #[serde(skip_serializing_if = "Option::is_none")] pub nationality: Option<String>, /// The person's phone number. - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option<String>, /// Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction. - #[serde(skip_serializing_if = "Option::is_none")] pub political_exposure: Option<PersonPoliticalExposure>, - #[serde(skip_serializing_if = "Option::is_none")] pub registered_address: Option<stripe_shared::Address>, - #[serde(skip_serializing_if = "Option::is_none")] pub relationship: Option<stripe_shared::PersonRelationship>, /// Information about the requirements for this person, including what information needs to be collected, and by when. - #[serde(skip_serializing_if = "Option::is_none")] pub requirements: Option<stripe_shared::PersonRequirements>, /// Whether the last four digits of the person's Social Security number have been provided (U.S. only). - #[serde(skip_serializing_if = "Option::is_none")] pub ssn_last_4_provided: Option<bool>, - #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option<stripe_shared::LegalEntityPersonVerification>, } +#[cfg(feature = "min-ser")] +pub struct PersonBuilder { + account: Option<Option<String>>, + additional_tos_acceptances: Option<Option<stripe_shared::PersonAdditionalTosAcceptances>>, + address: Option<Option<stripe_shared::Address>>, + address_kana: Option<Option<stripe_shared::LegalEntityJapanAddress>>, + address_kanji: Option<Option<stripe_shared::LegalEntityJapanAddress>>, + created: Option<stripe_types::Timestamp>, + dob: Option<Option<stripe_shared::LegalEntityDob>>, + email: Option<Option<String>>, + first_name: Option<Option<String>>, + first_name_kana: Option<Option<String>>, + first_name_kanji: Option<Option<String>>, + full_name_aliases: Option<Option<Vec<String>>>, + future_requirements: Option<Option<stripe_shared::PersonFutureRequirements>>, + gender: Option<Option<String>>, + id: Option<stripe_shared::PersonId>, + id_number_provided: Option<Option<bool>>, + id_number_secondary_provided: Option<Option<bool>>, + last_name: Option<Option<String>>, + last_name_kana: Option<Option<String>>, + last_name_kanji: Option<Option<String>>, + maiden_name: Option<Option<String>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + nationality: Option<Option<String>>, + phone: Option<Option<String>>, + political_exposure: Option<Option<PersonPoliticalExposure>>, + registered_address: Option<Option<stripe_shared::Address>>, + relationship: Option<Option<stripe_shared::PersonRelationship>>, + requirements: Option<Option<stripe_shared::PersonRequirements>>, + ssn_last_4_provided: Option<Option<bool>>, + verification: Option<Option<stripe_shared::LegalEntityPersonVerification>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Person { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Person>, + builder: PersonBuilder, + } + + impl Visitor for Place<Person> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PersonBuilder::deser_default() })) + } + } + + impl MapBuilder for PersonBuilder { + type Out = Person; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "additional_tos_acceptances" => Deserialize::begin(&mut self.additional_tos_acceptances), + "address" => Deserialize::begin(&mut self.address), + "address_kana" => Deserialize::begin(&mut self.address_kana), + "address_kanji" => Deserialize::begin(&mut self.address_kanji), + "created" => Deserialize::begin(&mut self.created), + "dob" => Deserialize::begin(&mut self.dob), + "email" => Deserialize::begin(&mut self.email), + "first_name" => Deserialize::begin(&mut self.first_name), + "first_name_kana" => Deserialize::begin(&mut self.first_name_kana), + "first_name_kanji" => Deserialize::begin(&mut self.first_name_kanji), + "full_name_aliases" => Deserialize::begin(&mut self.full_name_aliases), + "future_requirements" => Deserialize::begin(&mut self.future_requirements), + "gender" => Deserialize::begin(&mut self.gender), + "id" => Deserialize::begin(&mut self.id), + "id_number_provided" => Deserialize::begin(&mut self.id_number_provided), + "id_number_secondary_provided" => Deserialize::begin(&mut self.id_number_secondary_provided), + "last_name" => Deserialize::begin(&mut self.last_name), + "last_name_kana" => Deserialize::begin(&mut self.last_name_kana), + "last_name_kanji" => Deserialize::begin(&mut self.last_name_kanji), + "maiden_name" => Deserialize::begin(&mut self.maiden_name), + "metadata" => Deserialize::begin(&mut self.metadata), + "nationality" => Deserialize::begin(&mut self.nationality), + "phone" => Deserialize::begin(&mut self.phone), + "political_exposure" => Deserialize::begin(&mut self.political_exposure), + "registered_address" => Deserialize::begin(&mut self.registered_address), + "relationship" => Deserialize::begin(&mut self.relationship), + "requirements" => Deserialize::begin(&mut self.requirements), + "ssn_last_4_provided" => Deserialize::begin(&mut self.ssn_last_4_provided), + "verification" => Deserialize::begin(&mut self.verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + additional_tos_acceptances: Deserialize::default(), + address: Deserialize::default(), + address_kana: Deserialize::default(), + address_kanji: Deserialize::default(), + created: Deserialize::default(), + dob: Deserialize::default(), + email: Deserialize::default(), + first_name: Deserialize::default(), + first_name_kana: Deserialize::default(), + first_name_kanji: Deserialize::default(), + full_name_aliases: Deserialize::default(), + future_requirements: Deserialize::default(), + gender: Deserialize::default(), + id: Deserialize::default(), + id_number_provided: Deserialize::default(), + id_number_secondary_provided: Deserialize::default(), + last_name: Deserialize::default(), + last_name_kana: Deserialize::default(), + last_name_kanji: Deserialize::default(), + maiden_name: Deserialize::default(), + metadata: Deserialize::default(), + nationality: Deserialize::default(), + phone: Deserialize::default(), + political_exposure: Deserialize::default(), + registered_address: Deserialize::default(), + relationship: Deserialize::default(), + requirements: Deserialize::default(), + ssn_last_4_provided: Deserialize::default(), + verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let additional_tos_acceptances = self.additional_tos_acceptances.take()?; + let address = self.address.take()?; + let address_kana = self.address_kana.take()?; + let address_kanji = self.address_kanji.take()?; + let created = self.created.take()?; + let dob = self.dob.take()?; + let email = self.email.take()?; + let first_name = self.first_name.take()?; + let first_name_kana = self.first_name_kana.take()?; + let first_name_kanji = self.first_name_kanji.take()?; + let full_name_aliases = self.full_name_aliases.take()?; + let future_requirements = self.future_requirements.take()?; + let gender = self.gender.take()?; + let id = self.id.take()?; + let id_number_provided = self.id_number_provided.take()?; + let id_number_secondary_provided = self.id_number_secondary_provided.take()?; + let last_name = self.last_name.take()?; + let last_name_kana = self.last_name_kana.take()?; + let last_name_kanji = self.last_name_kanji.take()?; + let maiden_name = self.maiden_name.take()?; + let metadata = self.metadata.take()?; + let nationality = self.nationality.take()?; + let phone = self.phone.take()?; + let political_exposure = self.political_exposure.take()?; + let registered_address = self.registered_address.take()?; + let relationship = self.relationship.take()?; + let requirements = self.requirements.take()?; + let ssn_last_4_provided = self.ssn_last_4_provided.take()?; + let verification = self.verification.take()?; + + Some(Self::Out { + account, + additional_tos_acceptances, + address, + address_kana, + address_kanji, + created, + dob, + email, + first_name, + first_name_kana, + first_name_kanji, + full_name_aliases, + future_requirements, + gender, + id, + id_number_provided, + id_number_secondary_provided, + last_name, + last_name_kana, + last_name_kanji, + maiden_name, + metadata, + nationality, + phone, + political_exposure, + registered_address, + relationship, + requirements, + ssn_last_4_provided, + verification, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Person { + type Builder = PersonBuilder; + } + + impl FromValueOpt for Person { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PersonBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "additional_tos_acceptances" => b.additional_tos_acceptances = Some(FromValueOpt::from_value(v)?), + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "address_kana" => b.address_kana = Some(FromValueOpt::from_value(v)?), + "address_kanji" => b.address_kanji = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "dob" => b.dob = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "first_name" => b.first_name = Some(FromValueOpt::from_value(v)?), + "first_name_kana" => b.first_name_kana = Some(FromValueOpt::from_value(v)?), + "first_name_kanji" => b.first_name_kanji = Some(FromValueOpt::from_value(v)?), + "full_name_aliases" => b.full_name_aliases = Some(FromValueOpt::from_value(v)?), + "future_requirements" => b.future_requirements = Some(FromValueOpt::from_value(v)?), + "gender" => b.gender = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "id_number_provided" => b.id_number_provided = Some(FromValueOpt::from_value(v)?), + "id_number_secondary_provided" => b.id_number_secondary_provided = Some(FromValueOpt::from_value(v)?), + "last_name" => b.last_name = Some(FromValueOpt::from_value(v)?), + "last_name_kana" => b.last_name_kana = Some(FromValueOpt::from_value(v)?), + "last_name_kanji" => b.last_name_kanji = Some(FromValueOpt::from_value(v)?), + "maiden_name" => b.maiden_name = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "nationality" => b.nationality = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + "political_exposure" => b.political_exposure = Some(FromValueOpt::from_value(v)?), + "registered_address" => b.registered_address = Some(FromValueOpt::from_value(v)?), + "relationship" => b.relationship = Some(FromValueOpt::from_value(v)?), + "requirements" => b.requirements = Some(FromValueOpt::from_value(v)?), + "ssn_last_4_provided" => b.ssn_last_4_provided = Some(FromValueOpt::from_value(v)?), + "verification" => b.verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PersonPoliticalExposure { @@ -144,10 +382,27 @@ impl<'de> serde::Deserialize<'de> for PersonPoliticalExposure { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PersonPoliticalExposure")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PersonPoliticalExposure")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PersonPoliticalExposure { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PersonPoliticalExposure> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PersonPoliticalExposure::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PersonPoliticalExposure); impl stripe_types::Object for Person { type Id = stripe_shared::PersonId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/person_additional_tos_acceptance.rs b/generated/stripe_shared/src/person_additional_tos_acceptance.rs index e0d67e184..bbb096c05 100644 --- a/generated/stripe_shared/src/person_additional_tos_acceptance.rs +++ b/generated/stripe_shared/src/person_additional_tos_acceptance.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PersonAdditionalTosAcceptance { /// The Unix timestamp marking when the legal guardian accepted the service agreement. pub date: Option<stripe_types::Timestamp>, @@ -7,3 +9,97 @@ pub struct PersonAdditionalTosAcceptance { /// The user agent of the browser from which the legal guardian accepted the service agreement. pub user_agent: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PersonAdditionalTosAcceptanceBuilder { + date: Option<Option<stripe_types::Timestamp>>, + ip: Option<Option<String>>, + user_agent: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PersonAdditionalTosAcceptance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PersonAdditionalTosAcceptance>, + builder: PersonAdditionalTosAcceptanceBuilder, + } + + impl Visitor for Place<PersonAdditionalTosAcceptance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PersonAdditionalTosAcceptanceBuilder::deser_default() })) + } + } + + impl MapBuilder for PersonAdditionalTosAcceptanceBuilder { + type Out = PersonAdditionalTosAcceptance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "date" => Deserialize::begin(&mut self.date), + "ip" => Deserialize::begin(&mut self.ip), + "user_agent" => Deserialize::begin(&mut self.user_agent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { date: Deserialize::default(), ip: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let date = self.date.take()?; + let ip = self.ip.take()?; + let user_agent = self.user_agent.take()?; + + Some(Self::Out { date, ip, user_agent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PersonAdditionalTosAcceptance { + type Builder = PersonAdditionalTosAcceptanceBuilder; + } + + impl FromValueOpt for PersonAdditionalTosAcceptance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PersonAdditionalTosAcceptanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "date" => b.date = Some(FromValueOpt::from_value(v)?), + "ip" => b.ip = Some(FromValueOpt::from_value(v)?), + "user_agent" => b.user_agent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/person_additional_tos_acceptances.rs b/generated/stripe_shared/src/person_additional_tos_acceptances.rs index 0e3c641e7..d9f0d1f4c 100644 --- a/generated/stripe_shared/src/person_additional_tos_acceptances.rs +++ b/generated/stripe_shared/src/person_additional_tos_acceptances.rs @@ -1,4 +1,92 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PersonAdditionalTosAcceptances { pub account: stripe_shared::PersonAdditionalTosAcceptance, } +#[cfg(feature = "min-ser")] +pub struct PersonAdditionalTosAcceptancesBuilder { + account: Option<stripe_shared::PersonAdditionalTosAcceptance>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PersonAdditionalTosAcceptances { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PersonAdditionalTosAcceptances>, + builder: PersonAdditionalTosAcceptancesBuilder, + } + + impl Visitor for Place<PersonAdditionalTosAcceptances> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PersonAdditionalTosAcceptancesBuilder::deser_default() })) + } + } + + impl MapBuilder for PersonAdditionalTosAcceptancesBuilder { + type Out = PersonAdditionalTosAcceptances; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + + Some(Self::Out { account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PersonAdditionalTosAcceptances { + type Builder = PersonAdditionalTosAcceptancesBuilder; + } + + impl FromValueOpt for PersonAdditionalTosAcceptances { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PersonAdditionalTosAcceptancesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/person_future_requirements.rs b/generated/stripe_shared/src/person_future_requirements.rs index b226c55a5..e64a3d21d 100644 --- a/generated/stripe_shared/src/person_future_requirements.rs +++ b/generated/stripe_shared/src/person_future_requirements.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PersonFutureRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>, @@ -19,3 +21,116 @@ pub struct PersonFutureRequirements { /// If verification fails, these fields move to `eventually_due` or `currently_due`. pub pending_verification: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct PersonFutureRequirementsBuilder { + alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>, + currently_due: Option<Vec<String>>, + errors: Option<Vec<stripe_shared::AccountRequirementsError>>, + eventually_due: Option<Vec<String>>, + past_due: Option<Vec<String>>, + pending_verification: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PersonFutureRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PersonFutureRequirements>, + builder: PersonFutureRequirementsBuilder, + } + + impl Visitor for Place<PersonFutureRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PersonFutureRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for PersonFutureRequirementsBuilder { + type Out = PersonFutureRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alternatives" => Deserialize::begin(&mut self.alternatives), + "currently_due" => Deserialize::begin(&mut self.currently_due), + "errors" => Deserialize::begin(&mut self.errors), + "eventually_due" => Deserialize::begin(&mut self.eventually_due), + "past_due" => Deserialize::begin(&mut self.past_due), + "pending_verification" => Deserialize::begin(&mut self.pending_verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alternatives: Deserialize::default(), + currently_due: Deserialize::default(), + errors: Deserialize::default(), + eventually_due: Deserialize::default(), + past_due: Deserialize::default(), + pending_verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alternatives = self.alternatives.take()?; + let currently_due = self.currently_due.take()?; + let errors = self.errors.take()?; + let eventually_due = self.eventually_due.take()?; + let past_due = self.past_due.take()?; + let pending_verification = self.pending_verification.take()?; + + Some(Self::Out { alternatives, currently_due, errors, eventually_due, past_due, pending_verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PersonFutureRequirements { + type Builder = PersonFutureRequirementsBuilder; + } + + impl FromValueOpt for PersonFutureRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PersonFutureRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alternatives" => b.alternatives = Some(FromValueOpt::from_value(v)?), + "currently_due" => b.currently_due = Some(FromValueOpt::from_value(v)?), + "errors" => b.errors = Some(FromValueOpt::from_value(v)?), + "eventually_due" => b.eventually_due = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "pending_verification" => b.pending_verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/person_relationship.rs b/generated/stripe_shared/src/person_relationship.rs index 5dff94be4..e197b15bd 100644 --- a/generated/stripe_shared/src/person_relationship.rs +++ b/generated/stripe_shared/src/person_relationship.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PersonRelationship { /// Whether the person is a director of the account's legal entity. /// Directors are typically members of the governing board of the company, or responsible for ensuring the company meets its regulatory obligations. @@ -19,3 +21,121 @@ pub struct PersonRelationship { /// The person's title (e.g., CEO, Support Engineer). pub title: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PersonRelationshipBuilder { + director: Option<Option<bool>>, + executive: Option<Option<bool>>, + legal_guardian: Option<Option<bool>>, + owner: Option<Option<bool>>, + percent_ownership: Option<Option<f64>>, + representative: Option<Option<bool>>, + title: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PersonRelationship { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PersonRelationship>, + builder: PersonRelationshipBuilder, + } + + impl Visitor for Place<PersonRelationship> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PersonRelationshipBuilder::deser_default() })) + } + } + + impl MapBuilder for PersonRelationshipBuilder { + type Out = PersonRelationship; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "director" => Deserialize::begin(&mut self.director), + "executive" => Deserialize::begin(&mut self.executive), + "legal_guardian" => Deserialize::begin(&mut self.legal_guardian), + "owner" => Deserialize::begin(&mut self.owner), + "percent_ownership" => Deserialize::begin(&mut self.percent_ownership), + "representative" => Deserialize::begin(&mut self.representative), + "title" => Deserialize::begin(&mut self.title), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + director: Deserialize::default(), + executive: Deserialize::default(), + legal_guardian: Deserialize::default(), + owner: Deserialize::default(), + percent_ownership: Deserialize::default(), + representative: Deserialize::default(), + title: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let director = self.director.take()?; + let executive = self.executive.take()?; + let legal_guardian = self.legal_guardian.take()?; + let owner = self.owner.take()?; + let percent_ownership = self.percent_ownership.take()?; + let representative = self.representative.take()?; + let title = self.title.take()?; + + Some(Self::Out { director, executive, legal_guardian, owner, percent_ownership, representative, title }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PersonRelationship { + type Builder = PersonRelationshipBuilder; + } + + impl FromValueOpt for PersonRelationship { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PersonRelationshipBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "director" => b.director = Some(FromValueOpt::from_value(v)?), + "executive" => b.executive = Some(FromValueOpt::from_value(v)?), + "legal_guardian" => b.legal_guardian = Some(FromValueOpt::from_value(v)?), + "owner" => b.owner = Some(FromValueOpt::from_value(v)?), + "percent_ownership" => b.percent_ownership = Some(FromValueOpt::from_value(v)?), + "representative" => b.representative = Some(FromValueOpt::from_value(v)?), + "title" => b.title = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/person_requirements.rs b/generated/stripe_shared/src/person_requirements.rs index b15182337..2fc81c826 100644 --- a/generated/stripe_shared/src/person_requirements.rs +++ b/generated/stripe_shared/src/person_requirements.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PersonRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option<Vec<stripe_shared::AccountRequirementsAlternative>>, @@ -18,3 +20,116 @@ pub struct PersonRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct PersonRequirementsBuilder { + alternatives: Option<Option<Vec<stripe_shared::AccountRequirementsAlternative>>>, + currently_due: Option<Vec<String>>, + errors: Option<Vec<stripe_shared::AccountRequirementsError>>, + eventually_due: Option<Vec<String>>, + past_due: Option<Vec<String>>, + pending_verification: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PersonRequirements { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PersonRequirements>, + builder: PersonRequirementsBuilder, + } + + impl Visitor for Place<PersonRequirements> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PersonRequirementsBuilder::deser_default() })) + } + } + + impl MapBuilder for PersonRequirementsBuilder { + type Out = PersonRequirements; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "alternatives" => Deserialize::begin(&mut self.alternatives), + "currently_due" => Deserialize::begin(&mut self.currently_due), + "errors" => Deserialize::begin(&mut self.errors), + "eventually_due" => Deserialize::begin(&mut self.eventually_due), + "past_due" => Deserialize::begin(&mut self.past_due), + "pending_verification" => Deserialize::begin(&mut self.pending_verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alternatives: Deserialize::default(), + currently_due: Deserialize::default(), + errors: Deserialize::default(), + eventually_due: Deserialize::default(), + past_due: Deserialize::default(), + pending_verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let alternatives = self.alternatives.take()?; + let currently_due = self.currently_due.take()?; + let errors = self.errors.take()?; + let eventually_due = self.eventually_due.take()?; + let past_due = self.past_due.take()?; + let pending_verification = self.pending_verification.take()?; + + Some(Self::Out { alternatives, currently_due, errors, eventually_due, past_due, pending_verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PersonRequirements { + type Builder = PersonRequirementsBuilder; + } + + impl FromValueOpt for PersonRequirements { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PersonRequirementsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "alternatives" => b.alternatives = Some(FromValueOpt::from_value(v)?), + "currently_due" => b.currently_due = Some(FromValueOpt::from_value(v)?), + "errors" => b.errors = Some(FromValueOpt::from_value(v)?), + "eventually_due" => b.eventually_due = Some(FromValueOpt::from_value(v)?), + "past_due" => b.past_due = Some(FromValueOpt::from_value(v)?), + "pending_verification" => b.pending_verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/plan.rs b/generated/stripe_shared/src/plan.rs index eab07a8f9..a478669f1 100644 --- a/generated/stripe_shared/src/plan.rs +++ b/generated/stripe_shared/src/plan.rs @@ -11,7 +11,9 @@ /// Related guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription) and more about [products and prices](https://stripe.com/docs/products-prices/overview). /// /// For more details see <<https://stripe.com/docs/api/plans/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Plan { /// Whether the plan can be used for new purchases. pub active: bool, @@ -54,7 +56,6 @@ pub struct Plan { /// Each element represents a pricing tier. /// This parameter requires `billing_scheme` to be set to `tiered`. /// See also the documentation for `billing_scheme`. - #[serde(skip_serializing_if = "Option::is_none")] pub tiers: Option<Vec<stripe_shared::PlanTier>>, /// Defines if the tiering price should be `graduated` or `volume` based. /// In `volume`-based tiering, the maximum quantity within a period determines the per unit price. @@ -72,6 +73,204 @@ pub struct Plan { /// Defaults to `licensed`. pub usage_type: stripe_shared::PlanUsageType, } +#[cfg(feature = "min-ser")] +pub struct PlanBuilder { + active: Option<bool>, + aggregate_usage: Option<Option<stripe_shared::PlanAggregateUsage>>, + amount: Option<Option<i64>>, + amount_decimal: Option<Option<String>>, + billing_scheme: Option<stripe_shared::PlanBillingScheme>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + id: Option<stripe_shared::PlanId>, + interval: Option<stripe_shared::PlanInterval>, + interval_count: Option<u64>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + nickname: Option<Option<String>>, + product: Option<Option<stripe_types::Expandable<stripe_shared::Product>>>, + tiers: Option<Option<Vec<stripe_shared::PlanTier>>>, + tiers_mode: Option<Option<stripe_shared::PlanTiersMode>>, + transform_usage: Option<Option<stripe_shared::TransformUsage>>, + trial_period_days: Option<Option<u32>>, + usage_type: Option<stripe_shared::PlanUsageType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Plan { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Plan>, + builder: PlanBuilder, + } + + impl Visitor for Place<Plan> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PlanBuilder::deser_default() })) + } + } + + impl MapBuilder for PlanBuilder { + type Out = Plan; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "aggregate_usage" => Deserialize::begin(&mut self.aggregate_usage), + "amount" => Deserialize::begin(&mut self.amount), + "amount_decimal" => Deserialize::begin(&mut self.amount_decimal), + "billing_scheme" => Deserialize::begin(&mut self.billing_scheme), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "id" => Deserialize::begin(&mut self.id), + "interval" => Deserialize::begin(&mut self.interval), + "interval_count" => Deserialize::begin(&mut self.interval_count), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "nickname" => Deserialize::begin(&mut self.nickname), + "product" => Deserialize::begin(&mut self.product), + "tiers" => Deserialize::begin(&mut self.tiers), + "tiers_mode" => Deserialize::begin(&mut self.tiers_mode), + "transform_usage" => Deserialize::begin(&mut self.transform_usage), + "trial_period_days" => Deserialize::begin(&mut self.trial_period_days), + "usage_type" => Deserialize::begin(&mut self.usage_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + aggregate_usage: Deserialize::default(), + amount: Deserialize::default(), + amount_decimal: Deserialize::default(), + billing_scheme: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + id: Deserialize::default(), + interval: Deserialize::default(), + interval_count: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + nickname: Deserialize::default(), + product: Deserialize::default(), + tiers: Deserialize::default(), + tiers_mode: Deserialize::default(), + transform_usage: Deserialize::default(), + trial_period_days: Deserialize::default(), + usage_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let aggregate_usage = self.aggregate_usage.take()?; + let amount = self.amount.take()?; + let amount_decimal = self.amount_decimal.take()?; + let billing_scheme = self.billing_scheme.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let id = self.id.take()?; + let interval = self.interval.take()?; + let interval_count = self.interval_count.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let nickname = self.nickname.take()?; + let product = self.product.take()?; + let tiers = self.tiers.take()?; + let tiers_mode = self.tiers_mode.take()?; + let transform_usage = self.transform_usage.take()?; + let trial_period_days = self.trial_period_days.take()?; + let usage_type = self.usage_type.take()?; + + Some(Self::Out { + active, + aggregate_usage, + amount, + amount_decimal, + billing_scheme, + created, + currency, + id, + interval, + interval_count, + livemode, + metadata, + nickname, + product, + tiers, + tiers_mode, + transform_usage, + trial_period_days, + usage_type, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Plan { + type Builder = PlanBuilder; + } + + impl FromValueOpt for Plan { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PlanBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "aggregate_usage" => b.aggregate_usage = Some(FromValueOpt::from_value(v)?), + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_decimal" => b.amount_decimal = Some(FromValueOpt::from_value(v)?), + "billing_scheme" => b.billing_scheme = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "interval_count" => b.interval_count = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "nickname" => b.nickname = Some(FromValueOpt::from_value(v)?), + "product" => b.product = Some(FromValueOpt::from_value(v)?), + "tiers" => b.tiers = Some(FromValueOpt::from_value(v)?), + "tiers_mode" => b.tiers_mode = Some(FromValueOpt::from_value(v)?), + "transform_usage" => b.transform_usage = Some(FromValueOpt::from_value(v)?), + "trial_period_days" => b.trial_period_days = Some(FromValueOpt::from_value(v)?), + "usage_type" => b.usage_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Plan { type Id = stripe_shared::PlanId; fn id(&self) -> &Self::Id { @@ -134,10 +333,27 @@ impl<'de> serde::Deserialize<'de> for PlanAggregateUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PlanAggregateUsage")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PlanAggregateUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PlanAggregateUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PlanAggregateUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanAggregateUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PlanAggregateUsage); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PlanBillingScheme { PerUnit, @@ -187,10 +403,27 @@ impl<'de> serde::Deserialize<'de> for PlanBillingScheme { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PlanBillingScheme")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PlanBillingScheme")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PlanBillingScheme { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PlanBillingScheme> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanBillingScheme::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PlanBillingScheme); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PlanInterval { Day, @@ -249,6 +482,24 @@ impl<'de> serde::Deserialize<'de> for PlanInterval { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PlanInterval")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PlanInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PlanInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PlanInterval); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PlanTiersMode { Graduated, @@ -301,6 +552,24 @@ impl<'de> serde::Deserialize<'de> for PlanTiersMode { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PlanTiersMode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PlanTiersMode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PlanTiersMode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanTiersMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PlanTiersMode); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PlanUsageType { Licensed, @@ -353,3 +622,21 @@ impl<'de> serde::Deserialize<'de> for PlanUsageType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PlanUsageType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PlanUsageType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PlanUsageType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanUsageType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PlanUsageType); diff --git a/generated/stripe_shared/src/plan_tier.rs b/generated/stripe_shared/src/plan_tier.rs index ad338db35..f1b46566d 100644 --- a/generated/stripe_shared/src/plan_tier.rs +++ b/generated/stripe_shared/src/plan_tier.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PlanTier { /// Price for the entire tier. pub flat_amount: Option<i64>, @@ -11,3 +13,111 @@ pub struct PlanTier { /// Up to and including to this quantity will be contained in the tier. pub up_to: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct PlanTierBuilder { + flat_amount: Option<Option<i64>>, + flat_amount_decimal: Option<Option<String>>, + unit_amount: Option<Option<i64>>, + unit_amount_decimal: Option<Option<String>>, + up_to: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PlanTier { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PlanTier>, + builder: PlanTierBuilder, + } + + impl Visitor for Place<PlanTier> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PlanTierBuilder::deser_default() })) + } + } + + impl MapBuilder for PlanTierBuilder { + type Out = PlanTier; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "flat_amount" => Deserialize::begin(&mut self.flat_amount), + "flat_amount_decimal" => Deserialize::begin(&mut self.flat_amount_decimal), + "unit_amount" => Deserialize::begin(&mut self.unit_amount), + "unit_amount_decimal" => Deserialize::begin(&mut self.unit_amount_decimal), + "up_to" => Deserialize::begin(&mut self.up_to), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + flat_amount: Deserialize::default(), + flat_amount_decimal: Deserialize::default(), + unit_amount: Deserialize::default(), + unit_amount_decimal: Deserialize::default(), + up_to: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let flat_amount = self.flat_amount.take()?; + let flat_amount_decimal = self.flat_amount_decimal.take()?; + let unit_amount = self.unit_amount.take()?; + let unit_amount_decimal = self.unit_amount_decimal.take()?; + let up_to = self.up_to.take()?; + + Some(Self::Out { flat_amount, flat_amount_decimal, unit_amount, unit_amount_decimal, up_to }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PlanTier { + type Builder = PlanTierBuilder; + } + + impl FromValueOpt for PlanTier { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PlanTierBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "flat_amount" => b.flat_amount = Some(FromValueOpt::from_value(v)?), + "flat_amount_decimal" => b.flat_amount_decimal = Some(FromValueOpt::from_value(v)?), + "unit_amount" => b.unit_amount = Some(FromValueOpt::from_value(v)?), + "unit_amount_decimal" => b.unit_amount_decimal = Some(FromValueOpt::from_value(v)?), + "up_to" => b.up_to = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/platform_tax_fee.rs b/generated/stripe_shared/src/platform_tax_fee.rs index 5a5bf46f5..4b8c79d1a 100644 --- a/generated/stripe_shared/src/platform_tax_fee.rs +++ b/generated/stripe_shared/src/platform_tax_fee.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PlatformTaxFee { /// The Connected account that incurred this charge. pub account: String, @@ -7,9 +9,107 @@ pub struct PlatformTaxFee { /// The payment object that caused this tax to be inflicted. pub source_transaction: String, /// The type of tax (VAT). - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, } +#[cfg(feature = "min-ser")] +pub struct PlatformTaxFeeBuilder { + account: Option<String>, + id: Option<stripe_shared::PlatformTaxFeeId>, + source_transaction: Option<String>, + type_: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PlatformTaxFee { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PlatformTaxFee>, + builder: PlatformTaxFeeBuilder, + } + + impl Visitor for Place<PlatformTaxFee> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PlatformTaxFeeBuilder::deser_default() })) + } + } + + impl MapBuilder for PlatformTaxFeeBuilder { + type Out = PlatformTaxFee; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "id" => Deserialize::begin(&mut self.id), + "source_transaction" => Deserialize::begin(&mut self.source_transaction), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account: Deserialize::default(), id: Deserialize::default(), source_transaction: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account = self.account.take()?; + let id = self.id.take()?; + let source_transaction = self.source_transaction.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { account, id, source_transaction, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PlatformTaxFee { + type Builder = PlatformTaxFeeBuilder; + } + + impl FromValueOpt for PlatformTaxFee { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PlatformTaxFeeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "source_transaction" => b.source_transaction = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for PlatformTaxFee { type Id = stripe_shared::PlatformTaxFeeId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/price.rs b/generated/stripe_shared/src/price.rs index 06397b4e6..15d138e50 100644 --- a/generated/stripe_shared/src/price.rs +++ b/generated/stripe_shared/src/price.rs @@ -8,7 +8,9 @@ /// Related guides: [Set up a subscription](https://stripe.com/docs/billing/subscriptions/set-up-subscription), [create an invoice](https://stripe.com/docs/billing/invoices/create), and more about [products and prices](https://stripe.com/docs/products-prices/overview). /// /// For more details see <<https://stripe.com/docs/api/prices/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Price { /// Whether the price can be used for new purchases. pub active: bool, @@ -24,9 +26,7 @@ pub struct Price { pub currency: stripe_types::Currency, /// Prices defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). - #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: - Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::CurrencyOption>>, + pub currency_options: Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::CurrencyOption>>, /// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. pub custom_unit_amount: Option<stripe_shared::CustomUnitAmount>, /// Unique identifier for the object. @@ -53,7 +53,6 @@ pub struct Price { /// Each element represents a pricing tier. /// This parameter requires `billing_scheme` to be set to `tiered`. /// See also the documentation for `billing_scheme`. - #[serde(skip_serializing_if = "Option::is_none")] pub tiers: Option<Vec<stripe_shared::PriceTier>>, /// Defines if the tiering price should be `graduated` or `volume` based. /// In `volume`-based tiering, the maximum quantity within a period determines the per unit price. @@ -63,7 +62,7 @@ pub struct Price { /// Cannot be combined with `tiers`. pub transform_quantity: Option<stripe_shared::TransformQuantity>, /// One of `one_time` or `recurring` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_shared::PriceType, /// The unit amount in cents (or local equivalent) to be charged, represented as a whole integer if possible. /// Only set if `billing_scheme=per_unit`. @@ -72,6 +71,210 @@ pub struct Price { /// Only set if `billing_scheme=per_unit`. pub unit_amount_decimal: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct PriceBuilder { + active: Option<bool>, + billing_scheme: Option<stripe_shared::PriceBillingScheme>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + currency_options: Option<Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::CurrencyOption>>>, + custom_unit_amount: Option<Option<stripe_shared::CustomUnitAmount>>, + id: Option<stripe_shared::PriceId>, + livemode: Option<bool>, + lookup_key: Option<Option<String>>, + metadata: Option<std::collections::HashMap<String, String>>, + nickname: Option<Option<String>>, + product: Option<stripe_types::Expandable<stripe_shared::Product>>, + recurring: Option<Option<stripe_shared::Recurring>>, + tax_behavior: Option<Option<stripe_shared::PriceTaxBehavior>>, + tiers: Option<Option<Vec<stripe_shared::PriceTier>>>, + tiers_mode: Option<Option<stripe_shared::PriceTiersMode>>, + transform_quantity: Option<Option<stripe_shared::TransformQuantity>>, + type_: Option<stripe_shared::PriceType>, + unit_amount: Option<Option<i64>>, + unit_amount_decimal: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Price { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Price>, + builder: PriceBuilder, + } + + impl Visitor for Place<Price> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PriceBuilder::deser_default() })) + } + } + + impl MapBuilder for PriceBuilder { + type Out = Price; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "billing_scheme" => Deserialize::begin(&mut self.billing_scheme), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "currency_options" => Deserialize::begin(&mut self.currency_options), + "custom_unit_amount" => Deserialize::begin(&mut self.custom_unit_amount), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "lookup_key" => Deserialize::begin(&mut self.lookup_key), + "metadata" => Deserialize::begin(&mut self.metadata), + "nickname" => Deserialize::begin(&mut self.nickname), + "product" => Deserialize::begin(&mut self.product), + "recurring" => Deserialize::begin(&mut self.recurring), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tiers" => Deserialize::begin(&mut self.tiers), + "tiers_mode" => Deserialize::begin(&mut self.tiers_mode), + "transform_quantity" => Deserialize::begin(&mut self.transform_quantity), + "type" => Deserialize::begin(&mut self.type_), + "unit_amount" => Deserialize::begin(&mut self.unit_amount), + "unit_amount_decimal" => Deserialize::begin(&mut self.unit_amount_decimal), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + billing_scheme: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + currency_options: Deserialize::default(), + custom_unit_amount: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + lookup_key: Deserialize::default(), + metadata: Deserialize::default(), + nickname: Deserialize::default(), + product: Deserialize::default(), + recurring: Deserialize::default(), + tax_behavior: Deserialize::default(), + tiers: Deserialize::default(), + tiers_mode: Deserialize::default(), + transform_quantity: Deserialize::default(), + type_: Deserialize::default(), + unit_amount: Deserialize::default(), + unit_amount_decimal: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let billing_scheme = self.billing_scheme.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let currency_options = self.currency_options.take()?; + let custom_unit_amount = self.custom_unit_amount.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let lookup_key = self.lookup_key.take()?; + let metadata = self.metadata.take()?; + let nickname = self.nickname.take()?; + let product = self.product.take()?; + let recurring = self.recurring.take()?; + let tax_behavior = self.tax_behavior.take()?; + let tiers = self.tiers.take()?; + let tiers_mode = self.tiers_mode.take()?; + let transform_quantity = self.transform_quantity.take()?; + let type_ = self.type_.take()?; + let unit_amount = self.unit_amount.take()?; + let unit_amount_decimal = self.unit_amount_decimal.take()?; + + Some(Self::Out { + active, + billing_scheme, + created, + currency, + currency_options, + custom_unit_amount, + id, + livemode, + lookup_key, + metadata, + nickname, + product, + recurring, + tax_behavior, + tiers, + tiers_mode, + transform_quantity, + type_, + unit_amount, + unit_amount_decimal, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Price { + type Builder = PriceBuilder; + } + + impl FromValueOpt for Price { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PriceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "billing_scheme" => b.billing_scheme = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "currency_options" => b.currency_options = Some(FromValueOpt::from_value(v)?), + "custom_unit_amount" => b.custom_unit_amount = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "lookup_key" => b.lookup_key = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "nickname" => b.nickname = Some(FromValueOpt::from_value(v)?), + "product" => b.product = Some(FromValueOpt::from_value(v)?), + "recurring" => b.recurring = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tiers" => b.tiers = Some(FromValueOpt::from_value(v)?), + "tiers_mode" => b.tiers_mode = Some(FromValueOpt::from_value(v)?), + "transform_quantity" => b.transform_quantity = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "unit_amount" => b.unit_amount = Some(FromValueOpt::from_value(v)?), + "unit_amount_decimal" => b.unit_amount_decimal = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Price { type Id = stripe_shared::PriceId; fn id(&self) -> &Self::Id { @@ -128,10 +331,27 @@ impl<'de> serde::Deserialize<'de> for PriceBillingScheme { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PriceBillingScheme")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PriceBillingScheme")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PriceBillingScheme { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PriceBillingScheme> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceBillingScheme::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PriceBillingScheme); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PriceTaxBehavior { Exclusive, @@ -184,10 +404,27 @@ impl<'de> serde::Deserialize<'de> for PriceTaxBehavior { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for PriceTaxBehavior")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PriceTaxBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PriceTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PriceTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PriceTaxBehavior); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PriceTiersMode { Graduated, @@ -240,6 +477,24 @@ impl<'de> serde::Deserialize<'de> for PriceTiersMode { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PriceTiersMode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PriceTiersMode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PriceTiersMode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceTiersMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PriceTiersMode); #[derive(Copy, Clone, Eq, PartialEq)] pub enum PriceType { OneTime, @@ -292,3 +547,21 @@ impl<'de> serde::Deserialize<'de> for PriceType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for PriceType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for PriceType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<PriceType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(PriceType); diff --git a/generated/stripe_shared/src/price_tier.rs b/generated/stripe_shared/src/price_tier.rs index 6cd47e0a1..8b9f13f93 100644 --- a/generated/stripe_shared/src/price_tier.rs +++ b/generated/stripe_shared/src/price_tier.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PriceTier { /// Price for the entire tier. pub flat_amount: Option<i64>, @@ -11,3 +13,111 @@ pub struct PriceTier { /// Up to and including to this quantity will be contained in the tier. pub up_to: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct PriceTierBuilder { + flat_amount: Option<Option<i64>>, + flat_amount_decimal: Option<Option<String>>, + unit_amount: Option<Option<i64>>, + unit_amount_decimal: Option<Option<String>>, + up_to: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PriceTier { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PriceTier>, + builder: PriceTierBuilder, + } + + impl Visitor for Place<PriceTier> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PriceTierBuilder::deser_default() })) + } + } + + impl MapBuilder for PriceTierBuilder { + type Out = PriceTier; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "flat_amount" => Deserialize::begin(&mut self.flat_amount), + "flat_amount_decimal" => Deserialize::begin(&mut self.flat_amount_decimal), + "unit_amount" => Deserialize::begin(&mut self.unit_amount), + "unit_amount_decimal" => Deserialize::begin(&mut self.unit_amount_decimal), + "up_to" => Deserialize::begin(&mut self.up_to), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + flat_amount: Deserialize::default(), + flat_amount_decimal: Deserialize::default(), + unit_amount: Deserialize::default(), + unit_amount_decimal: Deserialize::default(), + up_to: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let flat_amount = self.flat_amount.take()?; + let flat_amount_decimal = self.flat_amount_decimal.take()?; + let unit_amount = self.unit_amount.take()?; + let unit_amount_decimal = self.unit_amount_decimal.take()?; + let up_to = self.up_to.take()?; + + Some(Self::Out { flat_amount, flat_amount_decimal, unit_amount, unit_amount_decimal, up_to }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PriceTier { + type Builder = PriceTierBuilder; + } + + impl FromValueOpt for PriceTier { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PriceTierBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "flat_amount" => b.flat_amount = Some(FromValueOpt::from_value(v)?), + "flat_amount_decimal" => b.flat_amount_decimal = Some(FromValueOpt::from_value(v)?), + "unit_amount" => b.unit_amount = Some(FromValueOpt::from_value(v)?), + "unit_amount_decimal" => b.unit_amount_decimal = Some(FromValueOpt::from_value(v)?), + "up_to" => b.up_to = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/product.rs b/generated/stripe_shared/src/product.rs index fdf34a279..31795d5b7 100644 --- a/generated/stripe_shared/src/product.rs +++ b/generated/stripe_shared/src/product.rs @@ -8,14 +8,15 @@ /// and more about [Products and Prices](https://stripe.com/docs/products-prices/overview) /// /// For more details see <<https://stripe.com/docs/api/products/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Product { /// Whether the product is currently available for purchase. pub active: bool, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// The ID of the [Price](https://stripe.com/docs/api/prices) object that is the default price for this product. - #[serde(skip_serializing_if = "Option::is_none")] pub default_price: Option<stripe_types::Expandable<stripe_shared::Price>>, /// The product's description, meant to be displayable to the customer. /// Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. @@ -40,23 +41,213 @@ pub struct Product { pub shippable: Option<bool>, /// Extra information about a product which will appear on your customer's credit card statement. /// In the case that multiple products are billed at once, the first statement descriptor will be used. - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. pub tax_code: Option<stripe_types::Expandable<stripe_shared::TaxCode>>, /// The type of the product. /// The product is either of type `good`, which is eligible for use with Orders and SKUs, or `service`, which is eligible for use with Subscriptions and Plans. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_shared::ProductType, /// A label that represents units of this product. /// When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal. - #[serde(skip_serializing_if = "Option::is_none")] pub unit_label: Option<String>, /// Time at which the object was last updated. Measured in seconds since the Unix epoch. pub updated: stripe_types::Timestamp, /// A URL of a publicly-accessible webpage for this product. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct ProductBuilder { + active: Option<bool>, + created: Option<stripe_types::Timestamp>, + default_price: Option<Option<stripe_types::Expandable<stripe_shared::Price>>>, + description: Option<Option<String>>, + features: Option<Vec<stripe_shared::ProductFeature>>, + id: Option<stripe_shared::ProductId>, + images: Option<Vec<String>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + name: Option<String>, + package_dimensions: Option<Option<stripe_shared::PackageDimensions>>, + shippable: Option<Option<bool>>, + statement_descriptor: Option<Option<String>>, + tax_code: Option<Option<stripe_types::Expandable<stripe_shared::TaxCode>>>, + type_: Option<stripe_shared::ProductType>, + unit_label: Option<Option<String>>, + updated: Option<stripe_types::Timestamp>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Product { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Product>, + builder: ProductBuilder, + } + + impl Visitor for Place<Product> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ProductBuilder::deser_default() })) + } + } + + impl MapBuilder for ProductBuilder { + type Out = Product; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "created" => Deserialize::begin(&mut self.created), + "default_price" => Deserialize::begin(&mut self.default_price), + "description" => Deserialize::begin(&mut self.description), + "features" => Deserialize::begin(&mut self.features), + "id" => Deserialize::begin(&mut self.id), + "images" => Deserialize::begin(&mut self.images), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "name" => Deserialize::begin(&mut self.name), + "package_dimensions" => Deserialize::begin(&mut self.package_dimensions), + "shippable" => Deserialize::begin(&mut self.shippable), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "tax_code" => Deserialize::begin(&mut self.tax_code), + "type" => Deserialize::begin(&mut self.type_), + "unit_label" => Deserialize::begin(&mut self.unit_label), + "updated" => Deserialize::begin(&mut self.updated), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + created: Deserialize::default(), + default_price: Deserialize::default(), + description: Deserialize::default(), + features: Deserialize::default(), + id: Deserialize::default(), + images: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + name: Deserialize::default(), + package_dimensions: Deserialize::default(), + shippable: Deserialize::default(), + statement_descriptor: Deserialize::default(), + tax_code: Deserialize::default(), + type_: Deserialize::default(), + unit_label: Deserialize::default(), + updated: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let created = self.created.take()?; + let default_price = self.default_price.take()?; + let description = self.description.take()?; + let features = self.features.take()?; + let id = self.id.take()?; + let images = self.images.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let name = self.name.take()?; + let package_dimensions = self.package_dimensions.take()?; + let shippable = self.shippable.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let tax_code = self.tax_code.take()?; + let type_ = self.type_.take()?; + let unit_label = self.unit_label.take()?; + let updated = self.updated.take()?; + let url = self.url.take()?; + + Some(Self::Out { + active, + created, + default_price, + description, + features, + id, + images, + livemode, + metadata, + name, + package_dimensions, + shippable, + statement_descriptor, + tax_code, + type_, + unit_label, + updated, + url, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Product { + type Builder = ProductBuilder; + } + + impl FromValueOpt for Product { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ProductBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "default_price" => b.default_price = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "features" => b.features = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "images" => b.images = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "package_dimensions" => b.package_dimensions = Some(FromValueOpt::from_value(v)?), + "shippable" => b.shippable = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "tax_code" => b.tax_code = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "unit_label" => b.unit_label = Some(FromValueOpt::from_value(v)?), + "updated" => b.updated = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Product { type Id = stripe_shared::ProductId; fn id(&self) -> &Self::Id { @@ -116,3 +307,21 @@ impl<'de> serde::Deserialize<'de> for ProductType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ProductType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ProductType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ProductType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ProductType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ProductType); diff --git a/generated/stripe_shared/src/product_feature.rs b/generated/stripe_shared/src/product_feature.rs index 996e4221e..d006cfd92 100644 --- a/generated/stripe_shared/src/product_feature.rs +++ b/generated/stripe_shared/src/product_feature.rs @@ -1,6 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ProductFeature { /// The feature's name. Up to 80 characters long. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct ProductFeatureBuilder { + name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ProductFeature { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ProductFeature>, + builder: ProductFeatureBuilder, + } + + impl Visitor for Place<ProductFeature> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ProductFeatureBuilder::deser_default() })) + } + } + + impl MapBuilder for ProductFeatureBuilder { + type Out = ProductFeature; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "name" => Deserialize::begin(&mut self.name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let name = self.name.take()?; + + Some(Self::Out { name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ProductFeature { + type Builder = ProductFeatureBuilder; + } + + impl FromValueOpt for ProductFeature { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ProductFeatureBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "name" => b.name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/promotion_code.rs b/generated/stripe_shared/src/promotion_code.rs index 6ff340261..66a314fe1 100644 --- a/generated/stripe_shared/src/promotion_code.rs +++ b/generated/stripe_shared/src/promotion_code.rs @@ -3,7 +3,9 @@ /// create multiple codes for a single coupon. /// /// For more details see <<https://stripe.com/docs/api/promotion_codes/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PromotionCode { /// Whether the promotion code is currently active. /// A promotion code is only active if the coupon is also valid. @@ -31,6 +33,149 @@ pub struct PromotionCode { /// Number of times this promotion code has been used. pub times_redeemed: i64, } +#[cfg(feature = "min-ser")] +pub struct PromotionCodeBuilder { + active: Option<bool>, + code: Option<String>, + coupon: Option<stripe_shared::Coupon>, + created: Option<stripe_types::Timestamp>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + expires_at: Option<Option<stripe_types::Timestamp>>, + id: Option<stripe_shared::PromotionCodeId>, + livemode: Option<bool>, + max_redemptions: Option<Option<i64>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + restrictions: Option<stripe_shared::PromotionCodesResourceRestrictions>, + times_redeemed: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PromotionCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PromotionCode>, + builder: PromotionCodeBuilder, + } + + impl Visitor for Place<PromotionCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PromotionCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for PromotionCodeBuilder { + type Out = PromotionCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "code" => Deserialize::begin(&mut self.code), + "coupon" => Deserialize::begin(&mut self.coupon), + "created" => Deserialize::begin(&mut self.created), + "customer" => Deserialize::begin(&mut self.customer), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "max_redemptions" => Deserialize::begin(&mut self.max_redemptions), + "metadata" => Deserialize::begin(&mut self.metadata), + "restrictions" => Deserialize::begin(&mut self.restrictions), + "times_redeemed" => Deserialize::begin(&mut self.times_redeemed), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + code: Deserialize::default(), + coupon: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + expires_at: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + max_redemptions: Deserialize::default(), + metadata: Deserialize::default(), + restrictions: Deserialize::default(), + times_redeemed: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let code = self.code.take()?; + let coupon = self.coupon.take()?; + let created = self.created.take()?; + let customer = self.customer.take()?; + let expires_at = self.expires_at.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let max_redemptions = self.max_redemptions.take()?; + let metadata = self.metadata.take()?; + let restrictions = self.restrictions.take()?; + let times_redeemed = self.times_redeemed.take()?; + + Some(Self::Out { active, code, coupon, created, customer, expires_at, id, livemode, max_redemptions, metadata, restrictions, times_redeemed }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PromotionCode { + type Builder = PromotionCodeBuilder; + } + + impl FromValueOpt for PromotionCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PromotionCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "coupon" => b.coupon = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "max_redemptions" => b.max_redemptions = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "restrictions" => b.restrictions = Some(FromValueOpt::from_value(v)?), + "times_redeemed" => b.times_redeemed = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for PromotionCode { type Id = stripe_shared::PromotionCodeId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/promotion_code_currency_option.rs b/generated/stripe_shared/src/promotion_code_currency_option.rs index 87758d03e..9f91f3cb5 100644 --- a/generated/stripe_shared/src/promotion_code_currency_option.rs +++ b/generated/stripe_shared/src/promotion_code_currency_option.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PromotionCodeCurrencyOption { /// Minimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work). pub minimum_amount: i64, } +#[cfg(feature = "min-ser")] +pub struct PromotionCodeCurrencyOptionBuilder { + minimum_amount: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PromotionCodeCurrencyOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PromotionCodeCurrencyOption>, + builder: PromotionCodeCurrencyOptionBuilder, + } + + impl Visitor for Place<PromotionCodeCurrencyOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PromotionCodeCurrencyOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for PromotionCodeCurrencyOptionBuilder { + type Out = PromotionCodeCurrencyOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "minimum_amount" => Deserialize::begin(&mut self.minimum_amount), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { minimum_amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let minimum_amount = self.minimum_amount.take()?; + + Some(Self::Out { minimum_amount }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PromotionCodeCurrencyOption { + type Builder = PromotionCodeCurrencyOptionBuilder; + } + + impl FromValueOpt for PromotionCodeCurrencyOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PromotionCodeCurrencyOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "minimum_amount" => b.minimum_amount = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/promotion_codes_resource_restrictions.rs b/generated/stripe_shared/src/promotion_codes_resource_restrictions.rs index 659e71f8d..1097e62d2 100644 --- a/generated/stripe_shared/src/promotion_codes_resource_restrictions.rs +++ b/generated/stripe_shared/src/promotion_codes_resource_restrictions.rs @@ -1,14 +1,10 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct PromotionCodesResourceRestrictions { /// Promotion code restrictions defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). - #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - std::collections::HashMap< - stripe_types::Currency, - stripe_shared::PromotionCodeCurrencyOption, - >, - >, + pub currency_options: Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::PromotionCodeCurrencyOption>>, /// A Boolean indicating if the Promotion Code should only be redeemed for Customers without any successful payments or invoices. pub first_time_transaction: bool, /// Minimum amount required to redeem this Promotion Code into a Coupon (e.g., a purchase must be $100 or more to work). @@ -16,3 +12,101 @@ pub struct PromotionCodesResourceRestrictions { /// Three-letter [ISO code](https://stripe.com/docs/currencies) for minimum_amount pub minimum_amount_currency: Option<stripe_types::Currency>, } +#[cfg(feature = "min-ser")] +pub struct PromotionCodesResourceRestrictionsBuilder { + currency_options: Option<Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::PromotionCodeCurrencyOption>>>, + first_time_transaction: Option<bool>, + minimum_amount: Option<Option<i64>>, + minimum_amount_currency: Option<Option<stripe_types::Currency>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PromotionCodesResourceRestrictions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<PromotionCodesResourceRestrictions>, + builder: PromotionCodesResourceRestrictionsBuilder, + } + + impl Visitor for Place<PromotionCodesResourceRestrictions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: PromotionCodesResourceRestrictionsBuilder::deser_default() })) + } + } + + impl MapBuilder for PromotionCodesResourceRestrictionsBuilder { + type Out = PromotionCodesResourceRestrictions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "currency_options" => Deserialize::begin(&mut self.currency_options), + "first_time_transaction" => Deserialize::begin(&mut self.first_time_transaction), + "minimum_amount" => Deserialize::begin(&mut self.minimum_amount), + "minimum_amount_currency" => Deserialize::begin(&mut self.minimum_amount_currency), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { currency_options: Deserialize::default(), first_time_transaction: Deserialize::default(), minimum_amount: Deserialize::default(), minimum_amount_currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let currency_options = self.currency_options.take()?; + let first_time_transaction = self.first_time_transaction.take()?; + let minimum_amount = self.minimum_amount.take()?; + let minimum_amount_currency = self.minimum_amount_currency.take()?; + + Some(Self::Out { currency_options, first_time_transaction, minimum_amount, minimum_amount_currency }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PromotionCodesResourceRestrictions { + type Builder = PromotionCodesResourceRestrictionsBuilder; + } + + impl FromValueOpt for PromotionCodesResourceRestrictions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PromotionCodesResourceRestrictionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "currency_options" => b.currency_options = Some(FromValueOpt::from_value(v)?), + "first_time_transaction" => b.first_time_transaction = Some(FromValueOpt::from_value(v)?), + "minimum_amount" => b.minimum_amount = Some(FromValueOpt::from_value(v)?), + "minimum_amount_currency" => b.minimum_amount_currency = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quote.rs b/generated/stripe_shared/src/quote.rs index 2ce2d8397..3975e48a3 100644 --- a/generated/stripe_shared/src/quote.rs +++ b/generated/stripe_shared/src/quote.rs @@ -2,7 +2,9 @@ /// Once accepted, it will automatically create an invoice, subscription or subscription schedule. /// /// For more details see <<https://stripe.com/docs/api/quotes/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Quote { /// Total before any discounts or taxes are applied. pub amount_subtotal: i64, @@ -34,7 +36,6 @@ pub struct Quote { /// Once specified, it cannot be changed. pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, /// The tax rates applied to this quote. - #[serde(skip_serializing_if = "Option::is_none")] pub default_tax_rates: Option<Vec<stripe_types::Expandable<stripe_shared::TaxRate>>>, /// A description that will be displayed on the quote PDF. pub description: Option<String>, @@ -54,9 +55,9 @@ pub struct Quote { pub id: stripe_shared::QuoteId, /// The invoice that was created from this quote. pub invoice: Option<stripe_types::Expandable<stripe_shared::Invoice>>, - pub invoice_settings: stripe_shared::InvoiceSettingQuoteSetting, + /// All invoices will be billed using the specified settings. + pub invoice_settings: Option<stripe_shared::InvoiceSettingQuoteSetting>, /// A list of items the customer is being quoted for. - #[serde(skip_serializing_if = "Option::is_none")] pub line_items: Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, @@ -76,14 +77,301 @@ pub struct Quote { pub subscription: Option<stripe_types::Expandable<stripe_shared::Subscription>>, pub subscription_data: stripe_shared::QuotesResourceSubscriptionDataSubscriptionData, /// The subscription schedule that was created or updated from this quote. - pub subscription_schedule: - Option<stripe_types::Expandable<stripe_shared::SubscriptionSchedule>>, + pub subscription_schedule: Option<stripe_types::Expandable<stripe_shared::SubscriptionSchedule>>, /// ID of the test clock this quote belongs to. pub test_clock: Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>, pub total_details: stripe_shared::QuotesResourceTotalDetails, /// The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the invoices. pub transfer_data: Option<stripe_shared::QuotesResourceTransferData>, } +#[cfg(feature = "min-ser")] +pub struct QuoteBuilder { + amount_subtotal: Option<i64>, + amount_total: Option<i64>, + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + application_fee_amount: Option<Option<i64>>, + application_fee_percent: Option<Option<f64>>, + automatic_tax: Option<stripe_shared::QuotesResourceAutomaticTax>, + collection_method: Option<stripe_shared::QuoteCollectionMethod>, + computed: Option<stripe_shared::QuotesResourceComputed>, + created: Option<stripe_types::Timestamp>, + currency: Option<Option<stripe_types::Currency>>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + default_tax_rates: Option<Option<Vec<stripe_types::Expandable<stripe_shared::TaxRate>>>>, + description: Option<Option<String>>, + discounts: Option<Vec<stripe_types::Expandable<stripe_shared::Discount>>>, + expires_at: Option<stripe_types::Timestamp>, + footer: Option<Option<String>>, + from_quote: Option<Option<stripe_shared::QuotesResourceFromQuote>>, + header: Option<Option<String>>, + id: Option<stripe_shared::QuoteId>, + invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + invoice_settings: Option<Option<stripe_shared::InvoiceSettingQuoteSetting>>, + line_items: Option<Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + number: Option<Option<String>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + status: Option<stripe_shared::QuoteStatus>, + status_transitions: Option<stripe_shared::QuotesResourceStatusTransitions>, + subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>, + subscription_data: Option<stripe_shared::QuotesResourceSubscriptionDataSubscriptionData>, + subscription_schedule: Option<Option<stripe_types::Expandable<stripe_shared::SubscriptionSchedule>>>, + test_clock: Option<Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>>, + total_details: Option<stripe_shared::QuotesResourceTotalDetails>, + transfer_data: Option<Option<stripe_shared::QuotesResourceTransferData>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Quote { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Quote>, + builder: QuoteBuilder, + } + + impl Visitor for Place<Quote> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuoteBuilder::deser_default() })) + } + } + + impl MapBuilder for QuoteBuilder { + type Out = Quote; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "application" => Deserialize::begin(&mut self.application), + "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount), + "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent), + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "collection_method" => Deserialize::begin(&mut self.collection_method), + "computed" => Deserialize::begin(&mut self.computed), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "default_tax_rates" => Deserialize::begin(&mut self.default_tax_rates), + "description" => Deserialize::begin(&mut self.description), + "discounts" => Deserialize::begin(&mut self.discounts), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "footer" => Deserialize::begin(&mut self.footer), + "from_quote" => Deserialize::begin(&mut self.from_quote), + "header" => Deserialize::begin(&mut self.header), + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "invoice_settings" => Deserialize::begin(&mut self.invoice_settings), + "line_items" => Deserialize::begin(&mut self.line_items), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "number" => Deserialize::begin(&mut self.number), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "subscription" => Deserialize::begin(&mut self.subscription), + "subscription_data" => Deserialize::begin(&mut self.subscription_data), + "subscription_schedule" => Deserialize::begin(&mut self.subscription_schedule), + "test_clock" => Deserialize::begin(&mut self.test_clock), + "total_details" => Deserialize::begin(&mut self.total_details), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_subtotal: Deserialize::default(), + amount_total: Deserialize::default(), + application: Deserialize::default(), + application_fee_amount: Deserialize::default(), + application_fee_percent: Deserialize::default(), + automatic_tax: Deserialize::default(), + collection_method: Deserialize::default(), + computed: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + default_tax_rates: Deserialize::default(), + description: Deserialize::default(), + discounts: Deserialize::default(), + expires_at: Deserialize::default(), + footer: Deserialize::default(), + from_quote: Deserialize::default(), + header: Deserialize::default(), + id: Deserialize::default(), + invoice: Deserialize::default(), + invoice_settings: Deserialize::default(), + line_items: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + number: Deserialize::default(), + on_behalf_of: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + subscription: Deserialize::default(), + subscription_data: Deserialize::default(), + subscription_schedule: Deserialize::default(), + test_clock: Deserialize::default(), + total_details: Deserialize::default(), + transfer_data: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_subtotal = self.amount_subtotal.take()?; + let amount_total = self.amount_total.take()?; + let application = self.application.take()?; + let application_fee_amount = self.application_fee_amount.take()?; + let application_fee_percent = self.application_fee_percent.take()?; + let automatic_tax = self.automatic_tax.take()?; + let collection_method = self.collection_method.take()?; + let computed = self.computed.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let default_tax_rates = self.default_tax_rates.take()?; + let description = self.description.take()?; + let discounts = self.discounts.take()?; + let expires_at = self.expires_at.take()?; + let footer = self.footer.take()?; + let from_quote = self.from_quote.take()?; + let header = self.header.take()?; + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let invoice_settings = self.invoice_settings.take()?; + let line_items = self.line_items.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let number = self.number.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + let subscription = self.subscription.take()?; + let subscription_data = self.subscription_data.take()?; + let subscription_schedule = self.subscription_schedule.take()?; + let test_clock = self.test_clock.take()?; + let total_details = self.total_details.take()?; + let transfer_data = self.transfer_data.take()?; + + Some(Self::Out { + amount_subtotal, + amount_total, + application, + application_fee_amount, + application_fee_percent, + automatic_tax, + collection_method, + computed, + created, + currency, + customer, + default_tax_rates, + description, + discounts, + expires_at, + footer, + from_quote, + header, + id, + invoice, + invoice_settings, + line_items, + livemode, + metadata, + number, + on_behalf_of, + status, + status_transitions, + subscription, + subscription_data, + subscription_schedule, + test_clock, + total_details, + transfer_data, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Quote { + type Builder = QuoteBuilder; + } + + impl FromValueOpt for Quote { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuoteBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "application_fee_amount" => b.application_fee_amount = Some(FromValueOpt::from_value(v)?), + "application_fee_percent" => b.application_fee_percent = Some(FromValueOpt::from_value(v)?), + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "collection_method" => b.collection_method = Some(FromValueOpt::from_value(v)?), + "computed" => b.computed = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "default_tax_rates" => b.default_tax_rates = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "footer" => b.footer = Some(FromValueOpt::from_value(v)?), + "from_quote" => b.from_quote = Some(FromValueOpt::from_value(v)?), + "header" => b.header = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "invoice_settings" => b.invoice_settings = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "number" => b.number = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + "subscription_data" => b.subscription_data = Some(FromValueOpt::from_value(v)?), + "subscription_schedule" => b.subscription_schedule = Some(FromValueOpt::from_value(v)?), + "test_clock" => b.test_clock = Some(FromValueOpt::from_value(v)?), + "total_details" => b.total_details = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Quote { type Id = stripe_shared::QuoteId; fn id(&self) -> &Self::Id { @@ -140,10 +428,27 @@ impl<'de> serde::Deserialize<'de> for QuoteCollectionMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for QuoteCollectionMethod")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for QuoteCollectionMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for QuoteCollectionMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<QuoteCollectionMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(QuoteCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(QuoteCollectionMethod); #[derive(Copy, Clone, Eq, PartialEq)] pub enum QuoteStatus { Accepted, @@ -202,3 +507,21 @@ impl<'de> serde::Deserialize<'de> for QuoteStatus { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for QuoteStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for QuoteStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<QuoteStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(QuoteStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(QuoteStatus); diff --git a/generated/stripe_shared/src/quotes_resource_automatic_tax.rs b/generated/stripe_shared/src/quotes_resource_automatic_tax.rs index 4b16b7111..e41c1a10f 100644 --- a/generated/stripe_shared/src/quotes_resource_automatic_tax.rs +++ b/generated/stripe_shared/src/quotes_resource_automatic_tax.rs @@ -1,14 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceAutomaticTax { /// Automatically calculate taxes pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - pub liability: Option<stripe_shared::ConnectAccountReference>, /// The status of the most recent automated tax calculation for this quote. pub status: Option<QuotesResourceAutomaticTaxStatus>, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceAutomaticTaxBuilder { + enabled: Option<bool>, + status: Option<Option<QuotesResourceAutomaticTaxStatus>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceAutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceAutomaticTax>, + builder: QuotesResourceAutomaticTaxBuilder, + } + + impl Visitor for Place<QuotesResourceAutomaticTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceAutomaticTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceAutomaticTaxBuilder { + type Out = QuotesResourceAutomaticTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + let status = self.status.take()?; + + Some(Self::Out { enabled, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceAutomaticTax { + type Builder = QuotesResourceAutomaticTaxBuilder; + } + + impl FromValueOpt for QuotesResourceAutomaticTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceAutomaticTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the most recent automated tax calculation for this quote. #[derive(Copy, Clone, Eq, PartialEq)] pub enum QuotesResourceAutomaticTaxStatus { @@ -62,8 +150,24 @@ impl<'de> serde::Deserialize<'de> for QuotesResourceAutomaticTaxStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for QuotesResourceAutomaticTaxStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for QuotesResourceAutomaticTaxStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for QuotesResourceAutomaticTaxStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<QuotesResourceAutomaticTaxStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(QuotesResourceAutomaticTaxStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(QuotesResourceAutomaticTaxStatus); diff --git a/generated/stripe_shared/src/quotes_resource_computed.rs b/generated/stripe_shared/src/quotes_resource_computed.rs index 45192eec7..b5632d40c 100644 --- a/generated/stripe_shared/src/quotes_resource_computed.rs +++ b/generated/stripe_shared/src/quotes_resource_computed.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceComputed { /// The definitive totals and line items the customer will be charged on a recurring basis. /// Takes into account the line items with recurring prices and discounts with `duration=forever` coupons only. @@ -6,3 +8,93 @@ pub struct QuotesResourceComputed { pub recurring: Option<stripe_shared::QuotesResourceRecurring>, pub upfront: stripe_shared::QuotesResourceUpfront, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceComputedBuilder { + recurring: Option<Option<stripe_shared::QuotesResourceRecurring>>, + upfront: Option<stripe_shared::QuotesResourceUpfront>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceComputed { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceComputed>, + builder: QuotesResourceComputedBuilder, + } + + impl Visitor for Place<QuotesResourceComputed> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceComputedBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceComputedBuilder { + type Out = QuotesResourceComputed; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "recurring" => Deserialize::begin(&mut self.recurring), + "upfront" => Deserialize::begin(&mut self.upfront), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { recurring: Deserialize::default(), upfront: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let recurring = self.recurring.take()?; + let upfront = self.upfront.take()?; + + Some(Self::Out { recurring, upfront }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceComputed { + type Builder = QuotesResourceComputedBuilder; + } + + impl FromValueOpt for QuotesResourceComputed { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceComputedBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "recurring" => b.recurring = Some(FromValueOpt::from_value(v)?), + "upfront" => b.upfront = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quotes_resource_from_quote.rs b/generated/stripe_shared/src/quotes_resource_from_quote.rs index f2253f47b..fa0be2ae9 100644 --- a/generated/stripe_shared/src/quotes_resource_from_quote.rs +++ b/generated/stripe_shared/src/quotes_resource_from_quote.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceFromQuote { /// Whether this quote is a revision of a different quote. pub is_revision: bool, /// The quote that was cloned. pub quote: stripe_types::Expandable<stripe_shared::Quote>, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceFromQuoteBuilder { + is_revision: Option<bool>, + quote: Option<stripe_types::Expandable<stripe_shared::Quote>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceFromQuote { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceFromQuote>, + builder: QuotesResourceFromQuoteBuilder, + } + + impl Visitor for Place<QuotesResourceFromQuote> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceFromQuoteBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceFromQuoteBuilder { + type Out = QuotesResourceFromQuote; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "is_revision" => Deserialize::begin(&mut self.is_revision), + "quote" => Deserialize::begin(&mut self.quote), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { is_revision: Deserialize::default(), quote: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let is_revision = self.is_revision.take()?; + let quote = self.quote.take()?; + + Some(Self::Out { is_revision, quote }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceFromQuote { + type Builder = QuotesResourceFromQuoteBuilder; + } + + impl FromValueOpt for QuotesResourceFromQuote { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceFromQuoteBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "is_revision" => b.is_revision = Some(FromValueOpt::from_value(v)?), + "quote" => b.quote = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quotes_resource_recurring.rs b/generated/stripe_shared/src/quotes_resource_recurring.rs index 981f9dbff..41d98d170 100644 --- a/generated/stripe_shared/src/quotes_resource_recurring.rs +++ b/generated/stripe_shared/src/quotes_resource_recurring.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceRecurring { /// Total before any discounts or taxes are applied. pub amount_subtotal: i64, @@ -11,6 +13,114 @@ pub struct QuotesResourceRecurring { pub interval_count: u64, pub total_details: stripe_shared::QuotesResourceTotalDetails, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceRecurringBuilder { + amount_subtotal: Option<i64>, + amount_total: Option<i64>, + interval: Option<QuotesResourceRecurringInterval>, + interval_count: Option<u64>, + total_details: Option<stripe_shared::QuotesResourceTotalDetails>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceRecurring { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceRecurring>, + builder: QuotesResourceRecurringBuilder, + } + + impl Visitor for Place<QuotesResourceRecurring> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceRecurringBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceRecurringBuilder { + type Out = QuotesResourceRecurring; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "interval" => Deserialize::begin(&mut self.interval), + "interval_count" => Deserialize::begin(&mut self.interval_count), + "total_details" => Deserialize::begin(&mut self.total_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_subtotal: Deserialize::default(), + amount_total: Deserialize::default(), + interval: Deserialize::default(), + interval_count: Deserialize::default(), + total_details: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_subtotal = self.amount_subtotal.take()?; + let amount_total = self.amount_total.take()?; + let interval = self.interval.take()?; + let interval_count = self.interval_count.take()?; + let total_details = self.total_details.take()?; + + Some(Self::Out { amount_subtotal, amount_total, interval, interval_count, total_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceRecurring { + type Builder = QuotesResourceRecurringBuilder; + } + + impl FromValueOpt for QuotesResourceRecurring { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceRecurringBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "interval_count" => b.interval_count = Some(FromValueOpt::from_value(v)?), + "total_details" => b.total_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum QuotesResourceRecurringInterval { @@ -67,8 +177,24 @@ impl<'de> serde::Deserialize<'de> for QuotesResourceRecurringInterval { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for QuotesResourceRecurringInterval") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for QuotesResourceRecurringInterval")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for QuotesResourceRecurringInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<QuotesResourceRecurringInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(QuotesResourceRecurringInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(QuotesResourceRecurringInterval); diff --git a/generated/stripe_shared/src/quotes_resource_status_transitions.rs b/generated/stripe_shared/src/quotes_resource_status_transitions.rs index 2e7f6345c..324b1dbab 100644 --- a/generated/stripe_shared/src/quotes_resource_status_transitions.rs +++ b/generated/stripe_shared/src/quotes_resource_status_transitions.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceStatusTransitions { /// The time that the quote was accepted. Measured in seconds since Unix epoch. pub accepted_at: Option<stripe_types::Timestamp>, @@ -7,3 +9,97 @@ pub struct QuotesResourceStatusTransitions { /// The time that the quote was finalized. Measured in seconds since Unix epoch. pub finalized_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceStatusTransitionsBuilder { + accepted_at: Option<Option<stripe_types::Timestamp>>, + canceled_at: Option<Option<stripe_types::Timestamp>>, + finalized_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceStatusTransitions>, + builder: QuotesResourceStatusTransitionsBuilder, + } + + impl Visitor for Place<QuotesResourceStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceStatusTransitionsBuilder { + type Out = QuotesResourceStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "accepted_at" => Deserialize::begin(&mut self.accepted_at), + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "finalized_at" => Deserialize::begin(&mut self.finalized_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { accepted_at: Deserialize::default(), canceled_at: Deserialize::default(), finalized_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let accepted_at = self.accepted_at.take()?; + let canceled_at = self.canceled_at.take()?; + let finalized_at = self.finalized_at.take()?; + + Some(Self::Out { accepted_at, canceled_at, finalized_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceStatusTransitions { + type Builder = QuotesResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for QuotesResourceStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "accepted_at" => b.accepted_at = Some(FromValueOpt::from_value(v)?), + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "finalized_at" => b.finalized_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quotes_resource_subscription_data_subscription_data.rs b/generated/stripe_shared/src/quotes_resource_subscription_data_subscription_data.rs index 04e6bc883..253aa6fd9 100644 --- a/generated/stripe_shared/src/quotes_resource_subscription_data_subscription_data.rs +++ b/generated/stripe_shared/src/quotes_resource_subscription_data_subscription_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceSubscriptionDataSubscriptionData { /// The subscription's description, meant to be displayable to the customer. /// Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs. @@ -16,3 +18,101 @@ pub struct QuotesResourceSubscriptionDataSubscriptionData { /// Integer representing the number of trial period days before the customer is charged for the first time. pub trial_period_days: Option<u32>, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceSubscriptionDataSubscriptionDataBuilder { + description: Option<Option<String>>, + effective_date: Option<Option<stripe_types::Timestamp>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + trial_period_days: Option<Option<u32>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceSubscriptionDataSubscriptionData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceSubscriptionDataSubscriptionData>, + builder: QuotesResourceSubscriptionDataSubscriptionDataBuilder, + } + + impl Visitor for Place<QuotesResourceSubscriptionDataSubscriptionData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceSubscriptionDataSubscriptionDataBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceSubscriptionDataSubscriptionDataBuilder { + type Out = QuotesResourceSubscriptionDataSubscriptionData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "description" => Deserialize::begin(&mut self.description), + "effective_date" => Deserialize::begin(&mut self.effective_date), + "metadata" => Deserialize::begin(&mut self.metadata), + "trial_period_days" => Deserialize::begin(&mut self.trial_period_days), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { description: Deserialize::default(), effective_date: Deserialize::default(), metadata: Deserialize::default(), trial_period_days: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let description = self.description.take()?; + let effective_date = self.effective_date.take()?; + let metadata = self.metadata.take()?; + let trial_period_days = self.trial_period_days.take()?; + + Some(Self::Out { description, effective_date, metadata, trial_period_days }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceSubscriptionDataSubscriptionData { + type Builder = QuotesResourceSubscriptionDataSubscriptionDataBuilder; + } + + impl FromValueOpt for QuotesResourceSubscriptionDataSubscriptionData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceSubscriptionDataSubscriptionDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "effective_date" => b.effective_date = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "trial_period_days" => b.trial_period_days = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quotes_resource_total_details.rs b/generated/stripe_shared/src/quotes_resource_total_details.rs index d3b364928..f1733ec9f 100644 --- a/generated/stripe_shared/src/quotes_resource_total_details.rs +++ b/generated/stripe_shared/src/quotes_resource_total_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceTotalDetails { /// This is the sum of all the discounts. pub amount_discount: i64, @@ -6,6 +8,103 @@ pub struct QuotesResourceTotalDetails { pub amount_shipping: Option<i64>, /// This is the sum of all the tax amounts. pub amount_tax: i64, - #[serde(skip_serializing_if = "Option::is_none")] pub breakdown: Option<stripe_shared::QuotesResourceTotalDetailsResourceBreakdown>, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceTotalDetailsBuilder { + amount_discount: Option<i64>, + amount_shipping: Option<Option<i64>>, + amount_tax: Option<i64>, + breakdown: Option<Option<stripe_shared::QuotesResourceTotalDetailsResourceBreakdown>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceTotalDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceTotalDetails>, + builder: QuotesResourceTotalDetailsBuilder, + } + + impl Visitor for Place<QuotesResourceTotalDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceTotalDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceTotalDetailsBuilder { + type Out = QuotesResourceTotalDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_discount" => Deserialize::begin(&mut self.amount_discount), + "amount_shipping" => Deserialize::begin(&mut self.amount_shipping), + "amount_tax" => Deserialize::begin(&mut self.amount_tax), + "breakdown" => Deserialize::begin(&mut self.breakdown), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_discount: Deserialize::default(), amount_shipping: Deserialize::default(), amount_tax: Deserialize::default(), breakdown: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_discount = self.amount_discount.take()?; + let amount_shipping = self.amount_shipping.take()?; + let amount_tax = self.amount_tax.take()?; + let breakdown = self.breakdown.take()?; + + Some(Self::Out { amount_discount, amount_shipping, amount_tax, breakdown }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceTotalDetails { + type Builder = QuotesResourceTotalDetailsBuilder; + } + + impl FromValueOpt for QuotesResourceTotalDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceTotalDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_discount" => b.amount_discount = Some(FromValueOpt::from_value(v)?), + "amount_shipping" => b.amount_shipping = Some(FromValueOpt::from_value(v)?), + "amount_tax" => b.amount_tax = Some(FromValueOpt::from_value(v)?), + "breakdown" => b.breakdown = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quotes_resource_total_details_resource_breakdown.rs b/generated/stripe_shared/src/quotes_resource_total_details_resource_breakdown.rs index 70202709b..0af732d77 100644 --- a/generated/stripe_shared/src/quotes_resource_total_details_resource_breakdown.rs +++ b/generated/stripe_shared/src/quotes_resource_total_details_resource_breakdown.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceTotalDetailsResourceBreakdown { /// The aggregated discounts. pub discounts: Vec<stripe_shared::LineItemsDiscountAmount>, /// The aggregated tax amounts by rate. pub taxes: Vec<stripe_shared::LineItemsTaxAmount>, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceTotalDetailsResourceBreakdownBuilder { + discounts: Option<Vec<stripe_shared::LineItemsDiscountAmount>>, + taxes: Option<Vec<stripe_shared::LineItemsTaxAmount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceTotalDetailsResourceBreakdown { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceTotalDetailsResourceBreakdown>, + builder: QuotesResourceTotalDetailsResourceBreakdownBuilder, + } + + impl Visitor for Place<QuotesResourceTotalDetailsResourceBreakdown> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceTotalDetailsResourceBreakdownBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceTotalDetailsResourceBreakdownBuilder { + type Out = QuotesResourceTotalDetailsResourceBreakdown; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "discounts" => Deserialize::begin(&mut self.discounts), + "taxes" => Deserialize::begin(&mut self.taxes), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { discounts: Deserialize::default(), taxes: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let discounts = self.discounts.take()?; + let taxes = self.taxes.take()?; + + Some(Self::Out { discounts, taxes }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceTotalDetailsResourceBreakdown { + type Builder = QuotesResourceTotalDetailsResourceBreakdownBuilder; + } + + impl FromValueOpt for QuotesResourceTotalDetailsResourceBreakdown { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceTotalDetailsResourceBreakdownBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "discounts" => b.discounts = Some(FromValueOpt::from_value(v)?), + "taxes" => b.taxes = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quotes_resource_transfer_data.rs b/generated/stripe_shared/src/quotes_resource_transfer_data.rs index 929567c19..d4787aeeb 100644 --- a/generated/stripe_shared/src/quotes_resource_transfer_data.rs +++ b/generated/stripe_shared/src/quotes_resource_transfer_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceTransferData { /// The amount in cents (or local equivalent) that will be transferred to the destination account when the invoice is paid. /// By default, the entire amount is transferred to the destination. @@ -10,3 +12,97 @@ pub struct QuotesResourceTransferData { /// The account where funds from the payment will be transferred to upon payment success. pub destination: stripe_types::Expandable<stripe_shared::Account>, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceTransferDataBuilder { + amount: Option<Option<i64>>, + amount_percent: Option<Option<f64>>, + destination: Option<stripe_types::Expandable<stripe_shared::Account>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceTransferData>, + builder: QuotesResourceTransferDataBuilder, + } + + impl Visitor for Place<QuotesResourceTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceTransferDataBuilder { + type Out = QuotesResourceTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_percent" => Deserialize::begin(&mut self.amount_percent), + "destination" => Deserialize::begin(&mut self.destination), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), amount_percent: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_percent = self.amount_percent.take()?; + let destination = self.destination.take()?; + + Some(Self::Out { amount, amount_percent, destination }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceTransferData { + type Builder = QuotesResourceTransferDataBuilder; + } + + impl FromValueOpt for QuotesResourceTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_percent" => b.amount_percent = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/quotes_resource_upfront.rs b/generated/stripe_shared/src/quotes_resource_upfront.rs index efed07033..592cdf5d6 100644 --- a/generated/stripe_shared/src/quotes_resource_upfront.rs +++ b/generated/stripe_shared/src/quotes_resource_upfront.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct QuotesResourceUpfront { /// Total before any discounts or taxes are applied. pub amount_subtotal: i64, @@ -6,7 +8,104 @@ pub struct QuotesResourceUpfront { pub amount_total: i64, /// The line items that will appear on the next invoice after this quote is accepted. /// This does not include pending invoice items that exist on the customer but may still be included in the next invoice. - #[serde(skip_serializing_if = "Option::is_none")] pub line_items: Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>, pub total_details: stripe_shared::QuotesResourceTotalDetails, } +#[cfg(feature = "min-ser")] +pub struct QuotesResourceUpfrontBuilder { + amount_subtotal: Option<i64>, + amount_total: Option<i64>, + line_items: Option<Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>>, + total_details: Option<stripe_shared::QuotesResourceTotalDetails>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for QuotesResourceUpfront { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<QuotesResourceUpfront>, + builder: QuotesResourceUpfrontBuilder, + } + + impl Visitor for Place<QuotesResourceUpfront> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: QuotesResourceUpfrontBuilder::deser_default() })) + } + } + + impl MapBuilder for QuotesResourceUpfrontBuilder { + type Out = QuotesResourceUpfront; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "line_items" => Deserialize::begin(&mut self.line_items), + "total_details" => Deserialize::begin(&mut self.total_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_subtotal: Deserialize::default(), amount_total: Deserialize::default(), line_items: Deserialize::default(), total_details: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_subtotal = self.amount_subtotal.take()?; + let amount_total = self.amount_total.take()?; + let line_items = self.line_items.take()?; + let total_details = self.total_details.take()?; + + Some(Self::Out { amount_subtotal, amount_total, line_items, total_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for QuotesResourceUpfront { + type Builder = QuotesResourceUpfrontBuilder; + } + + impl FromValueOpt for QuotesResourceUpfront { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = QuotesResourceUpfrontBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_subtotal" => b.amount_subtotal = Some(FromValueOpt::from_value(v)?), + "amount_total" => b.amount_total = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "total_details" => b.total_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/radar_radar_options.rs b/generated/stripe_shared/src/radar_radar_options.rs index a27ddf87f..77845243d 100644 --- a/generated/stripe_shared/src/radar_radar_options.rs +++ b/generated/stripe_shared/src/radar_radar_options.rs @@ -1,8 +1,95 @@ /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RadarRadarOptions { /// A [Radar Session](https://stripe.com/docs/radar/radar-session) is a snapshot of the browser metadata and device details that help Radar make more accurate predictions on your payments. - #[serde(skip_serializing_if = "Option::is_none")] pub session: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct RadarRadarOptionsBuilder { + session: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RadarRadarOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RadarRadarOptions>, + builder: RadarRadarOptionsBuilder, + } + + impl Visitor for Place<RadarRadarOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RadarRadarOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for RadarRadarOptionsBuilder { + type Out = RadarRadarOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "session" => Deserialize::begin(&mut self.session), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { session: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let session = self.session.take()?; + + Some(Self::Out { session }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RadarRadarOptions { + type Builder = RadarRadarOptionsBuilder; + } + + impl FromValueOpt for RadarRadarOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RadarRadarOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "session" => b.session = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/radar_review_resource_location.rs b/generated/stripe_shared/src/radar_review_resource_location.rs index a658c5806..409710d12 100644 --- a/generated/stripe_shared/src/radar_review_resource_location.rs +++ b/generated/stripe_shared/src/radar_review_resource_location.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RadarReviewResourceLocation { /// The city where the payment originated. pub city: Option<String>, @@ -11,3 +13,105 @@ pub struct RadarReviewResourceLocation { /// The state/county/province/region where the payment originated. pub region: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct RadarReviewResourceLocationBuilder { + city: Option<Option<String>>, + country: Option<Option<String>>, + latitude: Option<Option<f64>>, + longitude: Option<Option<f64>>, + region: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RadarReviewResourceLocation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RadarReviewResourceLocation>, + builder: RadarReviewResourceLocationBuilder, + } + + impl Visitor for Place<RadarReviewResourceLocation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RadarReviewResourceLocationBuilder::deser_default() })) + } + } + + impl MapBuilder for RadarReviewResourceLocationBuilder { + type Out = RadarReviewResourceLocation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "city" => Deserialize::begin(&mut self.city), + "country" => Deserialize::begin(&mut self.country), + "latitude" => Deserialize::begin(&mut self.latitude), + "longitude" => Deserialize::begin(&mut self.longitude), + "region" => Deserialize::begin(&mut self.region), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { city: Deserialize::default(), country: Deserialize::default(), latitude: Deserialize::default(), longitude: Deserialize::default(), region: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let city = self.city.take()?; + let country = self.country.take()?; + let latitude = self.latitude.take()?; + let longitude = self.longitude.take()?; + let region = self.region.take()?; + + Some(Self::Out { city, country, latitude, longitude, region }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RadarReviewResourceLocation { + type Builder = RadarReviewResourceLocationBuilder; + } + + impl FromValueOpt for RadarReviewResourceLocation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RadarReviewResourceLocationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "city" => b.city = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "latitude" => b.latitude = Some(FromValueOpt::from_value(v)?), + "longitude" => b.longitude = Some(FromValueOpt::from_value(v)?), + "region" => b.region = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/radar_review_resource_session.rs b/generated/stripe_shared/src/radar_review_resource_session.rs index 5bc93e651..e935849ec 100644 --- a/generated/stripe_shared/src/radar_review_resource_session.rs +++ b/generated/stripe_shared/src/radar_review_resource_session.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RadarReviewResourceSession { /// The browser used in this browser session (e.g., `Chrome`). pub browser: Option<String>, @@ -9,3 +11,101 @@ pub struct RadarReviewResourceSession { /// The version for the browser session (e.g., `61.0.3163.100`). pub version: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct RadarReviewResourceSessionBuilder { + browser: Option<Option<String>>, + device: Option<Option<String>>, + platform: Option<Option<String>>, + version: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RadarReviewResourceSession { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RadarReviewResourceSession>, + builder: RadarReviewResourceSessionBuilder, + } + + impl Visitor for Place<RadarReviewResourceSession> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RadarReviewResourceSessionBuilder::deser_default() })) + } + } + + impl MapBuilder for RadarReviewResourceSessionBuilder { + type Out = RadarReviewResourceSession; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "browser" => Deserialize::begin(&mut self.browser), + "device" => Deserialize::begin(&mut self.device), + "platform" => Deserialize::begin(&mut self.platform), + "version" => Deserialize::begin(&mut self.version), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { browser: Deserialize::default(), device: Deserialize::default(), platform: Deserialize::default(), version: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let browser = self.browser.take()?; + let device = self.device.take()?; + let platform = self.platform.take()?; + let version = self.version.take()?; + + Some(Self::Out { browser, device, platform, version }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RadarReviewResourceSession { + type Builder = RadarReviewResourceSessionBuilder; + } + + impl FromValueOpt for RadarReviewResourceSession { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RadarReviewResourceSessionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "browser" => b.browser = Some(FromValueOpt::from_value(v)?), + "device" => b.device = Some(FromValueOpt::from_value(v)?), + "platform" => b.platform = Some(FromValueOpt::from_value(v)?), + "version" => b.version = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/recurring.rs b/generated/stripe_shared/src/recurring.rs index 8cbc330d2..c3c0784f5 100644 --- a/generated/stripe_shared/src/recurring.rs +++ b/generated/stripe_shared/src/recurring.rs @@ -1,6 +1,10 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Recurring { - /// Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. + /// Specifies a usage aggregation strategy for prices of `usage_type=metered`. + /// Allowed values are `sum` for summing up all usage during a period, `last_during_period` for using the last usage record reported within a period, `last_ever` for using the last usage record ever (across period bounds) or `max` which uses the usage record with the maximum reported usage during a period. + /// Defaults to `sum`. pub aggregate_usage: Option<RecurringAggregateUsage>, /// The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`. pub interval: RecurringInterval, @@ -16,7 +20,117 @@ pub struct Recurring { /// Defaults to `licensed`. pub usage_type: RecurringUsageType, } -/// Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. +#[cfg(feature = "min-ser")] +pub struct RecurringBuilder { + aggregate_usage: Option<Option<RecurringAggregateUsage>>, + interval: Option<RecurringInterval>, + interval_count: Option<u64>, + trial_period_days: Option<Option<u32>>, + usage_type: Option<RecurringUsageType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Recurring { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Recurring>, + builder: RecurringBuilder, + } + + impl Visitor for Place<Recurring> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RecurringBuilder::deser_default() })) + } + } + + impl MapBuilder for RecurringBuilder { + type Out = Recurring; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "aggregate_usage" => Deserialize::begin(&mut self.aggregate_usage), + "interval" => Deserialize::begin(&mut self.interval), + "interval_count" => Deserialize::begin(&mut self.interval_count), + "trial_period_days" => Deserialize::begin(&mut self.trial_period_days), + "usage_type" => Deserialize::begin(&mut self.usage_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + aggregate_usage: Deserialize::default(), + interval: Deserialize::default(), + interval_count: Deserialize::default(), + trial_period_days: Deserialize::default(), + usage_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let aggregate_usage = self.aggregate_usage.take()?; + let interval = self.interval.take()?; + let interval_count = self.interval_count.take()?; + let trial_period_days = self.trial_period_days.take()?; + let usage_type = self.usage_type.take()?; + + Some(Self::Out { aggregate_usage, interval, interval_count, trial_period_days, usage_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Recurring { + type Builder = RecurringBuilder; + } + + impl FromValueOpt for Recurring { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RecurringBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "aggregate_usage" => b.aggregate_usage = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "interval_count" => b.interval_count = Some(FromValueOpt::from_value(v)?), + "trial_period_days" => b.trial_period_days = Some(FromValueOpt::from_value(v)?), + "usage_type" => b.usage_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// Specifies a usage aggregation strategy for prices of `usage_type=metered`. +/// Allowed values are `sum` for summing up all usage during a period, `last_during_period` for using the last usage record reported within a period, `last_ever` for using the last usage record ever (across period bounds) or `max` which uses the usage record with the maximum reported usage during a period. +/// Defaults to `sum`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum RecurringAggregateUsage { LastDuringPeriod, @@ -72,10 +186,27 @@ impl<'de> serde::Deserialize<'de> for RecurringAggregateUsage { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for RecurringAggregateUsage")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for RecurringAggregateUsage")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for RecurringAggregateUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<RecurringAggregateUsage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RecurringAggregateUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(RecurringAggregateUsage); /// The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum RecurringInterval { @@ -132,10 +263,27 @@ impl<'de> serde::Deserialize<'de> for RecurringInterval { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for RecurringInterval")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for RecurringInterval")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for RecurringInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<RecurringInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RecurringInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(RecurringInterval); /// Configures how the quantity per period should be determined. /// Can be either `metered` or `licensed`. /// `licensed` automatically bills the `quantity` set when adding it to a subscription. @@ -190,7 +338,24 @@ impl<'de> serde::Deserialize<'de> for RecurringUsageType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for RecurringUsageType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for RecurringUsageType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for RecurringUsageType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<RecurringUsageType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RecurringUsageType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(RecurringUsageType); diff --git a/generated/stripe_shared/src/refund.rs b/generated/stripe_shared/src/refund.rs index c48c33369..33b8b2c88 100644 --- a/generated/stripe_shared/src/refund.rs +++ b/generated/stripe_shared/src/refund.rs @@ -5,7 +5,9 @@ /// Related guide: [Refunds](https://stripe.com/docs/refunds) /// /// For more details see <<https://stripe.com/docs/api/refunds/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Refund { /// Amount, in cents (or local equivalent). pub amount: i64, @@ -20,27 +22,19 @@ pub struct Refund { pub currency: stripe_types::Currency, /// An arbitrary string attached to the object. /// You can use this for displaying to users (available on non-card refunds only). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] - pub destination_details: Option<stripe_shared::RefundDestinationDetails>, /// After the refund fails, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction. - #[serde(skip_serializing_if = "Option::is_none")] - pub failure_balance_transaction: - Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, + pub failure_balance_transaction: Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>, /// Provides the reason for the refund failure. /// Possible values are: `lost_or_stolen_card`, `expired_or_canceled_card`, `charge_for_pending_refund_disputed`, `insufficient_funds`, `declined`, `merchant_request`, or `unknown`. - #[serde(skip_serializing_if = "Option::is_none")] pub failure_reason: Option<String>, /// Unique identifier for the object. pub id: stripe_shared::RefundId, /// For payment methods without native refund support (for example, Konbini, PromptPay), provide an email address for the customer to receive refund instructions. - #[serde(skip_serializing_if = "Option::is_none")] pub instructions_email: Option<String>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. pub metadata: Option<std::collections::HashMap<String, String>>, - #[serde(skip_serializing_if = "Option::is_none")] pub next_action: Option<stripe_shared::RefundNextAction>, /// ID of the PaymentIntent that's refunded. pub payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, @@ -52,13 +46,206 @@ pub struct Refund { /// Only present if the charge came from another Stripe account. pub source_transfer_reversal: Option<stripe_types::Expandable<stripe_shared::TransferReversal>>, /// Status of the refund. - /// This can be `pending`, `requires_action`, `succeeded`, `failed`, or `canceled`. + /// For credit card refunds, this can be `pending`, `succeeded`, or `failed`. + /// For other types of refunds, it can be `pending`, `requires_action`, `succeeded`, `failed`, or `canceled`. /// Learn more about [failed refunds](https://stripe.com/docs/refunds#failed-refunds). pub status: Option<String>, /// This refers to the transfer reversal object if the accompanying transfer reverses. /// This is only applicable if the charge was created using the destination parameter. pub transfer_reversal: Option<stripe_types::Expandable<stripe_shared::TransferReversal>>, } +#[cfg(feature = "min-ser")] +pub struct RefundBuilder { + amount: Option<i64>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + failure_balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + failure_reason: Option<Option<String>>, + id: Option<stripe_shared::RefundId>, + instructions_email: Option<Option<String>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + next_action: Option<Option<stripe_shared::RefundNextAction>>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, + reason: Option<Option<RefundReason>>, + receipt_number: Option<Option<String>>, + source_transfer_reversal: Option<Option<stripe_types::Expandable<stripe_shared::TransferReversal>>>, + status: Option<Option<String>>, + transfer_reversal: Option<Option<stripe_types::Expandable<stripe_shared::TransferReversal>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Refund { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Refund>, + builder: RefundBuilder, + } + + impl Visitor for Place<Refund> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RefundBuilder::deser_default() })) + } + } + + impl MapBuilder for RefundBuilder { + type Out = Refund; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "charge" => Deserialize::begin(&mut self.charge), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "failure_balance_transaction" => Deserialize::begin(&mut self.failure_balance_transaction), + "failure_reason" => Deserialize::begin(&mut self.failure_reason), + "id" => Deserialize::begin(&mut self.id), + "instructions_email" => Deserialize::begin(&mut self.instructions_email), + "metadata" => Deserialize::begin(&mut self.metadata), + "next_action" => Deserialize::begin(&mut self.next_action), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "reason" => Deserialize::begin(&mut self.reason), + "receipt_number" => Deserialize::begin(&mut self.receipt_number), + "source_transfer_reversal" => Deserialize::begin(&mut self.source_transfer_reversal), + "status" => Deserialize::begin(&mut self.status), + "transfer_reversal" => Deserialize::begin(&mut self.transfer_reversal), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + balance_transaction: Deserialize::default(), + charge: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + failure_balance_transaction: Deserialize::default(), + failure_reason: Deserialize::default(), + id: Deserialize::default(), + instructions_email: Deserialize::default(), + metadata: Deserialize::default(), + next_action: Deserialize::default(), + payment_intent: Deserialize::default(), + reason: Deserialize::default(), + receipt_number: Deserialize::default(), + source_transfer_reversal: Deserialize::default(), + status: Deserialize::default(), + transfer_reversal: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let balance_transaction = self.balance_transaction.take()?; + let charge = self.charge.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let failure_balance_transaction = self.failure_balance_transaction.take()?; + let failure_reason = self.failure_reason.take()?; + let id = self.id.take()?; + let instructions_email = self.instructions_email.take()?; + let metadata = self.metadata.take()?; + let next_action = self.next_action.take()?; + let payment_intent = self.payment_intent.take()?; + let reason = self.reason.take()?; + let receipt_number = self.receipt_number.take()?; + let source_transfer_reversal = self.source_transfer_reversal.take()?; + let status = self.status.take()?; + let transfer_reversal = self.transfer_reversal.take()?; + + Some(Self::Out { + amount, + balance_transaction, + charge, + created, + currency, + description, + failure_balance_transaction, + failure_reason, + id, + instructions_email, + metadata, + next_action, + payment_intent, + reason, + receipt_number, + source_transfer_reversal, + status, + transfer_reversal, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Refund { + type Builder = RefundBuilder; + } + + impl FromValueOpt for Refund { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RefundBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "failure_balance_transaction" => b.failure_balance_transaction = Some(FromValueOpt::from_value(v)?), + "failure_reason" => b.failure_reason = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "instructions_email" => b.instructions_email = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "next_action" => b.next_action = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "receipt_number" => b.receipt_number = Some(FromValueOpt::from_value(v)?), + "source_transfer_reversal" => b.source_transfer_reversal = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "transfer_reversal" => b.transfer_reversal = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for the refund, which is either user-provided (`duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`). #[derive(Copy, Clone, Eq, PartialEq)] pub enum RefundReason { @@ -118,6 +305,24 @@ impl<'de> serde::Deserialize<'de> for RefundReason { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for RefundReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for RefundReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<RefundReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RefundReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(RefundReason); impl stripe_types::Object for Refund { type Id = stripe_shared::RefundId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/refund_destination_details.rs b/generated/stripe_shared/src/refund_destination_details.rs deleted file mode 100644 index a64f2802e..000000000 --- a/generated/stripe_shared/src/refund_destination_details.rs +++ /dev/null @@ -1,64 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct RefundDestinationDetails { - #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub au_bank_transfer: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub br_bank_transfer: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub card: Option<stripe_shared::RefundDestinationDetailsCard>, - #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub customer_cash_balance: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub eps: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub eu_bank_transfer: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub gb_bank_transfer: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub jp_bank_transfer: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub klarna: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub mx_bank_transfer: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub p24: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub revolut: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub sofort: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub swish: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub th_bank_transfer: Option<stripe_shared::RefundDestinationDetailsGeneric>, - /// The type of transaction-specific details of the payment method used in the refund (e.g., `card`). - /// An additional hash is included on `destination_details` with a name matching this value. - /// It contains information specific to the refund transaction. - #[serde(rename = "type")] - pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_transfer: Option<stripe_shared::RefundDestinationDetailsGeneric>, - #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<stripe_shared::DestinationDetailsUnimplemented>, - #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<stripe_shared::DestinationDetailsUnimplemented>, -} diff --git a/generated/stripe_shared/src/refund_destination_details_card.rs b/generated/stripe_shared/src/refund_destination_details_card.rs deleted file mode 100644 index a3531e4d2..000000000 --- a/generated/stripe_shared/src/refund_destination_details_card.rs +++ /dev/null @@ -1,73 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct RefundDestinationDetailsCard { - /// Value of the reference number assigned to the refund. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference: Option<String>, - /// Status of the reference number on the refund. This can be `pending`, `available` or `unavailable`. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference_status: Option<String>, - /// Type of the reference number assigned to the refund. - #[serde(skip_serializing_if = "Option::is_none")] - pub reference_type: Option<String>, - /// The type of refund. This can be `refund`, `reversal`, or `pending`. - #[serde(rename = "type")] - pub type_: RefundDestinationDetailsCardType, -} -/// The type of refund. This can be `refund`, `reversal`, or `pending`. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum RefundDestinationDetailsCardType { - Pending, - Refund, - Reversal, -} -impl RefundDestinationDetailsCardType { - pub fn as_str(self) -> &'static str { - use RefundDestinationDetailsCardType::*; - match self { - Pending => "pending", - Refund => "refund", - Reversal => "reversal", - } - } -} - -impl std::str::FromStr for RefundDestinationDetailsCardType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use RefundDestinationDetailsCardType::*; - match s { - "pending" => Ok(Pending), - "refund" => Ok(Refund), - "reversal" => Ok(Reversal), - _ => Err(()), - } - } -} -impl std::fmt::Display for RefundDestinationDetailsCardType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for RefundDestinationDetailsCardType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for RefundDestinationDetailsCardType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for RefundDestinationDetailsCardType { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for RefundDestinationDetailsCardType") - }) - } -} diff --git a/generated/stripe_shared/src/refund_destination_details_generic.rs b/generated/stripe_shared/src/refund_destination_details_generic.rs deleted file mode 100644 index 38af924b3..000000000 --- a/generated/stripe_shared/src/refund_destination_details_generic.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] -pub struct RefundDestinationDetailsGeneric { - /// The reference assigned to the refund. - pub reference: Option<String>, - /// Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. - pub reference_status: Option<String>, -} diff --git a/generated/stripe_shared/src/refund_next_action.rs b/generated/stripe_shared/src/refund_next_action.rs index 2073c3d0b..c6bd25080 100644 --- a/generated/stripe_shared/src/refund_next_action.rs +++ b/generated/stripe_shared/src/refund_next_action.rs @@ -1,8 +1,100 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RefundNextAction { /// Contains the refund details. pub display_details: Option<stripe_shared::RefundNextActionDisplayDetails>, /// Type of the next action to perform. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, } +#[cfg(feature = "min-ser")] +pub struct RefundNextActionBuilder { + display_details: Option<Option<stripe_shared::RefundNextActionDisplayDetails>>, + type_: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RefundNextAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RefundNextAction>, + builder: RefundNextActionBuilder, + } + + impl Visitor for Place<RefundNextAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RefundNextActionBuilder::deser_default() })) + } + } + + impl MapBuilder for RefundNextActionBuilder { + type Out = RefundNextAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "display_details" => Deserialize::begin(&mut self.display_details), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { display_details: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let display_details = self.display_details.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { display_details, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RefundNextAction { + type Builder = RefundNextActionBuilder; + } + + impl FromValueOpt for RefundNextAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RefundNextActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "display_details" => b.display_details = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/refund_next_action_display_details.rs b/generated/stripe_shared/src/refund_next_action_display_details.rs index 2db329477..ce52ce0ad 100644 --- a/generated/stripe_shared/src/refund_next_action_display_details.rs +++ b/generated/stripe_shared/src/refund_next_action_display_details.rs @@ -1,6 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct RefundNextActionDisplayDetails { pub email_sent: stripe_shared::EmailSent, /// The expiry timestamp. pub expires_at: stripe_types::Timestamp, } +#[cfg(feature = "min-ser")] +pub struct RefundNextActionDisplayDetailsBuilder { + email_sent: Option<stripe_shared::EmailSent>, + expires_at: Option<stripe_types::Timestamp>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RefundNextActionDisplayDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<RefundNextActionDisplayDetails>, + builder: RefundNextActionDisplayDetailsBuilder, + } + + impl Visitor for Place<RefundNextActionDisplayDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RefundNextActionDisplayDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for RefundNextActionDisplayDetailsBuilder { + type Out = RefundNextActionDisplayDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "email_sent" => Deserialize::begin(&mut self.email_sent), + "expires_at" => Deserialize::begin(&mut self.expires_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { email_sent: Deserialize::default(), expires_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let email_sent = self.email_sent.take()?; + let expires_at = self.expires_at.take()?; + + Some(Self::Out { email_sent, expires_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RefundNextActionDisplayDetails { + type Builder = RefundNextActionDisplayDetailsBuilder; + } + + impl FromValueOpt for RefundNextActionDisplayDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RefundNextActionDisplayDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "email_sent" => b.email_sent = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/reserve_transaction.rs b/generated/stripe_shared/src/reserve_transaction.rs index 6eff61158..b4101a6c3 100644 --- a/generated/stripe_shared/src/reserve_transaction.rs +++ b/generated/stripe_shared/src/reserve_transaction.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ReserveTransaction { pub amount: i64, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. @@ -9,6 +11,104 @@ pub struct ReserveTransaction { /// Unique identifier for the object. pub id: stripe_shared::ReserveTransactionId, } +#[cfg(feature = "min-ser")] +pub struct ReserveTransactionBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + id: Option<stripe_shared::ReserveTransactionId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ReserveTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ReserveTransaction>, + builder: ReserveTransactionBuilder, + } + + impl Visitor for Place<ReserveTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ReserveTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for ReserveTransactionBuilder { + type Out = ReserveTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default(), description: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let id = self.id.take()?; + + Some(Self::Out { amount, currency, description, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ReserveTransaction { + type Builder = ReserveTransactionBuilder; + } + + impl FromValueOpt for ReserveTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ReserveTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ReserveTransaction { type Id = stripe_shared::ReserveTransactionId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/review.rs b/generated/stripe_shared/src/review.rs index c173ea8b2..c30dac18d 100644 --- a/generated/stripe_shared/src/review.rs +++ b/generated/stripe_shared/src/review.rs @@ -4,7 +4,9 @@ /// [here](https://stripe.com/docs/radar/reviews). /// /// For more details see <<https://stripe.com/docs/api/radar/reviews/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Review { /// The ZIP or postal code of the card used, if applicable. pub billing_zip: Option<String>, @@ -29,7 +31,6 @@ pub struct Review { /// The reason the review was opened. One of `rule` or `manual`. pub opened_reason: ReviewOpenedReason, /// The PaymentIntent ID associated with this review, if one exists. - #[serde(skip_serializing_if = "Option::is_none")] pub payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, /// The reason the review is currently open or closed. /// One of `rule`, `manual`, `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`. @@ -37,6 +38,154 @@ pub struct Review { /// Information related to the browsing session of the user who initiated the payment. pub session: Option<stripe_shared::RadarReviewResourceSession>, } +#[cfg(feature = "min-ser")] +pub struct ReviewBuilder { + billing_zip: Option<Option<String>>, + charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + closed_reason: Option<Option<ReviewClosedReason>>, + created: Option<stripe_types::Timestamp>, + id: Option<stripe_shared::ReviewId>, + ip_address: Option<Option<String>>, + ip_address_location: Option<Option<stripe_shared::RadarReviewResourceLocation>>, + livemode: Option<bool>, + open: Option<bool>, + opened_reason: Option<ReviewOpenedReason>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, + reason: Option<String>, + session: Option<Option<stripe_shared::RadarReviewResourceSession>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Review { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Review>, + builder: ReviewBuilder, + } + + impl Visitor for Place<Review> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ReviewBuilder::deser_default() })) + } + } + + impl MapBuilder for ReviewBuilder { + type Out = Review; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_zip" => Deserialize::begin(&mut self.billing_zip), + "charge" => Deserialize::begin(&mut self.charge), + "closed_reason" => Deserialize::begin(&mut self.closed_reason), + "created" => Deserialize::begin(&mut self.created), + "id" => Deserialize::begin(&mut self.id), + "ip_address" => Deserialize::begin(&mut self.ip_address), + "ip_address_location" => Deserialize::begin(&mut self.ip_address_location), + "livemode" => Deserialize::begin(&mut self.livemode), + "open" => Deserialize::begin(&mut self.open), + "opened_reason" => Deserialize::begin(&mut self.opened_reason), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "reason" => Deserialize::begin(&mut self.reason), + "session" => Deserialize::begin(&mut self.session), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing_zip: Deserialize::default(), + charge: Deserialize::default(), + closed_reason: Deserialize::default(), + created: Deserialize::default(), + id: Deserialize::default(), + ip_address: Deserialize::default(), + ip_address_location: Deserialize::default(), + livemode: Deserialize::default(), + open: Deserialize::default(), + opened_reason: Deserialize::default(), + payment_intent: Deserialize::default(), + reason: Deserialize::default(), + session: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_zip = self.billing_zip.take()?; + let charge = self.charge.take()?; + let closed_reason = self.closed_reason.take()?; + let created = self.created.take()?; + let id = self.id.take()?; + let ip_address = self.ip_address.take()?; + let ip_address_location = self.ip_address_location.take()?; + let livemode = self.livemode.take()?; + let open = self.open.take()?; + let opened_reason = self.opened_reason.take()?; + let payment_intent = self.payment_intent.take()?; + let reason = self.reason.take()?; + let session = self.session.take()?; + + Some(Self::Out { billing_zip, charge, closed_reason, created, id, ip_address, ip_address_location, livemode, open, opened_reason, payment_intent, reason, session }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Review { + type Builder = ReviewBuilder; + } + + impl FromValueOpt for Review { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ReviewBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_zip" => b.billing_zip = Some(FromValueOpt::from_value(v)?), + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "closed_reason" => b.closed_reason = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "ip_address" => b.ip_address = Some(FromValueOpt::from_value(v)?), + "ip_address_location" => b.ip_address_location = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "open" => b.open = Some(FromValueOpt::from_value(v)?), + "opened_reason" => b.opened_reason = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "session" => b.session = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reason the review was closed, or null if it has not yet been closed. /// One of `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -97,10 +246,27 @@ impl<'de> serde::Deserialize<'de> for ReviewClosedReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ReviewClosedReason")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ReviewClosedReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ReviewClosedReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ReviewClosedReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReviewClosedReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ReviewClosedReason); /// The reason the review was opened. One of `rule` or `manual`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ReviewOpenedReason { @@ -151,10 +317,27 @@ impl<'de> serde::Deserialize<'de> for ReviewOpenedReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ReviewOpenedReason")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ReviewOpenedReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ReviewOpenedReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ReviewOpenedReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReviewOpenedReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ReviewOpenedReason); impl stripe_types::Object for Review { type Id = stripe_shared::ReviewId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/rule.rs b/generated/stripe_shared/src/rule.rs index c3c8c0bfb..c56ad33e2 100644 --- a/generated/stripe_shared/src/rule.rs +++ b/generated/stripe_shared/src/rule.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Rule { /// The action taken on the payment. pub action: String, @@ -7,6 +9,100 @@ pub struct Rule { /// The predicate to evaluate the payment against. pub predicate: String, } +#[cfg(feature = "min-ser")] +pub struct RuleBuilder { + action: Option<String>, + id: Option<stripe_shared::RuleId>, + predicate: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Rule { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Rule>, + builder: RuleBuilder, + } + + impl Visitor for Place<Rule> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: RuleBuilder::deser_default() })) + } + } + + impl MapBuilder for RuleBuilder { + type Out = Rule; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "action" => Deserialize::begin(&mut self.action), + "id" => Deserialize::begin(&mut self.id), + "predicate" => Deserialize::begin(&mut self.predicate), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { action: Deserialize::default(), id: Deserialize::default(), predicate: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let action = self.action.take()?; + let id = self.id.take()?; + let predicate = self.predicate.take()?; + + Some(Self::Out { action, id, predicate }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Rule { + type Builder = RuleBuilder; + } + + impl FromValueOpt for Rule { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RuleBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "action" => b.action = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "predicate" => b.predicate = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Rule { type Id = stripe_shared::RuleId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/schedules_phase_automatic_tax.rs b/generated/stripe_shared/src/schedules_phase_automatic_tax.rs index e0f4228ae..4d8719a37 100644 --- a/generated/stripe_shared/src/schedules_phase_automatic_tax.rs +++ b/generated/stripe_shared/src/schedules_phase_automatic_tax.rs @@ -1,9 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SchedulesPhaseAutomaticTax { /// Whether Stripe automatically computes tax on invoices created during this phase. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - pub liability: Option<stripe_shared::ConnectAccountReference>, } +#[cfg(feature = "min-ser")] +pub struct SchedulesPhaseAutomaticTaxBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SchedulesPhaseAutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SchedulesPhaseAutomaticTax>, + builder: SchedulesPhaseAutomaticTaxBuilder, + } + + impl Visitor for Place<SchedulesPhaseAutomaticTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SchedulesPhaseAutomaticTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for SchedulesPhaseAutomaticTaxBuilder { + type Out = SchedulesPhaseAutomaticTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SchedulesPhaseAutomaticTax { + type Builder = SchedulesPhaseAutomaticTaxBuilder; + } + + impl FromValueOpt for SchedulesPhaseAutomaticTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SchedulesPhaseAutomaticTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/sepa_debit_generated_from.rs b/generated/stripe_shared/src/sepa_debit_generated_from.rs index a6bf1ccae..9fc8ac22b 100644 --- a/generated/stripe_shared/src/sepa_debit_generated_from.rs +++ b/generated/stripe_shared/src/sepa_debit_generated_from.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SepaDebitGeneratedFrom { /// The ID of the Charge that generated this PaymentMethod, if any. pub charge: Option<stripe_types::Expandable<stripe_shared::Charge>>, /// The ID of the SetupAttempt that generated this PaymentMethod, if any. pub setup_attempt: Option<stripe_types::Expandable<stripe_shared::SetupAttempt>>, } +#[cfg(feature = "min-ser")] +pub struct SepaDebitGeneratedFromBuilder { + charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + setup_attempt: Option<Option<stripe_types::Expandable<stripe_shared::SetupAttempt>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SepaDebitGeneratedFrom { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SepaDebitGeneratedFrom>, + builder: SepaDebitGeneratedFromBuilder, + } + + impl Visitor for Place<SepaDebitGeneratedFrom> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SepaDebitGeneratedFromBuilder::deser_default() })) + } + } + + impl MapBuilder for SepaDebitGeneratedFromBuilder { + type Out = SepaDebitGeneratedFrom; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "charge" => Deserialize::begin(&mut self.charge), + "setup_attempt" => Deserialize::begin(&mut self.setup_attempt), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { charge: Deserialize::default(), setup_attempt: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let charge = self.charge.take()?; + let setup_attempt = self.setup_attempt.take()?; + + Some(Self::Out { charge, setup_attempt }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SepaDebitGeneratedFrom { + type Builder = SepaDebitGeneratedFromBuilder; + } + + impl FromValueOpt for SepaDebitGeneratedFrom { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SepaDebitGeneratedFromBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "setup_attempt" => b.setup_attempt = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt.rs b/generated/stripe_shared/src/setup_attempt.rs index a68fbdbc4..cdbb90530 100644 --- a/generated/stripe_shared/src/setup_attempt.rs +++ b/generated/stripe_shared/src/setup_attempt.rs @@ -4,7 +4,9 @@ /// payment method using a SetupIntent. /// /// For more details see <<https://stripe.com/docs/api/setup_attempts/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttempt { /// The value of [application](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-application) on the SetupIntent at the time of this confirmation. pub application: Option<stripe_types::Expandable<stripe_shared::Application>>, @@ -12,7 +14,6 @@ pub struct SetupAttempt { /// /// It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. /// It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer. - #[serde(skip_serializing_if = "Option::is_none")] pub attach_to_self: Option<bool>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -42,6 +43,174 @@ pub struct SetupAttempt { /// The value of [usage](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-usage) on the SetupIntent at the time of this confirmation, one of `off_session` or `on_session`. pub usage: String, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptBuilder { + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + attach_to_self: Option<Option<bool>>, + created: Option<stripe_types::Timestamp>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + flow_directions: Option<Option<Vec<SetupAttemptFlowDirections>>>, + id: Option<stripe_shared::SetupAttemptId>, + livemode: Option<bool>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>, + payment_method_details: Option<stripe_shared::SetupAttemptPaymentMethodDetails>, + setup_error: Option<Option<Box<stripe_shared::ApiErrors>>>, + setup_intent: Option<stripe_types::Expandable<stripe_shared::SetupIntent>>, + status: Option<String>, + usage: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttempt { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttempt>, + builder: SetupAttemptBuilder, + } + + impl Visitor for Place<SetupAttempt> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptBuilder { + type Out = SetupAttempt; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "application" => Deserialize::begin(&mut self.application), + "attach_to_self" => Deserialize::begin(&mut self.attach_to_self), + "created" => Deserialize::begin(&mut self.created), + "customer" => Deserialize::begin(&mut self.customer), + "flow_directions" => Deserialize::begin(&mut self.flow_directions), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "payment_method" => Deserialize::begin(&mut self.payment_method), + "payment_method_details" => Deserialize::begin(&mut self.payment_method_details), + "setup_error" => Deserialize::begin(&mut self.setup_error), + "setup_intent" => Deserialize::begin(&mut self.setup_intent), + "status" => Deserialize::begin(&mut self.status), + "usage" => Deserialize::begin(&mut self.usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + application: Deserialize::default(), + attach_to_self: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + flow_directions: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + on_behalf_of: Deserialize::default(), + payment_method: Deserialize::default(), + payment_method_details: Deserialize::default(), + setup_error: Deserialize::default(), + setup_intent: Deserialize::default(), + status: Deserialize::default(), + usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let application = self.application.take()?; + let attach_to_self = self.attach_to_self.take()?; + let created = self.created.take()?; + let customer = self.customer.take()?; + let flow_directions = self.flow_directions.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let payment_method = self.payment_method.take()?; + let payment_method_details = self.payment_method_details.take()?; + let setup_error = self.setup_error.take()?; + let setup_intent = self.setup_intent.take()?; + let status = self.status.take()?; + let usage = self.usage.take()?; + + Some(Self::Out { + application, + attach_to_self, + created, + customer, + flow_directions, + id, + livemode, + on_behalf_of, + payment_method, + payment_method_details, + setup_error, + setup_intent, + status, + usage, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttempt { + type Builder = SetupAttemptBuilder; + } + + impl FromValueOpt for SetupAttempt { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "attach_to_self" => b.attach_to_self = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "flow_directions" => b.flow_directions = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "payment_method" => b.payment_method = Some(FromValueOpt::from_value(v)?), + "payment_method_details" => b.payment_method_details = Some(FromValueOpt::from_value(v)?), + "setup_error" => b.setup_error = Some(FromValueOpt::from_value(v)?), + "setup_intent" => b.setup_intent = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "usage" => b.usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates the directions of money movement for which this payment method is intended to be used. /// /// Include `inbound` if you intend to use the payment method as the origin to pull funds from. @@ -96,10 +265,27 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptFlowDirections { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for SetupAttemptFlowDirections")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupAttemptFlowDirections")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupAttemptFlowDirections { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupAttemptFlowDirections> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptFlowDirections::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupAttemptFlowDirections); impl stripe_types::Object for SetupAttempt { type Id = stripe_shared::SetupAttemptId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details.rs index 0b3f15bc9..0195316e5 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details.rs @@ -1,38 +1,188 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_shared::SetupAttemptPaymentMethodDetailsAcssDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_shared::SetupAttemptPaymentMethodDetailsAuBecsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option<stripe_shared::SetupAttemptPaymentMethodDetailsBacsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option<stripe_shared::SetupAttemptPaymentMethodDetailsBancontact>, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option<stripe_shared::SetupAttemptPaymentMethodDetailsBoleto>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::SetupAttemptPaymentMethodDetailsCard>, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardPresent>, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option<stripe_shared::SetupAttemptPaymentMethodDetailsCashapp>, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option<stripe_shared::SetupAttemptPaymentMethodDetailsIdeal>, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option<stripe_shared::SetupAttemptPaymentMethodDetailsKlarna>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::SetupAttemptPaymentMethodDetailsLink>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_shared::SetupAttemptPaymentMethodDetailsPaypal>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_shared::SetupAttemptPaymentMethodDetailsSepaDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<stripe_shared::SetupAttemptPaymentMethodDetailsSofort>, /// The type of the payment method used in the SetupIntent (e.g., `card`). /// An additional hash is included on `payment_method_details` with a name matching this value. /// It contains confirmation-specific information for the payment method. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_shared::SetupAttemptPaymentMethodDetailsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsBuilder { + acss_debit: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsAcssDebit>>, + au_becs_debit: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsAuBecsDebit>>, + bacs_debit: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsBacsDebit>>, + bancontact: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsBancontact>>, + boleto: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsBoleto>>, + card: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsCard>>, + card_present: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardPresent>>, + cashapp: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsCashapp>>, + ideal: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsIdeal>>, + klarna: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsKlarna>>, + link: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsLink>>, + paypal: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsPaypal>>, + sepa_debit: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsSepaDebit>>, + sofort: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsSofort>>, + type_: Option<String>, + us_bank_account: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetails>, + builder: SetupAttemptPaymentMethodDetailsBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsBuilder { + type Out = SetupAttemptPaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bacs_debit" => Deserialize::begin(&mut self.bacs_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "boleto" => Deserialize::begin(&mut self.boleto), + "card" => Deserialize::begin(&mut self.card), + "card_present" => Deserialize::begin(&mut self.card_present), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "ideal" => Deserialize::begin(&mut self.ideal), + "klarna" => Deserialize::begin(&mut self.klarna), + "link" => Deserialize::begin(&mut self.link), + "paypal" => Deserialize::begin(&mut self.paypal), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "sofort" => Deserialize::begin(&mut self.sofort), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bacs_debit: Deserialize::default(), + bancontact: Deserialize::default(), + boleto: Deserialize::default(), + card: Deserialize::default(), + card_present: Deserialize::default(), + cashapp: Deserialize::default(), + ideal: Deserialize::default(), + klarna: Deserialize::default(), + link: Deserialize::default(), + paypal: Deserialize::default(), + sepa_debit: Deserialize::default(), + sofort: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bacs_debit = self.bacs_debit.take()?; + let bancontact = self.bancontact.take()?; + let boleto = self.boleto.take()?; + let card = self.card.take()?; + let card_present = self.card_present.take()?; + let cashapp = self.cashapp.take()?; + let ideal = self.ideal.take()?; + let klarna = self.klarna.take()?; + let link = self.link.take()?; + let paypal = self.paypal.take()?; + let sepa_debit = self.sepa_debit.take()?; + let sofort = self.sofort.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { acss_debit, au_becs_debit, bacs_debit, bancontact, boleto, card, card_present, cashapp, ideal, klarna, link, paypal, sepa_debit, sofort, type_, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetails { + type Builder = SetupAttemptPaymentMethodDetailsBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bacs_debit" => b.bacs_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "boleto" => b.boleto = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "card_present" => b.card_present = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "ideal" => b.ideal = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_acss_debit.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_acss_debit.rs index 59426ea77..9c9054690 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_acss_debit.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_acss_debit.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsAcssDebit {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsAcssDebitBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsAcssDebit>, + builder: SetupAttemptPaymentMethodDetailsAcssDebitBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsAcssDebitBuilder { + type Out = SetupAttemptPaymentMethodDetailsAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsAcssDebit { + type Builder = SetupAttemptPaymentMethodDetailsAcssDebitBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_au_becs_debit.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_au_becs_debit.rs index 092b15c74..2b4bd7e0a 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_au_becs_debit.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_au_becs_debit.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsAuBecsDebit {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsAuBecsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsAuBecsDebit>, + builder: SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsAuBecsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder { + type Out = SetupAttemptPaymentMethodDetailsAuBecsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsAuBecsDebit { + type Builder = SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsAuBecsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_bacs_debit.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_bacs_debit.rs index 39be12ee4..660e2cbc2 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_bacs_debit.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_bacs_debit.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsBacsDebit {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsBacsDebitBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsBacsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsBacsDebit>, + builder: SetupAttemptPaymentMethodDetailsBacsDebitBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsBacsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsBacsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsBacsDebitBuilder { + type Out = SetupAttemptPaymentMethodDetailsBacsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsBacsDebit { + type Builder = SetupAttemptPaymentMethodDetailsBacsDebitBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsBacsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsBacsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_bancontact.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_bancontact.rs index 647a5caca..81f2d4a59 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_bancontact.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_bancontact.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsBancontact { /// Bank code of bank associated with the bank account. pub bank_code: Option<String>, @@ -19,6 +21,129 @@ pub struct SetupAttemptPaymentMethodDetailsBancontact { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsBancontactBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + generated_sepa_debit: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + generated_sepa_debit_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + iban_last4: Option<Option<String>>, + preferred_language: Option<Option<SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsBancontact { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsBancontact>, + builder: SetupAttemptPaymentMethodDetailsBancontactBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsBancontact> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsBancontactBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsBancontactBuilder { + type Out = SetupAttemptPaymentMethodDetailsBancontact; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "generated_sepa_debit" => Deserialize::begin(&mut self.generated_sepa_debit), + "generated_sepa_debit_mandate" => Deserialize::begin(&mut self.generated_sepa_debit_mandate), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + bic: Deserialize::default(), + generated_sepa_debit: Deserialize::default(), + generated_sepa_debit_mandate: Deserialize::default(), + iban_last4: Deserialize::default(), + preferred_language: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let generated_sepa_debit = self.generated_sepa_debit.take()?; + let generated_sepa_debit_mandate = self.generated_sepa_debit_mandate.take()?; + let iban_last4 = self.iban_last4.take()?; + let preferred_language = self.preferred_language.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank_code, bank_name, bic, generated_sepa_debit, generated_sepa_debit_mandate, iban_last4, preferred_language, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsBancontact { + type Builder = SetupAttemptPaymentMethodDetailsBancontactBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsBancontact { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsBancontactBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit" => b.generated_sepa_debit = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit_mandate" => b.generated_sepa_debit_mandate = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred language of the Bancontact authorization page that the customer is redirected to. /// Can be one of `en`, `de`, `fr`, or `nl` #[derive(Copy, Clone, Eq, PartialEq)] @@ -76,10 +201,24 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsBancontact fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage); diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_boleto.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_boleto.rs index 879f54e79..34987d4a9 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_boleto.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_boleto.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsBoleto {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsBoletoBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsBoleto { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsBoleto>, + builder: SetupAttemptPaymentMethodDetailsBoletoBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsBoleto> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsBoletoBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsBoletoBuilder { + type Out = SetupAttemptPaymentMethodDetailsBoleto; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsBoleto { + type Builder = SetupAttemptPaymentMethodDetailsBoletoBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsBoleto { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsBoletoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_card.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_card.rs index ed67fedc4..8c080edcb 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_card.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_card.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsCard { /// Card brand. /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. @@ -10,7 +12,6 @@ pub struct SetupAttemptPaymentMethodDetailsCard { pub country: Option<String>, /// A high-level description of the type of cards issued in this range. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// Two-digit number representing the card's expiration month. pub exp_month: Option<i64>, @@ -21,17 +22,14 @@ pub struct SetupAttemptPaymentMethodDetailsCard { /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number. /// /// *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*. - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`. pub funding: Option<String>, /// Issuer identification number of the card. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, /// The name of the card's issuing bank. /// (For internal use only and not typically available in standard API requests.). - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, /// The last four digits of the card. pub last4: Option<String>, @@ -43,3 +41,156 @@ pub struct SetupAttemptPaymentMethodDetailsCard { /// If this Card is part of a card wallet, this contains the details of the card wallet. pub wallet: Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardWallet>, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsCardBuilder { + brand: Option<Option<String>>, + checks: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardChecks>>, + country: Option<Option<String>>, + description: Option<Option<String>>, + exp_month: Option<Option<i64>>, + exp_year: Option<Option<i64>>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + network: Option<Option<String>>, + three_d_secure: Option<Option<stripe_shared::ThreeDSecureDetails>>, + wallet: Option<Option<stripe_shared::SetupAttemptPaymentMethodDetailsCardWallet>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsCard>, + builder: SetupAttemptPaymentMethodDetailsCardBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsCardBuilder { + type Out = SetupAttemptPaymentMethodDetailsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "brand" => Deserialize::begin(&mut self.brand), + "checks" => Deserialize::begin(&mut self.checks), + "country" => Deserialize::begin(&mut self.country), + "description" => Deserialize::begin(&mut self.description), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "network" => Deserialize::begin(&mut self.network), + "three_d_secure" => Deserialize::begin(&mut self.three_d_secure), + "wallet" => Deserialize::begin(&mut self.wallet), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + brand: Deserialize::default(), + checks: Deserialize::default(), + country: Deserialize::default(), + description: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + network: Deserialize::default(), + three_d_secure: Deserialize::default(), + wallet: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let brand = self.brand.take()?; + let checks = self.checks.take()?; + let country = self.country.take()?; + let description = self.description.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let network = self.network.take()?; + let three_d_secure = self.three_d_secure.take()?; + let wallet = self.wallet.take()?; + + Some(Self::Out { brand, checks, country, description, exp_month, exp_year, fingerprint, funding, iin, issuer, last4, network, three_d_secure, wallet }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsCard { + type Builder = SetupAttemptPaymentMethodDetailsCardBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "checks" => b.checks = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "three_d_secure" => b.three_d_secure = Some(FromValueOpt::from_value(v)?), + "wallet" => b.wallet = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_card_checks.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_card_checks.rs index de56ad5c9..b7f5663c0 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_card_checks.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_card_checks.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsCardChecks { /// If a address line1 was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub address_line1_check: Option<String>, @@ -7,3 +9,97 @@ pub struct SetupAttemptPaymentMethodDetailsCardChecks { /// If a CVC was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub cvc_check: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsCardChecksBuilder { + address_line1_check: Option<Option<String>>, + address_postal_code_check: Option<Option<String>>, + cvc_check: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsCardChecks { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsCardChecks>, + builder: SetupAttemptPaymentMethodDetailsCardChecksBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsCardChecks> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsCardChecksBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsCardChecksBuilder { + type Out = SetupAttemptPaymentMethodDetailsCardChecks; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address_line1_check" => Deserialize::begin(&mut self.address_line1_check), + "address_postal_code_check" => Deserialize::begin(&mut self.address_postal_code_check), + "cvc_check" => Deserialize::begin(&mut self.cvc_check), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address_line1_check: Deserialize::default(), address_postal_code_check: Deserialize::default(), cvc_check: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address_line1_check = self.address_line1_check.take()?; + let address_postal_code_check = self.address_postal_code_check.take()?; + let cvc_check = self.cvc_check.take()?; + + Some(Self::Out { address_line1_check, address_postal_code_check, cvc_check }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsCardChecks { + type Builder = SetupAttemptPaymentMethodDetailsCardChecksBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsCardChecks { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsCardChecksBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address_line1_check" => b.address_line1_check = Some(FromValueOpt::from_value(v)?), + "address_postal_code_check" => b.address_postal_code_check = Some(FromValueOpt::from_value(v)?), + "cvc_check" => b.cvc_check = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_card_present.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_card_present.rs index a9ea3977c..31382b0f8 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_card_present.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_card_present.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsCardPresent { /// The ID of the Card PaymentMethod which was generated by this SetupAttempt. pub generated_card: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsCardPresentBuilder { + generated_card: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsCardPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsCardPresent>, + builder: SetupAttemptPaymentMethodDetailsCardPresentBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsCardPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsCardPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsCardPresentBuilder { + type Out = SetupAttemptPaymentMethodDetailsCardPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "generated_card" => Deserialize::begin(&mut self.generated_card), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { generated_card: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let generated_card = self.generated_card.take()?; + + Some(Self::Out { generated_card }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsCardPresent { + type Builder = SetupAttemptPaymentMethodDetailsCardPresentBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsCardPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsCardPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "generated_card" => b.generated_card = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_card_wallet.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_card_wallet.rs index 4911031db..55e45872d 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_card_wallet.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_card_wallet.rs @@ -1,15 +1,109 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsCardWallet { - #[serde(skip_serializing_if = "Option::is_none")] pub apple_pay: Option<stripe_shared::PaymentMethodDetailsCardWalletApplePay>, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option<stripe_shared::PaymentMethodDetailsCardWalletGooglePay>, /// The type of the card wallet, one of `apple_pay`, `google_pay`, or `link`. /// An additional hash is included on the Wallet subhash with a name matching this value. /// It contains additional information specific to the card wallet type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: SetupAttemptPaymentMethodDetailsCardWalletType, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsCardWalletBuilder { + apple_pay: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletApplePay>>, + google_pay: Option<Option<stripe_shared::PaymentMethodDetailsCardWalletGooglePay>>, + type_: Option<SetupAttemptPaymentMethodDetailsCardWalletType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsCardWallet { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsCardWallet>, + builder: SetupAttemptPaymentMethodDetailsCardWalletBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsCardWallet> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsCardWalletBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsCardWalletBuilder { + type Out = SetupAttemptPaymentMethodDetailsCardWallet; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "apple_pay" => Deserialize::begin(&mut self.apple_pay), + "google_pay" => Deserialize::begin(&mut self.google_pay), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { apple_pay: Deserialize::default(), google_pay: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let apple_pay = self.apple_pay.take()?; + let google_pay = self.google_pay.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { apple_pay, google_pay, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsCardWallet { + type Builder = SetupAttemptPaymentMethodDetailsCardWalletBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsCardWallet { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsCardWalletBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "apple_pay" => b.apple_pay = Some(FromValueOpt::from_value(v)?), + "google_pay" => b.google_pay = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the card wallet, one of `apple_pay`, `google_pay`, or `link`. /// An additional hash is included on the Wallet subhash with a name matching this value. /// It contains additional information specific to the card wallet type. @@ -65,10 +159,24 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsCardWallet fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupAttemptPaymentMethodDetailsCardWalletType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupAttemptPaymentMethodDetailsCardWalletType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsCardWalletType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupAttemptPaymentMethodDetailsCardWalletType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptPaymentMethodDetailsCardWalletType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsCardWalletType); diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_cashapp.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_cashapp.rs index f5980430c..5daf300bd 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_cashapp.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_cashapp.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsCashapp {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsCashappBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsCashapp { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsCashapp>, + builder: SetupAttemptPaymentMethodDetailsCashappBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsCashapp> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsCashappBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsCashappBuilder { + type Out = SetupAttemptPaymentMethodDetailsCashapp; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsCashapp { + type Builder = SetupAttemptPaymentMethodDetailsCashappBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsCashapp { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsCashappBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_ideal.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_ideal.rs index f7379c164..c4f50c80e 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_ideal.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_ideal.rs @@ -1,7 +1,9 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsIdeal { /// The customer's bank. - /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. + /// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. pub bank: Option<SetupAttemptPaymentMethodDetailsIdealBank>, /// The Bank Identifier Code of the customer's bank. pub bic: Option<SetupAttemptPaymentMethodDetailsIdealBic>, @@ -15,8 +17,121 @@ pub struct SetupAttemptPaymentMethodDetailsIdeal { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsIdealBuilder { + bank: Option<Option<SetupAttemptPaymentMethodDetailsIdealBank>>, + bic: Option<Option<SetupAttemptPaymentMethodDetailsIdealBic>>, + generated_sepa_debit: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + generated_sepa_debit_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + iban_last4: Option<Option<String>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsIdeal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsIdeal>, + builder: SetupAttemptPaymentMethodDetailsIdealBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsIdeal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsIdealBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsIdealBuilder { + type Out = SetupAttemptPaymentMethodDetailsIdeal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + "bic" => Deserialize::begin(&mut self.bic), + "generated_sepa_debit" => Deserialize::begin(&mut self.generated_sepa_debit), + "generated_sepa_debit_mandate" => Deserialize::begin(&mut self.generated_sepa_debit_mandate), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank: Deserialize::default(), + bic: Deserialize::default(), + generated_sepa_debit: Deserialize::default(), + generated_sepa_debit_mandate: Deserialize::default(), + iban_last4: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + let bic = self.bic.take()?; + let generated_sepa_debit = self.generated_sepa_debit.take()?; + let generated_sepa_debit_mandate = self.generated_sepa_debit_mandate.take()?; + let iban_last4 = self.iban_last4.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank, bic, generated_sepa_debit, generated_sepa_debit_mandate, iban_last4, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsIdeal { + type Builder = SetupAttemptPaymentMethodDetailsIdealBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsIdeal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsIdealBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit" => b.generated_sepa_debit = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit_mandate" => b.generated_sepa_debit_mandate = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The customer's bank. -/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `nn`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. +/// Can be one of `abn_amro`, `asn_bank`, `bunq`, `handelsbanken`, `ing`, `knab`, `moneyou`, `n26`, `rabobank`, `regiobank`, `revolut`, `sns_bank`, `triodos_bank`, `van_lanschot`, or `yoursafe`. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] pub enum SetupAttemptPaymentMethodDetailsIdealBank { @@ -28,7 +143,6 @@ pub enum SetupAttemptPaymentMethodDetailsIdealBank { Knab, Moneyou, N26, - Nn, Rabobank, Regiobank, Revolut, @@ -51,7 +165,6 @@ impl SetupAttemptPaymentMethodDetailsIdealBank { Knab => "knab", Moneyou => "moneyou", N26 => "n26", - Nn => "nn", Rabobank => "rabobank", Regiobank => "regiobank", Revolut => "revolut", @@ -77,7 +190,6 @@ impl std::str::FromStr for SetupAttemptPaymentMethodDetailsIdealBank { "knab" => Ok(Knab), "moneyou" => Ok(Moneyou), "n26" => Ok(N26), - "nn" => Ok(Nn), "rabobank" => Ok(Rabobank), "regiobank" => Ok(Regiobank), "revolut" => Ok(Revolut), @@ -112,9 +224,27 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsIdealBank fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(SetupAttemptPaymentMethodDetailsIdealBank::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsIdealBank { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupAttemptPaymentMethodDetailsIdealBank> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptPaymentMethodDetailsIdealBank::from_str(s).unwrap_or(SetupAttemptPaymentMethodDetailsIdealBank::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsIdealBank); /// The Bank Identifier Code of the customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -128,7 +258,6 @@ pub enum SetupAttemptPaymentMethodDetailsIdealBic { Ingbnl2a, Knabnl2h, Moyonl21, - Nnbanl2g, Ntsbdeb1, Rabonl2u, Rbrbnl21, @@ -152,7 +281,6 @@ impl SetupAttemptPaymentMethodDetailsIdealBic { Ingbnl2a => "INGBNL2A", Knabnl2h => "KNABNL2H", Moyonl21 => "MOYONL21", - Nnbanl2g => "NNBANL2G", Ntsbdeb1 => "NTSBDEB1", Rabonl2u => "RABONL2U", Rbrbnl21 => "RBRBNL21", @@ -179,7 +307,6 @@ impl std::str::FromStr for SetupAttemptPaymentMethodDetailsIdealBic { "INGBNL2A" => Ok(Ingbnl2a), "KNABNL2H" => Ok(Knabnl2h), "MOYONL21" => Ok(Moyonl21), - "NNBANL2G" => Ok(Nnbanl2g), "NTSBDEB1" => Ok(Ntsbdeb1), "RABONL2U" => Ok(Rabonl2u), "RBRBNL21" => Ok(Rbrbnl21), @@ -214,6 +341,24 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsIdealBic { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(SetupAttemptPaymentMethodDetailsIdealBic::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsIdealBic { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupAttemptPaymentMethodDetailsIdealBic> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptPaymentMethodDetailsIdealBic::from_str(s).unwrap_or(SetupAttemptPaymentMethodDetailsIdealBic::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsIdealBic); diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_klarna.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_klarna.rs index 530bbd657..a40c0c1e1 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_klarna.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_klarna.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsKlarna {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsKlarnaBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsKlarna { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsKlarna>, + builder: SetupAttemptPaymentMethodDetailsKlarnaBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsKlarna> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsKlarnaBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsKlarnaBuilder { + type Out = SetupAttemptPaymentMethodDetailsKlarna; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsKlarna { + type Builder = SetupAttemptPaymentMethodDetailsKlarnaBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsKlarna { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsKlarnaBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_link.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_link.rs index cfd19ba47..da95dc5fd 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_link.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_link.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsLink {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsLinkBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsLink>, + builder: SetupAttemptPaymentMethodDetailsLinkBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsLinkBuilder { + type Out = SetupAttemptPaymentMethodDetailsLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsLink { + type Builder = SetupAttemptPaymentMethodDetailsLinkBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_paypal.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_paypal.rs index 915512a00..a0569c7bb 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_paypal.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_paypal.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsPaypal {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsPaypalBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsPaypal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsPaypal>, + builder: SetupAttemptPaymentMethodDetailsPaypalBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsPaypal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsPaypalBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsPaypalBuilder { + type Out = SetupAttemptPaymentMethodDetailsPaypal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsPaypal { + type Builder = SetupAttemptPaymentMethodDetailsPaypalBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsPaypal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsPaypalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_sepa_debit.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_sepa_debit.rs index 2063e17ca..f8b3d10cc 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_sepa_debit.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_sepa_debit.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsSepaDebit {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsSepaDebitBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsSepaDebit>, + builder: SetupAttemptPaymentMethodDetailsSepaDebitBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsSepaDebitBuilder { + type Out = SetupAttemptPaymentMethodDetailsSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsSepaDebit { + type Builder = SetupAttemptPaymentMethodDetailsSepaDebitBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_sofort.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_sofort.rs index fed163ded..6f27860c5 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_sofort.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_sofort.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsSofort { /// Bank code of bank associated with the bank account. pub bank_code: Option<String>, @@ -19,6 +21,129 @@ pub struct SetupAttemptPaymentMethodDetailsSofort { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsSofortBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + generated_sepa_debit: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + generated_sepa_debit_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + iban_last4: Option<Option<String>>, + preferred_language: Option<Option<SetupAttemptPaymentMethodDetailsSofortPreferredLanguage>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsSofort { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsSofort>, + builder: SetupAttemptPaymentMethodDetailsSofortBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsSofort> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsSofortBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsSofortBuilder { + type Out = SetupAttemptPaymentMethodDetailsSofort; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "generated_sepa_debit" => Deserialize::begin(&mut self.generated_sepa_debit), + "generated_sepa_debit_mandate" => Deserialize::begin(&mut self.generated_sepa_debit_mandate), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + bic: Deserialize::default(), + generated_sepa_debit: Deserialize::default(), + generated_sepa_debit_mandate: Deserialize::default(), + iban_last4: Deserialize::default(), + preferred_language: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let generated_sepa_debit = self.generated_sepa_debit.take()?; + let generated_sepa_debit_mandate = self.generated_sepa_debit_mandate.take()?; + let iban_last4 = self.iban_last4.take()?; + let preferred_language = self.preferred_language.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { bank_code, bank_name, bic, generated_sepa_debit, generated_sepa_debit_mandate, iban_last4, preferred_language, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsSofort { + type Builder = SetupAttemptPaymentMethodDetailsSofortBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsSofort { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsSofortBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit" => b.generated_sepa_debit = Some(FromValueOpt::from_value(v)?), + "generated_sepa_debit_mandate" => b.generated_sepa_debit_mandate = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Preferred language of the Sofort authorization page that the customer is redirected to. /// Can be one of `en`, `de`, `fr`, or `nl` #[derive(Copy, Clone, Eq, PartialEq)] @@ -76,10 +201,24 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsSofortPref fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupAttemptPaymentMethodDetailsSofortPreferredLanguage> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsSofortPreferredLanguage); diff --git a/generated/stripe_shared/src/setup_attempt_payment_method_details_us_bank_account.rs b/generated/stripe_shared/src/setup_attempt_payment_method_details_us_bank_account.rs index e8938c099..5e602a0a1 100644 --- a/generated/stripe_shared/src/setup_attempt_payment_method_details_us_bank_account.rs +++ b/generated/stripe_shared/src/setup_attempt_payment_method_details_us_bank_account.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupAttemptPaymentMethodDetailsUsBankAccount {} +#[cfg(feature = "min-ser")] +pub struct SetupAttemptPaymentMethodDetailsUsBankAccountBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupAttemptPaymentMethodDetailsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupAttemptPaymentMethodDetailsUsBankAccount>, + builder: SetupAttemptPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place<SetupAttemptPaymentMethodDetailsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupAttemptPaymentMethodDetailsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupAttemptPaymentMethodDetailsUsBankAccountBuilder { + type Out = SetupAttemptPaymentMethodDetailsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupAttemptPaymentMethodDetailsUsBankAccount { + type Builder = SetupAttemptPaymentMethodDetailsUsBankAccountBuilder; + } + + impl FromValueOpt for SetupAttemptPaymentMethodDetailsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupAttemptPaymentMethodDetailsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent.rs b/generated/stripe_shared/src/setup_intent.rs index 5a775a4d1..bc5a0a497 100644 --- a/generated/stripe_shared/src/setup_intent.rs +++ b/generated/stripe_shared/src/setup_intent.rs @@ -21,7 +21,9 @@ /// Related guide: [Setup Intents API](https://stripe.com/docs/payments/setup-intents) /// /// For more details see <<https://stripe.com/docs/api/setup_intents/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntent { /// ID of the Connect application that created the SetupIntent. pub application: Option<stripe_types::Expandable<stripe_shared::Application>>, @@ -29,11 +31,9 @@ pub struct SetupIntent { /// /// It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. /// It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer. - #[serde(skip_serializing_if = "Option::is_none")] pub attach_to_self: Option<bool>, /// Settings for dynamic payment methods compatible with this Setup Intent - pub automatic_payment_methods: - Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsSetupIntent>, + pub automatic_payment_methods: Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsSetupIntent>, /// Reason for cancellation of this SetupIntent, one of `abandoned`, `requested_by_customer`, or `duplicate`. pub cancellation_reason: Option<stripe_shared::SetupIntentCancellationReason>, /// The client secret of this SetupIntent. Used for client-side retrieval using a publishable key. @@ -77,8 +77,7 @@ pub struct SetupIntent { /// ID of the payment method used with this SetupIntent. pub payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>, /// Information about the payment method configuration used for this Setup Intent. - pub payment_method_configuration_details: - Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>, + pub payment_method_configuration_details: Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>, /// Payment method-specific configuration for this SetupIntent. pub payment_method_options: Option<stripe_shared::SetupIntentPaymentMethodOptions>, /// The list of payment method types (e.g. card) that this SetupIntent is allowed to set up. @@ -94,6 +93,234 @@ pub struct SetupIntent { /// If not provided, this value defaults to `off_session`. pub usage: String, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentBuilder { + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + attach_to_self: Option<Option<bool>>, + automatic_payment_methods: Option<Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsSetupIntent>>, + cancellation_reason: Option<Option<stripe_shared::SetupIntentCancellationReason>>, + client_secret: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + description: Option<Option<String>>, + flow_directions: Option<Option<Vec<stripe_shared::SetupIntentFlowDirections>>>, + id: Option<stripe_shared::SetupIntentId>, + last_setup_error: Option<Option<Box<stripe_shared::ApiErrors>>>, + latest_attempt: Option<Option<stripe_types::Expandable<stripe_shared::SetupAttempt>>>, + livemode: Option<bool>, + mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + next_action: Option<Option<stripe_shared::SetupIntentNextAction>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + payment_method_configuration_details: Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>, + payment_method_options: Option<Option<stripe_shared::SetupIntentPaymentMethodOptions>>, + payment_method_types: Option<Vec<String>>, + single_use_mandate: Option<Option<stripe_types::Expandable<stripe_shared::Mandate>>>, + status: Option<SetupIntentStatus>, + usage: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntent>, + builder: SetupIntentBuilder, + } + + impl Visitor for Place<SetupIntent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentBuilder { + type Out = SetupIntent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "application" => Deserialize::begin(&mut self.application), + "attach_to_self" => Deserialize::begin(&mut self.attach_to_self), + "automatic_payment_methods" => Deserialize::begin(&mut self.automatic_payment_methods), + "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason), + "client_secret" => Deserialize::begin(&mut self.client_secret), + "created" => Deserialize::begin(&mut self.created), + "customer" => Deserialize::begin(&mut self.customer), + "description" => Deserialize::begin(&mut self.description), + "flow_directions" => Deserialize::begin(&mut self.flow_directions), + "id" => Deserialize::begin(&mut self.id), + "last_setup_error" => Deserialize::begin(&mut self.last_setup_error), + "latest_attempt" => Deserialize::begin(&mut self.latest_attempt), + "livemode" => Deserialize::begin(&mut self.livemode), + "mandate" => Deserialize::begin(&mut self.mandate), + "metadata" => Deserialize::begin(&mut self.metadata), + "next_action" => Deserialize::begin(&mut self.next_action), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "payment_method" => Deserialize::begin(&mut self.payment_method), + "payment_method_configuration_details" => Deserialize::begin(&mut self.payment_method_configuration_details), + "payment_method_options" => Deserialize::begin(&mut self.payment_method_options), + "payment_method_types" => Deserialize::begin(&mut self.payment_method_types), + "single_use_mandate" => Deserialize::begin(&mut self.single_use_mandate), + "status" => Deserialize::begin(&mut self.status), + "usage" => Deserialize::begin(&mut self.usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + application: Deserialize::default(), + attach_to_self: Deserialize::default(), + automatic_payment_methods: Deserialize::default(), + cancellation_reason: Deserialize::default(), + client_secret: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + description: Deserialize::default(), + flow_directions: Deserialize::default(), + id: Deserialize::default(), + last_setup_error: Deserialize::default(), + latest_attempt: Deserialize::default(), + livemode: Deserialize::default(), + mandate: Deserialize::default(), + metadata: Deserialize::default(), + next_action: Deserialize::default(), + on_behalf_of: Deserialize::default(), + payment_method: Deserialize::default(), + payment_method_configuration_details: Deserialize::default(), + payment_method_options: Deserialize::default(), + payment_method_types: Deserialize::default(), + single_use_mandate: Deserialize::default(), + status: Deserialize::default(), + usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let application = self.application.take()?; + let attach_to_self = self.attach_to_self.take()?; + let automatic_payment_methods = self.automatic_payment_methods.take()?; + let cancellation_reason = self.cancellation_reason.take()?; + let client_secret = self.client_secret.take()?; + let created = self.created.take()?; + let customer = self.customer.take()?; + let description = self.description.take()?; + let flow_directions = self.flow_directions.take()?; + let id = self.id.take()?; + let last_setup_error = self.last_setup_error.take()?; + let latest_attempt = self.latest_attempt.take()?; + let livemode = self.livemode.take()?; + let mandate = self.mandate.take()?; + let metadata = self.metadata.take()?; + let next_action = self.next_action.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let payment_method = self.payment_method.take()?; + let payment_method_configuration_details = self.payment_method_configuration_details.take()?; + let payment_method_options = self.payment_method_options.take()?; + let payment_method_types = self.payment_method_types.take()?; + let single_use_mandate = self.single_use_mandate.take()?; + let status = self.status.take()?; + let usage = self.usage.take()?; + + Some(Self::Out { + application, + attach_to_self, + automatic_payment_methods, + cancellation_reason, + client_secret, + created, + customer, + description, + flow_directions, + id, + last_setup_error, + latest_attempt, + livemode, + mandate, + metadata, + next_action, + on_behalf_of, + payment_method, + payment_method_configuration_details, + payment_method_options, + payment_method_types, + single_use_mandate, + status, + usage, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntent { + type Builder = SetupIntentBuilder; + } + + impl FromValueOpt for SetupIntent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "attach_to_self" => b.attach_to_self = Some(FromValueOpt::from_value(v)?), + "automatic_payment_methods" => b.automatic_payment_methods = Some(FromValueOpt::from_value(v)?), + "cancellation_reason" => b.cancellation_reason = Some(FromValueOpt::from_value(v)?), + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "flow_directions" => b.flow_directions = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "last_setup_error" => b.last_setup_error = Some(FromValueOpt::from_value(v)?), + "latest_attempt" => b.latest_attempt = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "mandate" => b.mandate = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "next_action" => b.next_action = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "payment_method" => b.payment_method = Some(FromValueOpt::from_value(v)?), + "payment_method_configuration_details" => b.payment_method_configuration_details = Some(FromValueOpt::from_value(v)?), + "payment_method_options" => b.payment_method_options = Some(FromValueOpt::from_value(v)?), + "payment_method_types" => b.payment_method_types = Some(FromValueOpt::from_value(v)?), + "single_use_mandate" => b.single_use_mandate = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "usage" => b.usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// [Status](https://stripe.com/docs/payments/intents#intent-statuses) of this SetupIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `canceled`, or `succeeded`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentStatus { @@ -156,10 +383,27 @@ impl<'de> serde::Deserialize<'de> for SetupIntentStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentStatus); impl stripe_types::Object for SetupIntent { type Id = stripe_shared::SetupIntentId; fn id(&self) -> &Self::Id { @@ -219,11 +463,27 @@ impl<'de> serde::Deserialize<'de> for SetupIntentCancellationReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for SetupIntentCancellationReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentCancellationReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentCancellationReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentCancellationReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentCancellationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentCancellationReason); #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentFlowDirections { Inbound, @@ -273,7 +533,24 @@ impl<'de> serde::Deserialize<'de> for SetupIntentFlowDirections { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentFlowDirections")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentFlowDirections")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentFlowDirections { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentFlowDirections> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentFlowDirections::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentFlowDirections); diff --git a/generated/stripe_shared/src/setup_intent_next_action.rs b/generated/stripe_shared/src/setup_intent_next_action.rs index 896115660..1aa4ed33d 100644 --- a/generated/stripe_shared/src/setup_intent_next_action.rs +++ b/generated/stripe_shared/src/setup_intent_next_action.rs @@ -1,18 +1,122 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentNextAction { - #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp_handle_redirect_or_display_qr_code: - Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>, - #[serde(skip_serializing_if = "Option::is_none")] + pub cashapp_handle_redirect_or_display_qr_code: Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>, pub redirect_to_url: Option<stripe_shared::SetupIntentNextActionRedirectToUrl>, /// Type of the next action to perform, one of `redirect_to_url`, `use_stripe_sdk`, `alipay_handle_redirect`, `oxxo_display_details`, or `verify_with_microdeposits`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: String, /// When confirming a SetupIntent with Stripe.js, Stripe.js depends on the contents of this dictionary to invoke authentication flows. /// The shape of the contents is subject to change and is only intended to be used by Stripe.js. - #[serde(skip_serializing_if = "Option::is_none")] - pub use_stripe_sdk: Option<serde_json::Value>, - #[serde(skip_serializing_if = "Option::is_none")] - pub verify_with_microdeposits: - Option<stripe_shared::SetupIntentNextActionVerifyWithMicrodeposits>, + pub use_stripe_sdk: Option<stripe_types::Value>, + pub verify_with_microdeposits: Option<stripe_shared::SetupIntentNextActionVerifyWithMicrodeposits>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentNextActionBuilder { + cashapp_handle_redirect_or_display_qr_code: Option<Option<stripe_shared::PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode>>, + redirect_to_url: Option<Option<stripe_shared::SetupIntentNextActionRedirectToUrl>>, + type_: Option<String>, + use_stripe_sdk: Option<Option<stripe_types::Value>>, + verify_with_microdeposits: Option<Option<stripe_shared::SetupIntentNextActionVerifyWithMicrodeposits>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentNextAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentNextAction>, + builder: SetupIntentNextActionBuilder, + } + + impl Visitor for Place<SetupIntentNextAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentNextActionBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentNextActionBuilder { + type Out = SetupIntentNextAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "cashapp_handle_redirect_or_display_qr_code" => Deserialize::begin(&mut self.cashapp_handle_redirect_or_display_qr_code), + "redirect_to_url" => Deserialize::begin(&mut self.redirect_to_url), + "type" => Deserialize::begin(&mut self.type_), + "use_stripe_sdk" => Deserialize::begin(&mut self.use_stripe_sdk), + "verify_with_microdeposits" => Deserialize::begin(&mut self.verify_with_microdeposits), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + cashapp_handle_redirect_or_display_qr_code: Deserialize::default(), + redirect_to_url: Deserialize::default(), + type_: Deserialize::default(), + use_stripe_sdk: Deserialize::default(), + verify_with_microdeposits: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let cashapp_handle_redirect_or_display_qr_code = self.cashapp_handle_redirect_or_display_qr_code.take()?; + let redirect_to_url = self.redirect_to_url.take()?; + let type_ = self.type_.take()?; + let use_stripe_sdk = self.use_stripe_sdk.take()?; + let verify_with_microdeposits = self.verify_with_microdeposits.take()?; + + Some(Self::Out { cashapp_handle_redirect_or_display_qr_code, redirect_to_url, type_, use_stripe_sdk, verify_with_microdeposits }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentNextAction { + type Builder = SetupIntentNextActionBuilder; + } + + impl FromValueOpt for SetupIntentNextAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentNextActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "cashapp_handle_redirect_or_display_qr_code" => b.cashapp_handle_redirect_or_display_qr_code = Some(FromValueOpt::from_value(v)?), + "redirect_to_url" => b.redirect_to_url = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "use_stripe_sdk" => b.use_stripe_sdk = Some(FromValueOpt::from_value(v)?), + "verify_with_microdeposits" => b.verify_with_microdeposits = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent_next_action_redirect_to_url.rs b/generated/stripe_shared/src/setup_intent_next_action_redirect_to_url.rs index c999292b4..26be7984c 100644 --- a/generated/stripe_shared/src/setup_intent_next_action_redirect_to_url.rs +++ b/generated/stripe_shared/src/setup_intent_next_action_redirect_to_url.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentNextActionRedirectToUrl { /// If the customer does not exit their browser while authenticating, they will be redirected to this specified URL after completion. pub return_url: Option<String>, /// The URL you must redirect your customer to in order to authenticate. pub url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentNextActionRedirectToUrlBuilder { + return_url: Option<Option<String>>, + url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentNextActionRedirectToUrl { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentNextActionRedirectToUrl>, + builder: SetupIntentNextActionRedirectToUrlBuilder, + } + + impl Visitor for Place<SetupIntentNextActionRedirectToUrl> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentNextActionRedirectToUrlBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentNextActionRedirectToUrlBuilder { + type Out = SetupIntentNextActionRedirectToUrl; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "return_url" => Deserialize::begin(&mut self.return_url), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { return_url: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let return_url = self.return_url.take()?; + let url = self.url.take()?; + + Some(Self::Out { return_url, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentNextActionRedirectToUrl { + type Builder = SetupIntentNextActionRedirectToUrlBuilder; + } + + impl FromValueOpt for SetupIntentNextActionRedirectToUrl { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentNextActionRedirectToUrlBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent_next_action_verify_with_microdeposits.rs b/generated/stripe_shared/src/setup_intent_next_action_verify_with_microdeposits.rs index 5bdda8ebb..07e6440bc 100644 --- a/generated/stripe_shared/src/setup_intent_next_action_verify_with_microdeposits.rs +++ b/generated/stripe_shared/src/setup_intent_next_action_verify_with_microdeposits.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentNextActionVerifyWithMicrodeposits { /// The timestamp when the microdeposits are expected to land. pub arrival_date: stripe_types::Timestamp, @@ -8,6 +10,100 @@ pub struct SetupIntentNextActionVerifyWithMicrodeposits { /// Used to distinguish between different verification methods. pub microdeposit_type: Option<SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentNextActionVerifyWithMicrodepositsBuilder { + arrival_date: Option<stripe_types::Timestamp>, + hosted_verification_url: Option<String>, + microdeposit_type: Option<Option<SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentNextActionVerifyWithMicrodeposits { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentNextActionVerifyWithMicrodeposits>, + builder: SetupIntentNextActionVerifyWithMicrodepositsBuilder, + } + + impl Visitor for Place<SetupIntentNextActionVerifyWithMicrodeposits> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentNextActionVerifyWithMicrodepositsBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentNextActionVerifyWithMicrodepositsBuilder { + type Out = SetupIntentNextActionVerifyWithMicrodeposits; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "arrival_date" => Deserialize::begin(&mut self.arrival_date), + "hosted_verification_url" => Deserialize::begin(&mut self.hosted_verification_url), + "microdeposit_type" => Deserialize::begin(&mut self.microdeposit_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { arrival_date: Deserialize::default(), hosted_verification_url: Deserialize::default(), microdeposit_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let arrival_date = self.arrival_date.take()?; + let hosted_verification_url = self.hosted_verification_url.take()?; + let microdeposit_type = self.microdeposit_type.take()?; + + Some(Self::Out { arrival_date, hosted_verification_url, microdeposit_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentNextActionVerifyWithMicrodeposits { + type Builder = SetupIntentNextActionVerifyWithMicrodepositsBuilder; + } + + impl FromValueOpt for SetupIntentNextActionVerifyWithMicrodeposits { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentNextActionVerifyWithMicrodepositsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "arrival_date" => b.arrival_date = Some(FromValueOpt::from_value(v)?), + "hosted_verification_url" => b.hosted_verification_url = Some(FromValueOpt::from_value(v)?), + "microdeposit_type" => b.microdeposit_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the microdeposit sent to the customer. /// Used to distinguish between different verification methods. #[derive(Copy, Clone, Eq, PartialEq)] @@ -59,10 +155,24 @@ impl<'de> serde::Deserialize<'de> for SetupIntentNextActionVerifyWithMicrodeposi fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType); diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options.rs b/generated/stripe_shared/src/setup_intent_payment_method_options.rs index 69f9c634e..c7869c6e1 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options.rs @@ -1,15 +1,124 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_shared::SetupIntentPaymentMethodOptionsAcssDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::SetupIntentPaymentMethodOptionsCard>, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option<stripe_shared::SetupIntentPaymentMethodOptionsLink>, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option<stripe_shared::SetupIntentPaymentMethodOptionsPaypal>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_shared::SetupIntentPaymentMethodOptionsSepaDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_shared::SetupIntentPaymentMethodOptionsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsBuilder { + acss_debit: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsAcssDebit>>, + card: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsCard>>, + link: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsLink>>, + paypal: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsPaypal>>, + sepa_debit: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsSepaDebit>>, + us_bank_account: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptions>, + builder: SetupIntentPaymentMethodOptionsBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsBuilder { + type Out = SetupIntentPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "card" => Deserialize::begin(&mut self.card), + "link" => Deserialize::begin(&mut self.link), + "paypal" => Deserialize::begin(&mut self.paypal), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + card: Deserialize::default(), + link: Deserialize::default(), + paypal: Deserialize::default(), + sepa_debit: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let card = self.card.take()?; + let link = self.link.take()?; + let paypal = self.paypal.take()?; + let sepa_debit = self.sepa_debit.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { acss_debit, card, link, paypal, sepa_debit, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptions { + type Builder = SetupIntentPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "link" => b.link = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_acss_debit.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_acss_debit.rs index 2bce40999..a073c5f8f 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_acss_debit.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_acss_debit.rs @@ -1,14 +1,107 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsAcssDebit { /// Currency supported by the bank account pub currency: Option<SetupIntentPaymentMethodOptionsAcssDebitCurrency>, - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>, + pub mandate_options: Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsAcssDebitBuilder { + currency: Option<Option<SetupIntentPaymentMethodOptionsAcssDebitCurrency>>, + mandate_options: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>>, + verification_method: Option<Option<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsAcssDebit>, + builder: SetupIntentPaymentMethodOptionsAcssDebitBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsAcssDebitBuilder { + type Out = SetupIntentPaymentMethodOptionsAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "currency" => Deserialize::begin(&mut self.currency), + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { currency: Deserialize::default(), mandate_options: Deserialize::default(), verification_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let currency = self.currency.take()?; + let mandate_options = self.mandate_options.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { currency, mandate_options, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsAcssDebit { + type Builder = SetupIntentPaymentMethodOptionsAcssDebitBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Currency supported by the bank account #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsAcssDebitCurrency { @@ -59,13 +152,27 @@ impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitCu fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentPaymentMethodOptionsAcssDebitCurrency", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsAcssDebitCurrency")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsAcssDebitCurrency> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsAcssDebitCurrency::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsAcssDebitCurrency); /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -119,10 +226,24 @@ impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitVe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod); diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_card.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_card.rs index 189f64e33..481129502 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_card.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_card.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsCard { /// Configuration options for setting up an eMandate for cards issued in India. pub mandate_options: Option<stripe_shared::SetupIntentPaymentMethodOptionsCardMandateOptions>, @@ -8,10 +10,105 @@ pub struct SetupIntentPaymentMethodOptionsCard { pub network: Option<SetupIntentPaymentMethodOptionsCardNetwork>, /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. - /// If not provided, this value defaults to `automatic`. + /// Permitted values include: `automatic` or `any`. + /// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. pub request_three_d_secure: Option<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsCardBuilder { + mandate_options: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsCardMandateOptions>>, + network: Option<Option<SetupIntentPaymentMethodOptionsCardNetwork>>, + request_three_d_secure: Option<Option<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsCard>, + builder: SetupIntentPaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsCardBuilder { + type Out = SetupIntentPaymentMethodOptionsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "network" => Deserialize::begin(&mut self.network), + "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { mandate_options: Deserialize::default(), network: Deserialize::default(), request_three_d_secure: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let mandate_options = self.mandate_options.take()?; + let network = self.network.take()?; + let request_three_d_secure = self.request_three_d_secure.take()?; + + Some(Self::Out { mandate_options, network, request_three_d_secure }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsCard { + type Builder = SetupIntentPaymentMethodOptionsCardBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "request_three_d_secure" => b.request_three_d_secure = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Selected network to process this SetupIntent on. /// Depends on the available networks of the card attached to the setup intent. /// Can be only set confirm-time. @@ -91,20 +188,37 @@ impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardNetwork fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardNetwork") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsCardNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardNetwork); /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. -/// If not provided, this value defaults to `automatic`. +/// Permitted values include: `automatic` or `any`. +/// If not provided, defaults to `automatic`. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, + ChallengeOnly, } impl SetupIntentPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -112,7 +226,7 @@ impl SetupIntentPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", + ChallengeOnly => "challenge_only", } } } @@ -124,7 +238,7 @@ impl std::str::FromStr for SetupIntentPaymentMethodOptionsCardRequestThreeDSecur match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), + "challenge_only" => Ok(ChallengeOnly), _ => Err(()), } } @@ -152,10 +266,24 @@ impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardRequest fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardRequestThreeDSecure> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardRequestThreeDSecure); diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_card_mandate_options.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_card_mandate_options.rs index db15e4d82..e72cf82d9 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_card_mandate_options.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_card_mandate_options.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsCardMandateOptions { /// Amount to be charged for future payments. pub amount: i64, @@ -27,9 +29,141 @@ pub struct SetupIntentPaymentMethodOptionsCardMandateOptions { /// Start date of the mandate or subscription. Start date should not be lesser than yesterday. pub start_date: stripe_types::Timestamp, /// Specifies the type of mandates supported. Possible values are `india`. - pub supported_types: - Option<Vec<SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes>>, + pub supported_types: Option<Vec<SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes>>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder { + amount: Option<i64>, + amount_type: Option<SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + end_date: Option<Option<stripe_types::Timestamp>>, + interval: Option<SetupIntentPaymentMethodOptionsCardMandateOptionsInterval>, + interval_count: Option<Option<u64>>, + reference: Option<String>, + start_date: Option<stripe_types::Timestamp>, + supported_types: Option<Option<Vec<SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsCardMandateOptions>, + builder: SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsCardMandateOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder { + type Out = SetupIntentPaymentMethodOptionsCardMandateOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_type" => Deserialize::begin(&mut self.amount_type), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "end_date" => Deserialize::begin(&mut self.end_date), + "interval" => Deserialize::begin(&mut self.interval), + "interval_count" => Deserialize::begin(&mut self.interval_count), + "reference" => Deserialize::begin(&mut self.reference), + "start_date" => Deserialize::begin(&mut self.start_date), + "supported_types" => Deserialize::begin(&mut self.supported_types), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_type: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + end_date: Deserialize::default(), + interval: Deserialize::default(), + interval_count: Deserialize::default(), + reference: Deserialize::default(), + start_date: Deserialize::default(), + supported_types: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_type = self.amount_type.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let end_date = self.end_date.take()?; + let interval = self.interval.take()?; + let interval_count = self.interval_count.take()?; + let reference = self.reference.take()?; + let start_date = self.start_date.take()?; + let supported_types = self.supported_types.take()?; + + Some(Self::Out { amount, amount_type, currency, description, end_date, interval, interval_count, reference, start_date, supported_types }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsCardMandateOptions { + type Builder = SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsCardMandateOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_type" => b.amount_type = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "end_date" => b.end_date = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "interval_count" => b.interval_count = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "start_date" => b.start_date = Some(FromValueOpt::from_value(v)?), + "supported_types" => b.supported_types = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// One of `fixed` or `maximum`. /// If `fixed`, the `amount` param refers to the exact amount to be charged in future payments. /// If `maximum`, the amount charged can be up to the value passed for the `amount` param. @@ -82,13 +216,27 @@ impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardMandate fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType); /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsCardMandateOptionsInterval { @@ -148,13 +296,27 @@ impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardMandate fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardMandateOptionsInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsCardMandateOptionsInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardMandateOptionsInterval); /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -198,16 +360,28 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsSuppo serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes -{ +impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes); diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_link.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_link.rs index 752428286..7ddd4ed2d 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_link.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_link.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsLink { /// \[Deprecated\] This is a legacy parameter that no longer has any function. pub persistent_token: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsLinkBuilder { + persistent_token: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsLink { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsLink>, + builder: SetupIntentPaymentMethodOptionsLinkBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsLink> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsLinkBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsLinkBuilder { + type Out = SetupIntentPaymentMethodOptionsLink; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "persistent_token" => Deserialize::begin(&mut self.persistent_token), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { persistent_token: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let persistent_token = self.persistent_token.take()?; + + Some(Self::Out { persistent_token }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsLink { + type Builder = SetupIntentPaymentMethodOptionsLinkBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsLink { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsLinkBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "persistent_token" => b.persistent_token = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_acss_debit.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_acss_debit.rs index 76f39b13e..f995adef0 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_acss_debit.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_acss_debit.rs @@ -1,21 +1,127 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit { /// A URL for custom mandate text - #[serde(skip_serializing_if = "Option::is_none")] pub custom_mandate_url: Option<String>, /// List of Stripe products where this mandate can be selected automatically. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for: Option<Vec<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor>>, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. pub interval_description: Option<String>, /// Payment schedule for the mandate. - pub payment_schedule: - Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>, + pub payment_schedule: Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>, /// Transaction type of the mandate. - pub transaction_type: - Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>, + pub transaction_type: Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder { + custom_mandate_url: Option<Option<String>>, + default_for: Option<Option<Vec<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor>>>, + interval_description: Option<Option<String>>, + payment_schedule: Option<Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule>>, + transaction_type: Option<Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit>, + builder: SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder { + type Out = SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "custom_mandate_url" => Deserialize::begin(&mut self.custom_mandate_url), + "default_for" => Deserialize::begin(&mut self.default_for), + "interval_description" => Deserialize::begin(&mut self.interval_description), + "payment_schedule" => Deserialize::begin(&mut self.payment_schedule), + "transaction_type" => Deserialize::begin(&mut self.transaction_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + custom_mandate_url: Deserialize::default(), + default_for: Deserialize::default(), + interval_description: Deserialize::default(), + payment_schedule: Deserialize::default(), + transaction_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let custom_mandate_url = self.custom_mandate_url.take()?; + let default_for = self.default_for.take()?; + let interval_description = self.interval_description.take()?; + let payment_schedule = self.payment_schedule.take()?; + let transaction_type = self.transaction_type.take()?; + + Some(Self::Out { custom_mandate_url, default_for, interval_description, payment_schedule, transaction_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit { + type Builder = SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "custom_mandate_url" => b.custom_mandate_url = Some(FromValueOpt::from_value(v)?), + "default_for" => b.default_for = Some(FromValueOpt::from_value(v)?), + "interval_description" => b.interval_description = Some(FromValueOpt::from_value(v)?), + "payment_schedule" => b.payment_schedule = Some(FromValueOpt::from_value(v)?), + "transaction_type" => b.transaction_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// List of Stripe products where this mandate can be selected automatically. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor { @@ -62,15 +168,31 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor -{ +impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor); /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { @@ -120,15 +242,31 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule -{ +impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule); /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { @@ -175,12 +313,28 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType -{ +impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType); diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_sepa_debit.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_sepa_debit.rs index 810fb8543..fe236b278 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_sepa_debit.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_mandate_options_sepa_debit.rs @@ -1,2 +1,82 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit {} +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit>, + builder: SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder { + type Out = SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit { + type Builder = SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_paypal.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_paypal.rs index 359203a15..edb498239 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_paypal.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_paypal.rs @@ -1,6 +1,94 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsPaypal { /// The PayPal Billing Agreement ID (BAID). /// This is an ID generated by PayPal which represents the mandate between the merchant and the customer. pub billing_agreement_id: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsPaypalBuilder { + billing_agreement_id: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsPaypal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsPaypal>, + builder: SetupIntentPaymentMethodOptionsPaypalBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsPaypal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsPaypalBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsPaypalBuilder { + type Out = SetupIntentPaymentMethodOptionsPaypal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_agreement_id" => Deserialize::begin(&mut self.billing_agreement_id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_agreement_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_agreement_id = self.billing_agreement_id.take()?; + + Some(Self::Out { billing_agreement_id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsPaypal { + type Builder = SetupIntentPaymentMethodOptionsPaypalBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsPaypal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsPaypalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_agreement_id" => b.billing_agreement_id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_sepa_debit.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_sepa_debit.rs index 57fb0d3e5..ac6e019c4 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_sepa_debit.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_sepa_debit.rs @@ -1,6 +1,92 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsSepaDebit { - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: - Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit>, + pub mandate_options: Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsSepaDebitBuilder { + mandate_options: Option<Option<stripe_shared::SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsSepaDebit>, + builder: SetupIntentPaymentMethodOptionsSepaDebitBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsSepaDebitBuilder { + type Out = SetupIntentPaymentMethodOptionsSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { mandate_options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let mandate_options = self.mandate_options.take()?; + + Some(Self::Out { mandate_options }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsSepaDebit { + type Builder = SetupIntentPaymentMethodOptionsSepaDebitBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/setup_intent_payment_method_options_us_bank_account.rs b/generated/stripe_shared/src/setup_intent_payment_method_options_us_bank_account.rs index da3226828..40a468e12 100644 --- a/generated/stripe_shared/src/setup_intent_payment_method_options_us_bank_account.rs +++ b/generated/stripe_shared/src/setup_intent_payment_method_options_us_bank_account.rs @@ -1,13 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SetupIntentPaymentMethodOptionsUsBankAccount { - #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections: Option<stripe_shared::LinkedAccountOptionsUsBankAccount>, - #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<stripe_shared::PaymentMethodOptionsUsBankAccountMandateOptions>, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option<SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>, } +#[cfg(feature = "min-ser")] +pub struct SetupIntentPaymentMethodOptionsUsBankAccountBuilder { + financial_connections: Option<Option<stripe_shared::LinkedAccountOptionsUsBankAccount>>, + verification_method: Option<Option<SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SetupIntentPaymentMethodOptionsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SetupIntentPaymentMethodOptionsUsBankAccount>, + builder: SetupIntentPaymentMethodOptionsUsBankAccountBuilder, + } + + impl Visitor for Place<SetupIntentPaymentMethodOptionsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SetupIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for SetupIntentPaymentMethodOptionsUsBankAccountBuilder { + type Out = SetupIntentPaymentMethodOptionsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "financial_connections" => Deserialize::begin(&mut self.financial_connections), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { financial_connections: Deserialize::default(), verification_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let financial_connections = self.financial_connections.take()?; + let verification_method = self.verification_method.take()?; + + Some(Self::Out { financial_connections, verification_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SetupIntentPaymentMethodOptionsUsBankAccount { + type Builder = SetupIntentPaymentMethodOptionsUsBankAccountBuilder; + } + + impl FromValueOpt for SetupIntentPaymentMethodOptionsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SetupIntentPaymentMethodOptionsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "financial_connections" => b.financial_connections = Some(FromValueOpt::from_value(v)?), + "verification_method" => b.verification_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -57,16 +145,28 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsUsBankAccountVerificati serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod -{ +impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod); diff --git a/generated/stripe_shared/src/shipping.rs b/generated/stripe_shared/src/shipping.rs index 4599cf4a5..a85b480c0 100644 --- a/generated/stripe_shared/src/shipping.rs +++ b/generated/stripe_shared/src/shipping.rs @@ -1,18 +1,117 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Shipping { - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option<stripe_shared::Address>, /// The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc. - #[serde(skip_serializing_if = "Option::is_none")] pub carrier: Option<String>, /// Recipient name. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, /// Recipient phone (including extension). - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option<String>, /// The tracking number for a physical product, obtained from the delivery service. /// If multiple tracking numbers were generated for this purchase, please separate them with commas. - #[serde(skip_serializing_if = "Option::is_none")] pub tracking_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct ShippingBuilder { + address: Option<Option<stripe_shared::Address>>, + carrier: Option<Option<String>>, + name: Option<Option<String>>, + phone: Option<Option<String>>, + tracking_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Shipping { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Shipping>, + builder: ShippingBuilder, + } + + impl Visitor for Place<Shipping> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ShippingBuilder::deser_default() })) + } + } + + impl MapBuilder for ShippingBuilder { + type Out = Shipping; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "carrier" => Deserialize::begin(&mut self.carrier), + "name" => Deserialize::begin(&mut self.name), + "phone" => Deserialize::begin(&mut self.phone), + "tracking_number" => Deserialize::begin(&mut self.tracking_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address: Deserialize::default(), carrier: Deserialize::default(), name: Deserialize::default(), phone: Deserialize::default(), tracking_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let carrier = self.carrier.take()?; + let name = self.name.take()?; + let phone = self.phone.take()?; + let tracking_number = self.tracking_number.take()?; + + Some(Self::Out { address, carrier, name, phone, tracking_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Shipping { + type Builder = ShippingBuilder; + } + + impl FromValueOpt for Shipping { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ShippingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "carrier" => b.carrier = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + "tracking_number" => b.tracking_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/shipping_rate.rs b/generated/stripe_shared/src/shipping_rate.rs index b11603669..6c8e43729 100644 --- a/generated/stripe_shared/src/shipping_rate.rs +++ b/generated/stripe_shared/src/shipping_rate.rs @@ -3,7 +3,9 @@ /// For more information, see [Charge for shipping](https://stripe.com/docs/payments/during-payment/charge-shipping). /// /// For more details see <<https://stripe.com/docs/api/shipping_rates/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ShippingRate { /// Whether the shipping rate can be used for new purchases. Defaults to `true`. pub active: bool, @@ -15,7 +17,6 @@ pub struct ShippingRate { /// The name of the shipping rate, meant to be displayable to the customer. /// This will appear on CheckoutSessions. pub display_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub fixed_amount: Option<stripe_shared::ShippingRateFixedAmount>, /// Unique identifier for the object. pub id: stripe_shared::ShippingRateId, @@ -31,9 +32,147 @@ pub struct ShippingRate { /// The Shipping tax code is `txcd_92010001`. pub tax_code: Option<stripe_types::Expandable<stripe_shared::TaxCode>>, /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: stripe_shared::ShippingRateType, } +#[cfg(feature = "min-ser")] +pub struct ShippingRateBuilder { + active: Option<bool>, + created: Option<stripe_types::Timestamp>, + delivery_estimate: Option<Option<stripe_shared::ShippingRateDeliveryEstimate>>, + display_name: Option<Option<String>>, + fixed_amount: Option<Option<stripe_shared::ShippingRateFixedAmount>>, + id: Option<stripe_shared::ShippingRateId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + tax_behavior: Option<Option<stripe_shared::ShippingRateTaxBehavior>>, + tax_code: Option<Option<stripe_types::Expandable<stripe_shared::TaxCode>>>, + type_: Option<stripe_shared::ShippingRateType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ShippingRate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ShippingRate>, + builder: ShippingRateBuilder, + } + + impl Visitor for Place<ShippingRate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ShippingRateBuilder::deser_default() })) + } + } + + impl MapBuilder for ShippingRateBuilder { + type Out = ShippingRate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "created" => Deserialize::begin(&mut self.created), + "delivery_estimate" => Deserialize::begin(&mut self.delivery_estimate), + "display_name" => Deserialize::begin(&mut self.display_name), + "fixed_amount" => Deserialize::begin(&mut self.fixed_amount), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tax_code" => Deserialize::begin(&mut self.tax_code), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + created: Deserialize::default(), + delivery_estimate: Deserialize::default(), + display_name: Deserialize::default(), + fixed_amount: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + tax_behavior: Deserialize::default(), + tax_code: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let created = self.created.take()?; + let delivery_estimate = self.delivery_estimate.take()?; + let display_name = self.display_name.take()?; + let fixed_amount = self.fixed_amount.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let tax_behavior = self.tax_behavior.take()?; + let tax_code = self.tax_code.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { active, created, delivery_estimate, display_name, fixed_amount, id, livemode, metadata, tax_behavior, tax_code, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ShippingRate { + type Builder = ShippingRateBuilder; + } + + impl FromValueOpt for ShippingRate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ShippingRateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "delivery_estimate" => b.delivery_estimate = Some(FromValueOpt::from_value(v)?), + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "fixed_amount" => b.fixed_amount = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + "tax_code" => b.tax_code = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for ShippingRate { type Id = stripe_shared::ShippingRateId; fn id(&self) -> &Self::Id { @@ -93,10 +232,27 @@ impl<'de> serde::Deserialize<'de> for ShippingRateTaxBehavior { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ShippingRateTaxBehavior")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ShippingRateTaxBehavior")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ShippingRateTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ShippingRateTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ShippingRateTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ShippingRateTaxBehavior); #[derive(Copy, Clone, Eq, PartialEq)] pub enum ShippingRateType { FixedAmount, @@ -143,7 +299,24 @@ impl<'de> serde::Deserialize<'de> for ShippingRateType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ShippingRateType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ShippingRateType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ShippingRateType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ShippingRateType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ShippingRateType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ShippingRateType); diff --git a/generated/stripe_shared/src/shipping_rate_currency_option.rs b/generated/stripe_shared/src/shipping_rate_currency_option.rs index a1fcafacd..49333bf0c 100644 --- a/generated/stripe_shared/src/shipping_rate_currency_option.rs +++ b/generated/stripe_shared/src/shipping_rate_currency_option.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ShippingRateCurrencyOption { /// A non-negative integer in cents representing how much to charge. pub amount: i64, @@ -6,6 +8,96 @@ pub struct ShippingRateCurrencyOption { /// One of `inclusive`, `exclusive`, or `unspecified`. pub tax_behavior: ShippingRateCurrencyOptionTaxBehavior, } +#[cfg(feature = "min-ser")] +pub struct ShippingRateCurrencyOptionBuilder { + amount: Option<i64>, + tax_behavior: Option<ShippingRateCurrencyOptionTaxBehavior>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ShippingRateCurrencyOption { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ShippingRateCurrencyOption>, + builder: ShippingRateCurrencyOptionBuilder, + } + + impl Visitor for Place<ShippingRateCurrencyOption> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ShippingRateCurrencyOptionBuilder::deser_default() })) + } + } + + impl MapBuilder for ShippingRateCurrencyOptionBuilder { + type Out = ShippingRateCurrencyOption; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), tax_behavior: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let tax_behavior = self.tax_behavior.take()?; + + Some(Self::Out { amount, tax_behavior }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ShippingRateCurrencyOption { + type Builder = ShippingRateCurrencyOptionBuilder; + } + + impl FromValueOpt for ShippingRateCurrencyOption { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ShippingRateCurrencyOptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "tax_behavior" => b.tax_behavior = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -60,8 +152,24 @@ impl<'de> serde::Deserialize<'de> for ShippingRateCurrencyOptionTaxBehavior { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ShippingRateCurrencyOptionTaxBehavior") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ShippingRateCurrencyOptionTaxBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ShippingRateCurrencyOptionTaxBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ShippingRateCurrencyOptionTaxBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ShippingRateCurrencyOptionTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ShippingRateCurrencyOptionTaxBehavior); diff --git a/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs b/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs index 16875264f..3554e7847 100644 --- a/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs +++ b/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ShippingRateDeliveryEstimate { /// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. pub maximum: Option<stripe_shared::ShippingRateDeliveryEstimateBound>, /// The lower bound of the estimated range. If empty, represents no lower bound. pub minimum: Option<stripe_shared::ShippingRateDeliveryEstimateBound>, } +#[cfg(feature = "min-ser")] +pub struct ShippingRateDeliveryEstimateBuilder { + maximum: Option<Option<stripe_shared::ShippingRateDeliveryEstimateBound>>, + minimum: Option<Option<stripe_shared::ShippingRateDeliveryEstimateBound>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ShippingRateDeliveryEstimate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ShippingRateDeliveryEstimate>, + builder: ShippingRateDeliveryEstimateBuilder, + } + + impl Visitor for Place<ShippingRateDeliveryEstimate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ShippingRateDeliveryEstimateBuilder::deser_default() })) + } + } + + impl MapBuilder for ShippingRateDeliveryEstimateBuilder { + type Out = ShippingRateDeliveryEstimate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "maximum" => Deserialize::begin(&mut self.maximum), + "minimum" => Deserialize::begin(&mut self.minimum), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum: Deserialize::default(), minimum: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let maximum = self.maximum.take()?; + let minimum = self.minimum.take()?; + + Some(Self::Out { maximum, minimum }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ShippingRateDeliveryEstimate { + type Builder = ShippingRateDeliveryEstimateBuilder; + } + + impl FromValueOpt for ShippingRateDeliveryEstimate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ShippingRateDeliveryEstimateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "maximum" => b.maximum = Some(FromValueOpt::from_value(v)?), + "minimum" => b.minimum = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/shipping_rate_delivery_estimate_bound.rs b/generated/stripe_shared/src/shipping_rate_delivery_estimate_bound.rs index 87372926b..63d43cc94 100644 --- a/generated/stripe_shared/src/shipping_rate_delivery_estimate_bound.rs +++ b/generated/stripe_shared/src/shipping_rate_delivery_estimate_bound.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ShippingRateDeliveryEstimateBound { /// A unit of time. pub unit: ShippingRateDeliveryEstimateBoundUnit, /// Must be greater than 0. pub value: i64, } +#[cfg(feature = "min-ser")] +pub struct ShippingRateDeliveryEstimateBoundBuilder { + unit: Option<ShippingRateDeliveryEstimateBoundUnit>, + value: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ShippingRateDeliveryEstimateBound { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ShippingRateDeliveryEstimateBound>, + builder: ShippingRateDeliveryEstimateBoundBuilder, + } + + impl Visitor for Place<ShippingRateDeliveryEstimateBound> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ShippingRateDeliveryEstimateBoundBuilder::deser_default() })) + } + } + + impl MapBuilder for ShippingRateDeliveryEstimateBoundBuilder { + type Out = ShippingRateDeliveryEstimateBound; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "unit" => Deserialize::begin(&mut self.unit), + "value" => Deserialize::begin(&mut self.value), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { unit: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let unit = self.unit.take()?; + let value = self.value.take()?; + + Some(Self::Out { unit, value }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ShippingRateDeliveryEstimateBound { + type Builder = ShippingRateDeliveryEstimateBoundBuilder; + } + + impl FromValueOpt for ShippingRateDeliveryEstimateBound { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ShippingRateDeliveryEstimateBoundBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "unit" => b.unit = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// A unit of time. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ShippingRateDeliveryEstimateBoundUnit { @@ -64,8 +156,24 @@ impl<'de> serde::Deserialize<'de> for ShippingRateDeliveryEstimateBoundUnit { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ShippingRateDeliveryEstimateBoundUnit") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ShippingRateDeliveryEstimateBoundUnit")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ShippingRateDeliveryEstimateBoundUnit { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ShippingRateDeliveryEstimateBoundUnit> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ShippingRateDeliveryEstimateBoundUnit::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ShippingRateDeliveryEstimateBoundUnit); diff --git a/generated/stripe_shared/src/shipping_rate_fixed_amount.rs b/generated/stripe_shared/src/shipping_rate_fixed_amount.rs index 8259a0bbf..bf5d5afe0 100644 --- a/generated/stripe_shared/src/shipping_rate_fixed_amount.rs +++ b/generated/stripe_shared/src/shipping_rate_fixed_amount.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ShippingRateFixedAmount { /// A non-negative integer in cents representing how much to charge. pub amount: i64, @@ -7,11 +9,99 @@ pub struct ShippingRateFixedAmount { pub currency: stripe_types::Currency, /// Shipping rates defined in each available currency option. /// Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). - #[serde(skip_serializing_if = "Option::is_none")] - pub currency_options: Option< - std::collections::HashMap< - stripe_types::Currency, - stripe_shared::ShippingRateCurrencyOption, - >, - >, + pub currency_options: Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::ShippingRateCurrencyOption>>, } +#[cfg(feature = "min-ser")] +pub struct ShippingRateFixedAmountBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, + currency_options: Option<Option<std::collections::HashMap<stripe_types::Currency, stripe_shared::ShippingRateCurrencyOption>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ShippingRateFixedAmount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ShippingRateFixedAmount>, + builder: ShippingRateFixedAmountBuilder, + } + + impl Visitor for Place<ShippingRateFixedAmount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ShippingRateFixedAmountBuilder::deser_default() })) + } + } + + impl MapBuilder for ShippingRateFixedAmountBuilder { + type Out = ShippingRateFixedAmount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "currency_options" => Deserialize::begin(&mut self.currency_options), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default(), currency_options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let currency_options = self.currency_options.take()?; + + Some(Self::Out { amount, currency, currency_options }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ShippingRateFixedAmount { + type Builder = ShippingRateFixedAmountBuilder; + } + + impl FromValueOpt for ShippingRateFixedAmount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ShippingRateFixedAmountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "currency_options" => b.currency_options = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source.rs b/generated/stripe_shared/src/source.rs index e34a1fde9..bd625dc16 100644 --- a/generated/stripe_shared/src/source.rs +++ b/generated/stripe_shared/src/source.rs @@ -10,31 +10,24 @@ /// Related guides: [Sources API](https://stripe.com/docs/sources) and [Sources & Customers](https://stripe.com/docs/sources/customers). /// /// For more details see <<https://stripe.com/docs/api/sources/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Source { - #[serde(skip_serializing_if = "Option::is_none")] pub ach_credit_transfer: Option<stripe_shared::SourceTypeAchCreditTransfer>, - #[serde(skip_serializing_if = "Option::is_none")] pub ach_debit: Option<stripe_shared::SourceTypeAchDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option<stripe_shared::SourceTypeAcssDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option<stripe_shared::SourceTypeAlipay>, /// A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount associated with the source. /// This is the amount for which the source will be chargeable once ready. /// Required for `single_use` sources. pub amount: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option<stripe_shared::SourceTypeAuBecsDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option<stripe_shared::SourceTypeBancontact>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<stripe_shared::SourceTypeCard>, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option<stripe_shared::SourceTypeCardPresent>, /// The client secret of the source. Used for client-side retrieval using a publishable key. pub client_secret: String, - #[serde(skip_serializing_if = "Option::is_none")] pub code_verification: Option<stripe_shared::SourceCodeVerificationFlow>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -44,43 +37,30 @@ pub struct Source { pub currency: Option<stripe_types::Currency>, /// The ID of the customer to which this source is attached. /// This will not be present when the source has not been attached to a customer. - #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option<stripe_shared::SourceTypeEps>, /// The authentication `flow` of the source. /// `flow` is one of `redirect`, `receiver`, `code_verification`, `none`. pub flow: String, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option<stripe_shared::SourceTypeGiropay>, /// Unique identifier for the object. pub id: stripe_shared::SourceId, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option<stripe_shared::SourceTypeIdeal>, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option<stripe_shared::SourceTypeKlarna>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. pub metadata: Option<std::collections::HashMap<String, String>>, - #[serde(skip_serializing_if = "Option::is_none")] pub multibanco: Option<stripe_shared::SourceTypeMultibanco>, /// Information about the owner of the payment instrument that may be used or required by particular source types. pub owner: Option<stripe_shared::SourceOwner>, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option<stripe_shared::SourceTypeP24>, - #[serde(skip_serializing_if = "Option::is_none")] pub receiver: Option<stripe_shared::SourceReceiverFlow>, - #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option<stripe_shared::SourceRedirectFlow>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_credit_transfer: Option<stripe_shared::SourceTypeSepaCreditTransfer>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option<stripe_shared::SourceTypeSepaDebit>, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option<stripe_shared::SourceTypeSofort>, - #[serde(skip_serializing_if = "Option::is_none")] pub source_order: Option<stripe_shared::SourceOrder>, /// Extra information about a source. /// This will appear on your customer's statement every time you charge the source. @@ -88,22 +68,326 @@ pub struct Source { /// The status of the source, one of `canceled`, `chargeable`, `consumed`, `failed`, or `pending`. /// Only `chargeable` sources can be used to create a charge. pub status: String, - #[serde(skip_serializing_if = "Option::is_none")] pub three_d_secure: Option<stripe_shared::SourceTypeThreeDSecure>, /// The `type` of the source. /// The `type` is a payment method, one of `ach_credit_transfer`, `ach_debit`, `alipay`, `bancontact`, `card`, `card_present`, `eps`, `giropay`, `ideal`, `multibanco`, `klarna`, `p24`, `sepa_debit`, `sofort`, `three_d_secure`, or `wechat`. /// An additional hash is included on the source with a name matching this value. /// It contains additional information specific to the [payment method](https://stripe.com/docs/sources) used. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: SourceType, /// Either `reusable` or `single_use`. /// Whether this source should be reusable or not. /// Some source types may or may not be reusable by construction, while others may leave the option at creation. /// If an incompatible value is passed, an error will be returned. pub usage: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat: Option<stripe_shared::SourceTypeWechat>, } +#[cfg(feature = "min-ser")] +pub struct SourceBuilder { + ach_credit_transfer: Option<Option<stripe_shared::SourceTypeAchCreditTransfer>>, + ach_debit: Option<Option<stripe_shared::SourceTypeAchDebit>>, + acss_debit: Option<Option<stripe_shared::SourceTypeAcssDebit>>, + alipay: Option<Option<stripe_shared::SourceTypeAlipay>>, + amount: Option<Option<i64>>, + au_becs_debit: Option<Option<stripe_shared::SourceTypeAuBecsDebit>>, + bancontact: Option<Option<stripe_shared::SourceTypeBancontact>>, + card: Option<Option<stripe_shared::SourceTypeCard>>, + card_present: Option<Option<stripe_shared::SourceTypeCardPresent>>, + client_secret: Option<String>, + code_verification: Option<Option<stripe_shared::SourceCodeVerificationFlow>>, + created: Option<stripe_types::Timestamp>, + currency: Option<Option<stripe_types::Currency>>, + customer: Option<Option<String>>, + eps: Option<Option<stripe_shared::SourceTypeEps>>, + flow: Option<String>, + giropay: Option<Option<stripe_shared::SourceTypeGiropay>>, + id: Option<stripe_shared::SourceId>, + ideal: Option<Option<stripe_shared::SourceTypeIdeal>>, + klarna: Option<Option<stripe_shared::SourceTypeKlarna>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + multibanco: Option<Option<stripe_shared::SourceTypeMultibanco>>, + owner: Option<Option<stripe_shared::SourceOwner>>, + p24: Option<Option<stripe_shared::SourceTypeP24>>, + receiver: Option<Option<stripe_shared::SourceReceiverFlow>>, + redirect: Option<Option<stripe_shared::SourceRedirectFlow>>, + sepa_credit_transfer: Option<Option<stripe_shared::SourceTypeSepaCreditTransfer>>, + sepa_debit: Option<Option<stripe_shared::SourceTypeSepaDebit>>, + sofort: Option<Option<stripe_shared::SourceTypeSofort>>, + source_order: Option<Option<stripe_shared::SourceOrder>>, + statement_descriptor: Option<Option<String>>, + status: Option<String>, + three_d_secure: Option<Option<stripe_shared::SourceTypeThreeDSecure>>, + type_: Option<SourceType>, + usage: Option<Option<String>>, + wechat: Option<Option<stripe_shared::SourceTypeWechat>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Source { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Source>, + builder: SourceBuilder, + } + + impl Visitor for Place<Source> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceBuilder { + type Out = Source; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ach_credit_transfer" => Deserialize::begin(&mut self.ach_credit_transfer), + "ach_debit" => Deserialize::begin(&mut self.ach_debit), + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "alipay" => Deserialize::begin(&mut self.alipay), + "amount" => Deserialize::begin(&mut self.amount), + "au_becs_debit" => Deserialize::begin(&mut self.au_becs_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "card" => Deserialize::begin(&mut self.card), + "card_present" => Deserialize::begin(&mut self.card_present), + "client_secret" => Deserialize::begin(&mut self.client_secret), + "code_verification" => Deserialize::begin(&mut self.code_verification), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "eps" => Deserialize::begin(&mut self.eps), + "flow" => Deserialize::begin(&mut self.flow), + "giropay" => Deserialize::begin(&mut self.giropay), + "id" => Deserialize::begin(&mut self.id), + "ideal" => Deserialize::begin(&mut self.ideal), + "klarna" => Deserialize::begin(&mut self.klarna), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "multibanco" => Deserialize::begin(&mut self.multibanco), + "owner" => Deserialize::begin(&mut self.owner), + "p24" => Deserialize::begin(&mut self.p24), + "receiver" => Deserialize::begin(&mut self.receiver), + "redirect" => Deserialize::begin(&mut self.redirect), + "sepa_credit_transfer" => Deserialize::begin(&mut self.sepa_credit_transfer), + "sepa_debit" => Deserialize::begin(&mut self.sepa_debit), + "sofort" => Deserialize::begin(&mut self.sofort), + "source_order" => Deserialize::begin(&mut self.source_order), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "status" => Deserialize::begin(&mut self.status), + "three_d_secure" => Deserialize::begin(&mut self.three_d_secure), + "type" => Deserialize::begin(&mut self.type_), + "usage" => Deserialize::begin(&mut self.usage), + "wechat" => Deserialize::begin(&mut self.wechat), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + ach_credit_transfer: Deserialize::default(), + ach_debit: Deserialize::default(), + acss_debit: Deserialize::default(), + alipay: Deserialize::default(), + amount: Deserialize::default(), + au_becs_debit: Deserialize::default(), + bancontact: Deserialize::default(), + card: Deserialize::default(), + card_present: Deserialize::default(), + client_secret: Deserialize::default(), + code_verification: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + eps: Deserialize::default(), + flow: Deserialize::default(), + giropay: Deserialize::default(), + id: Deserialize::default(), + ideal: Deserialize::default(), + klarna: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + multibanco: Deserialize::default(), + owner: Deserialize::default(), + p24: Deserialize::default(), + receiver: Deserialize::default(), + redirect: Deserialize::default(), + sepa_credit_transfer: Deserialize::default(), + sepa_debit: Deserialize::default(), + sofort: Deserialize::default(), + source_order: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + three_d_secure: Deserialize::default(), + type_: Deserialize::default(), + usage: Deserialize::default(), + wechat: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ach_credit_transfer = self.ach_credit_transfer.take()?; + let ach_debit = self.ach_debit.take()?; + let acss_debit = self.acss_debit.take()?; + let alipay = self.alipay.take()?; + let amount = self.amount.take()?; + let au_becs_debit = self.au_becs_debit.take()?; + let bancontact = self.bancontact.take()?; + let card = self.card.take()?; + let card_present = self.card_present.take()?; + let client_secret = self.client_secret.take()?; + let code_verification = self.code_verification.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let eps = self.eps.take()?; + let flow = self.flow.take()?; + let giropay = self.giropay.take()?; + let id = self.id.take()?; + let ideal = self.ideal.take()?; + let klarna = self.klarna.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let multibanco = self.multibanco.take()?; + let owner = self.owner.take()?; + let p24 = self.p24.take()?; + let receiver = self.receiver.take()?; + let redirect = self.redirect.take()?; + let sepa_credit_transfer = self.sepa_credit_transfer.take()?; + let sepa_debit = self.sepa_debit.take()?; + let sofort = self.sofort.take()?; + let source_order = self.source_order.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let status = self.status.take()?; + let three_d_secure = self.three_d_secure.take()?; + let type_ = self.type_.take()?; + let usage = self.usage.take()?; + let wechat = self.wechat.take()?; + + Some(Self::Out { + ach_credit_transfer, + ach_debit, + acss_debit, + alipay, + amount, + au_becs_debit, + bancontact, + card, + card_present, + client_secret, + code_verification, + created, + currency, + customer, + eps, + flow, + giropay, + id, + ideal, + klarna, + livemode, + metadata, + multibanco, + owner, + p24, + receiver, + redirect, + sepa_credit_transfer, + sepa_debit, + sofort, + source_order, + statement_descriptor, + status, + three_d_secure, + type_, + usage, + wechat, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Source { + type Builder = SourceBuilder; + } + + impl FromValueOpt for Source { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ach_credit_transfer" => b.ach_credit_transfer = Some(FromValueOpt::from_value(v)?), + "ach_debit" => b.ach_debit = Some(FromValueOpt::from_value(v)?), + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "alipay" => b.alipay = Some(FromValueOpt::from_value(v)?), + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "au_becs_debit" => b.au_becs_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "card_present" => b.card_present = Some(FromValueOpt::from_value(v)?), + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "code_verification" => b.code_verification = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "eps" => b.eps = Some(FromValueOpt::from_value(v)?), + "flow" => b.flow = Some(FromValueOpt::from_value(v)?), + "giropay" => b.giropay = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "ideal" => b.ideal = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "multibanco" => b.multibanco = Some(FromValueOpt::from_value(v)?), + "owner" => b.owner = Some(FromValueOpt::from_value(v)?), + "p24" => b.p24 = Some(FromValueOpt::from_value(v)?), + "receiver" => b.receiver = Some(FromValueOpt::from_value(v)?), + "redirect" => b.redirect = Some(FromValueOpt::from_value(v)?), + "sepa_credit_transfer" => b.sepa_credit_transfer = Some(FromValueOpt::from_value(v)?), + "sepa_debit" => b.sepa_debit = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "source_order" => b.source_order = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "three_d_secure" => b.three_d_secure = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "usage" => b.usage = Some(FromValueOpt::from_value(v)?), + "wechat" => b.wechat = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The `type` of the source. /// The `type` is a payment method, one of `ach_credit_transfer`, `ach_debit`, `alipay`, `bancontact`, `card`, `card_present`, `eps`, `giropay`, `ideal`, `multibanco`, `klarna`, `p24`, `sepa_debit`, `sofort`, `three_d_secure`, or `wechat`. /// An additional hash is included on the source with a name matching this value. @@ -212,9 +496,27 @@ impl<'de> serde::Deserialize<'de> for SourceType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(SourceType::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SourceType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SourceType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SourceType::from_str(s).unwrap_or(SourceType::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SourceType); impl stripe_types::Object for Source { type Id = stripe_shared::SourceId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/source_code_verification_flow.rs b/generated/stripe_shared/src/source_code_verification_flow.rs index ebaa0cc38..d5247a0d6 100644 --- a/generated/stripe_shared/src/source_code_verification_flow.rs +++ b/generated/stripe_shared/src/source_code_verification_flow.rs @@ -1,7 +1,99 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceCodeVerificationFlow { /// The number of attempts remaining to authenticate the source object with a verification code. pub attempts_remaining: i64, /// The status of the code verification, either `pending` (awaiting verification, `attempts_remaining` should be greater than 0), `succeeded` (successful verification) or `failed` (failed verification, cannot be verified anymore as `attempts_remaining` should be 0). pub status: String, } +#[cfg(feature = "min-ser")] +pub struct SourceCodeVerificationFlowBuilder { + attempts_remaining: Option<i64>, + status: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceCodeVerificationFlow { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceCodeVerificationFlow>, + builder: SourceCodeVerificationFlowBuilder, + } + + impl Visitor for Place<SourceCodeVerificationFlow> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceCodeVerificationFlowBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceCodeVerificationFlowBuilder { + type Out = SourceCodeVerificationFlow; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "attempts_remaining" => Deserialize::begin(&mut self.attempts_remaining), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { attempts_remaining: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let attempts_remaining = self.attempts_remaining.take()?; + let status = self.status.take()?; + + Some(Self::Out { attempts_remaining, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceCodeVerificationFlow { + type Builder = SourceCodeVerificationFlowBuilder; + } + + impl FromValueOpt for SourceCodeVerificationFlow { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceCodeVerificationFlowBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "attempts_remaining" => b.attempts_remaining = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_order.rs b/generated/stripe_shared/src/source_order.rs index 8efce108e..398496a81 100644 --- a/generated/stripe_shared/src/source_order.rs +++ b/generated/stripe_shared/src/source_order.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceOrder { /// A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the order. pub amount: i64, @@ -6,10 +8,110 @@ pub struct SourceOrder { /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: stripe_types::Currency, /// The email address of the customer placing the order. - #[serde(skip_serializing_if = "Option::is_none")] pub email: Option<String>, /// List of items constituting the order. pub items: Option<Vec<stripe_shared::SourceOrderItem>>, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping: Option<stripe_shared::Shipping>, } +#[cfg(feature = "min-ser")] +pub struct SourceOrderBuilder { + amount: Option<i64>, + currency: Option<stripe_types::Currency>, + email: Option<Option<String>>, + items: Option<Option<Vec<stripe_shared::SourceOrderItem>>>, + shipping: Option<Option<stripe_shared::Shipping>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceOrder { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceOrder>, + builder: SourceOrderBuilder, + } + + impl Visitor for Place<SourceOrder> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceOrderBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceOrderBuilder { + type Out = SourceOrder; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "email" => Deserialize::begin(&mut self.email), + "items" => Deserialize::begin(&mut self.items), + "shipping" => Deserialize::begin(&mut self.shipping), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default(), email: Deserialize::default(), items: Deserialize::default(), shipping: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let email = self.email.take()?; + let items = self.items.take()?; + let shipping = self.shipping.take()?; + + Some(Self::Out { amount, currency, email, items, shipping }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceOrder { + type Builder = SourceOrderBuilder; + } + + impl FromValueOpt for SourceOrder { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceOrderBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "items" => b.items = Some(FromValueOpt::from_value(v)?), + "shipping" => b.shipping = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_order_item.rs b/generated/stripe_shared/src/source_order_item.rs index fec4f886b..0cb183ed1 100644 --- a/generated/stripe_shared/src/source_order_item.rs +++ b/generated/stripe_shared/src/source_order_item.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceOrderItem { /// The amount (price) for this order item. pub amount: Option<i64>, @@ -11,9 +13,121 @@ pub struct SourceOrderItem { pub parent: Option<String>, /// The quantity of this order item. /// When type is `sku`, this is the number of instances of the SKU to be ordered. - #[serde(skip_serializing_if = "Option::is_none")] pub quantity: Option<u64>, /// The type of this order item. Must be `sku`, `tax`, or `shipping`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceOrderItemBuilder { + amount: Option<Option<i64>>, + currency: Option<Option<stripe_types::Currency>>, + description: Option<Option<String>>, + parent: Option<Option<String>>, + quantity: Option<Option<u64>>, + type_: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceOrderItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceOrderItem>, + builder: SourceOrderItemBuilder, + } + + impl Visitor for Place<SourceOrderItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceOrderItemBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceOrderItemBuilder { + type Out = SourceOrderItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "parent" => Deserialize::begin(&mut self.parent), + "quantity" => Deserialize::begin(&mut self.quantity), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + parent: Deserialize::default(), + quantity: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let parent = self.parent.take()?; + let quantity = self.quantity.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { amount, currency, description, parent, quantity, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceOrderItem { + type Builder = SourceOrderItemBuilder; + } + + impl FromValueOpt for SourceOrderItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceOrderItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "parent" => b.parent = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_owner.rs b/generated/stripe_shared/src/source_owner.rs index 72a67ffb8..89108e3a1 100644 --- a/generated/stripe_shared/src/source_owner.rs +++ b/generated/stripe_shared/src/source_owner.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceOwner { /// Owner's address. pub address: Option<stripe_shared::Address>, @@ -25,3 +27,126 @@ pub struct SourceOwner { /// They cannot be set or mutated. pub verified_phone: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceOwnerBuilder { + address: Option<Option<stripe_shared::Address>>, + email: Option<Option<String>>, + name: Option<Option<String>>, + phone: Option<Option<String>>, + verified_address: Option<Option<stripe_shared::Address>>, + verified_email: Option<Option<String>>, + verified_name: Option<Option<String>>, + verified_phone: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceOwner { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceOwner>, + builder: SourceOwnerBuilder, + } + + impl Visitor for Place<SourceOwner> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceOwnerBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceOwnerBuilder { + type Out = SourceOwner; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + "phone" => Deserialize::begin(&mut self.phone), + "verified_address" => Deserialize::begin(&mut self.verified_address), + "verified_email" => Deserialize::begin(&mut self.verified_email), + "verified_name" => Deserialize::begin(&mut self.verified_name), + "verified_phone" => Deserialize::begin(&mut self.verified_phone), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + email: Deserialize::default(), + name: Deserialize::default(), + phone: Deserialize::default(), + verified_address: Deserialize::default(), + verified_email: Deserialize::default(), + verified_name: Deserialize::default(), + verified_phone: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + let phone = self.phone.take()?; + let verified_address = self.verified_address.take()?; + let verified_email = self.verified_email.take()?; + let verified_name = self.verified_name.take()?; + let verified_phone = self.verified_phone.take()?; + + Some(Self::Out { address, email, name, phone, verified_address, verified_email, verified_name, verified_phone }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceOwner { + type Builder = SourceOwnerBuilder; + } + + impl FromValueOpt for SourceOwner { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceOwnerBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "phone" => b.phone = Some(FromValueOpt::from_value(v)?), + "verified_address" => b.verified_address = Some(FromValueOpt::from_value(v)?), + "verified_email" => b.verified_email = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + "verified_phone" => b.verified_phone = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_receiver_flow.rs b/generated/stripe_shared/src/source_receiver_flow.rs index d8dcdb46d..902a74a0d 100644 --- a/generated/stripe_shared/src/source_receiver_flow.rs +++ b/generated/stripe_shared/src/source_receiver_flow.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceReceiverFlow { /// The address of the receiver source. /// This is the value that should be communicated to the customer to send their funds to. @@ -20,3 +22,116 @@ pub struct SourceReceiverFlow { /// Type of refund attribute status, one of `missing`, `requested`, or `available`. pub refund_attributes_status: String, } +#[cfg(feature = "min-ser")] +pub struct SourceReceiverFlowBuilder { + address: Option<Option<String>>, + amount_charged: Option<i64>, + amount_received: Option<i64>, + amount_returned: Option<i64>, + refund_attributes_method: Option<String>, + refund_attributes_status: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceReceiverFlow { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceReceiverFlow>, + builder: SourceReceiverFlowBuilder, + } + + impl Visitor for Place<SourceReceiverFlow> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceReceiverFlowBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceReceiverFlowBuilder { + type Out = SourceReceiverFlow; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "amount_charged" => Deserialize::begin(&mut self.amount_charged), + "amount_received" => Deserialize::begin(&mut self.amount_received), + "amount_returned" => Deserialize::begin(&mut self.amount_returned), + "refund_attributes_method" => Deserialize::begin(&mut self.refund_attributes_method), + "refund_attributes_status" => Deserialize::begin(&mut self.refund_attributes_status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + amount_charged: Deserialize::default(), + amount_received: Deserialize::default(), + amount_returned: Deserialize::default(), + refund_attributes_method: Deserialize::default(), + refund_attributes_status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let amount_charged = self.amount_charged.take()?; + let amount_received = self.amount_received.take()?; + let amount_returned = self.amount_returned.take()?; + let refund_attributes_method = self.refund_attributes_method.take()?; + let refund_attributes_status = self.refund_attributes_status.take()?; + + Some(Self::Out { address, amount_charged, amount_received, amount_returned, refund_attributes_method, refund_attributes_status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceReceiverFlow { + type Builder = SourceReceiverFlowBuilder; + } + + impl FromValueOpt for SourceReceiverFlow { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceReceiverFlowBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "amount_charged" => b.amount_charged = Some(FromValueOpt::from_value(v)?), + "amount_received" => b.amount_received = Some(FromValueOpt::from_value(v)?), + "amount_returned" => b.amount_returned = Some(FromValueOpt::from_value(v)?), + "refund_attributes_method" => b.refund_attributes_method = Some(FromValueOpt::from_value(v)?), + "refund_attributes_status" => b.refund_attributes_status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_redirect_flow.rs b/generated/stripe_shared/src/source_redirect_flow.rs index 5c150985c..0258ac115 100644 --- a/generated/stripe_shared/src/source_redirect_flow.rs +++ b/generated/stripe_shared/src/source_redirect_flow.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceRedirectFlow { /// The failure reason for the redirect, either `user_abort` (the customer aborted or dropped out of the redirect flow), `declined` (the authentication failed or the transaction was declined), or `processing_error` (the redirect failed due to a technical error). /// Present only if the redirect status is `failed`. @@ -10,3 +12,101 @@ pub struct SourceRedirectFlow { /// The URL provided to you to redirect a customer to as part of a `redirect` authentication flow. pub url: String, } +#[cfg(feature = "min-ser")] +pub struct SourceRedirectFlowBuilder { + failure_reason: Option<Option<String>>, + return_url: Option<String>, + status: Option<String>, + url: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceRedirectFlow { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceRedirectFlow>, + builder: SourceRedirectFlowBuilder, + } + + impl Visitor for Place<SourceRedirectFlow> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceRedirectFlowBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceRedirectFlowBuilder { + type Out = SourceRedirectFlow; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "failure_reason" => Deserialize::begin(&mut self.failure_reason), + "return_url" => Deserialize::begin(&mut self.return_url), + "status" => Deserialize::begin(&mut self.status), + "url" => Deserialize::begin(&mut self.url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { failure_reason: Deserialize::default(), return_url: Deserialize::default(), status: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let failure_reason = self.failure_reason.take()?; + let return_url = self.return_url.take()?; + let status = self.status.take()?; + let url = self.url.take()?; + + Some(Self::Out { failure_reason, return_url, status, url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceRedirectFlow { + type Builder = SourceRedirectFlowBuilder; + } + + impl FromValueOpt for SourceRedirectFlow { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceRedirectFlowBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "failure_reason" => b.failure_reason = Some(FromValueOpt::from_value(v)?), + "return_url" => b.return_url = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_transaction.rs b/generated/stripe_shared/src/source_transaction.rs index 866c94771..315beea5a 100644 --- a/generated/stripe_shared/src/source_transaction.rs +++ b/generated/stripe_shared/src/source_transaction.rs @@ -2,37 +2,182 @@ /// Customers can be instructed to send any amount, and it can be made up of /// multiple transactions. As such, sources can have multiple associated /// transactions. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTransaction { - #[serde(skip_serializing_if = "Option::is_none")] pub ach_credit_transfer: Option<stripe_shared::SourceTransactionAchCreditTransferData>, /// A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the amount your customer has pushed to the receiver. pub amount: i64, - #[serde(skip_serializing_if = "Option::is_none")] pub chf_credit_transfer: Option<stripe_shared::SourceTransactionChfCreditTransferData>, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: stripe_types::Currency, - #[serde(skip_serializing_if = "Option::is_none")] pub gbp_credit_transfer: Option<stripe_shared::SourceTransactionGbpCreditTransferData>, /// Unique identifier for the object. pub id: stripe_shared::SourceTransactionId, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub paper_check: Option<stripe_shared::SourceTransactionPaperCheckData>, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_credit_transfer: Option<stripe_shared::SourceTransactionSepaCreditTransferData>, /// The ID of the source this transaction is attached to. pub source: String, /// The status of the transaction, one of `succeeded`, `pending`, or `failed`. pub status: String, /// The type of source this transaction is attached to. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: SourceTransactionType, } +#[cfg(feature = "min-ser")] +pub struct SourceTransactionBuilder { + ach_credit_transfer: Option<Option<stripe_shared::SourceTransactionAchCreditTransferData>>, + amount: Option<i64>, + chf_credit_transfer: Option<Option<stripe_shared::SourceTransactionChfCreditTransferData>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + gbp_credit_transfer: Option<Option<stripe_shared::SourceTransactionGbpCreditTransferData>>, + id: Option<stripe_shared::SourceTransactionId>, + livemode: Option<bool>, + paper_check: Option<Option<stripe_shared::SourceTransactionPaperCheckData>>, + sepa_credit_transfer: Option<Option<stripe_shared::SourceTransactionSepaCreditTransferData>>, + source: Option<String>, + status: Option<String>, + type_: Option<SourceTransactionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTransaction>, + builder: SourceTransactionBuilder, + } + + impl Visitor for Place<SourceTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTransactionBuilder { + type Out = SourceTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ach_credit_transfer" => Deserialize::begin(&mut self.ach_credit_transfer), + "amount" => Deserialize::begin(&mut self.amount), + "chf_credit_transfer" => Deserialize::begin(&mut self.chf_credit_transfer), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "gbp_credit_transfer" => Deserialize::begin(&mut self.gbp_credit_transfer), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "paper_check" => Deserialize::begin(&mut self.paper_check), + "sepa_credit_transfer" => Deserialize::begin(&mut self.sepa_credit_transfer), + "source" => Deserialize::begin(&mut self.source), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + ach_credit_transfer: Deserialize::default(), + amount: Deserialize::default(), + chf_credit_transfer: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + gbp_credit_transfer: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + paper_check: Deserialize::default(), + sepa_credit_transfer: Deserialize::default(), + source: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ach_credit_transfer = self.ach_credit_transfer.take()?; + let amount = self.amount.take()?; + let chf_credit_transfer = self.chf_credit_transfer.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let gbp_credit_transfer = self.gbp_credit_transfer.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let paper_check = self.paper_check.take()?; + let sepa_credit_transfer = self.sepa_credit_transfer.take()?; + let source = self.source.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { ach_credit_transfer, amount, chf_credit_transfer, created, currency, gbp_credit_transfer, id, livemode, paper_check, sepa_credit_transfer, source, status, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTransaction { + type Builder = SourceTransactionBuilder; + } + + impl FromValueOpt for SourceTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ach_credit_transfer" => b.ach_credit_transfer = Some(FromValueOpt::from_value(v)?), + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "chf_credit_transfer" => b.chf_credit_transfer = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "gbp_credit_transfer" => b.gbp_credit_transfer = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "paper_check" => b.paper_check = Some(FromValueOpt::from_value(v)?), + "sepa_credit_transfer" => b.sepa_credit_transfer = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of source this transaction is attached to. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -129,9 +274,27 @@ impl<'de> serde::Deserialize<'de> for SourceTransactionType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(SourceTransactionType::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SourceTransactionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SourceTransactionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SourceTransactionType::from_str(s).unwrap_or(SourceTransactionType::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SourceTransactionType); impl stripe_types::Object for SourceTransaction { type Id = stripe_shared::SourceTransactionId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/source_transaction_ach_credit_transfer_data.rs b/generated/stripe_shared/src/source_transaction_ach_credit_transfer_data.rs index cbb4be85d..27ec7e133 100644 --- a/generated/stripe_shared/src/source_transaction_ach_credit_transfer_data.rs +++ b/generated/stripe_shared/src/source_transaction_ach_credit_transfer_data.rs @@ -1,15 +1,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTransactionAchCreditTransferData { /// Customer data associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub customer_data: Option<String>, /// Bank account fingerprint associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, /// Last 4 digits of the account number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, /// Routing number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTransactionAchCreditTransferDataBuilder { + customer_data: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTransactionAchCreditTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTransactionAchCreditTransferData>, + builder: SourceTransactionAchCreditTransferDataBuilder, + } + + impl Visitor for Place<SourceTransactionAchCreditTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTransactionAchCreditTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTransactionAchCreditTransferDataBuilder { + type Out = SourceTransactionAchCreditTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "customer_data" => Deserialize::begin(&mut self.customer_data), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { customer_data: Deserialize::default(), fingerprint: Deserialize::default(), last4: Deserialize::default(), routing_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let customer_data = self.customer_data.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { customer_data, fingerprint, last4, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTransactionAchCreditTransferData { + type Builder = SourceTransactionAchCreditTransferDataBuilder; + } + + impl FromValueOpt for SourceTransactionAchCreditTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTransactionAchCreditTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "customer_data" => b.customer_data = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_transaction_chf_credit_transfer_data.rs b/generated/stripe_shared/src/source_transaction_chf_credit_transfer_data.rs index 491954c7f..2f7135ca7 100644 --- a/generated/stripe_shared/src/source_transaction_chf_credit_transfer_data.rs +++ b/generated/stripe_shared/src/source_transaction_chf_credit_transfer_data.rs @@ -1,18 +1,123 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTransactionChfCreditTransferData { /// Reference associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option<String>, /// Sender's country address. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_address_country: Option<String>, /// Sender's line 1 address. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_address_line1: Option<String>, /// Sender's bank account IBAN. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_iban: Option<String>, /// Sender's name. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTransactionChfCreditTransferDataBuilder { + reference: Option<Option<String>>, + sender_address_country: Option<Option<String>>, + sender_address_line1: Option<Option<String>>, + sender_iban: Option<Option<String>>, + sender_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTransactionChfCreditTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTransactionChfCreditTransferData>, + builder: SourceTransactionChfCreditTransferDataBuilder, + } + + impl Visitor for Place<SourceTransactionChfCreditTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTransactionChfCreditTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTransactionChfCreditTransferDataBuilder { + type Out = SourceTransactionChfCreditTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + "sender_address_country" => Deserialize::begin(&mut self.sender_address_country), + "sender_address_line1" => Deserialize::begin(&mut self.sender_address_line1), + "sender_iban" => Deserialize::begin(&mut self.sender_iban), + "sender_name" => Deserialize::begin(&mut self.sender_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + reference: Deserialize::default(), + sender_address_country: Deserialize::default(), + sender_address_line1: Deserialize::default(), + sender_iban: Deserialize::default(), + sender_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reference = self.reference.take()?; + let sender_address_country = self.sender_address_country.take()?; + let sender_address_line1 = self.sender_address_line1.take()?; + let sender_iban = self.sender_iban.take()?; + let sender_name = self.sender_name.take()?; + + Some(Self::Out { reference, sender_address_country, sender_address_line1, sender_iban, sender_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTransactionChfCreditTransferData { + type Builder = SourceTransactionChfCreditTransferDataBuilder; + } + + impl FromValueOpt for SourceTransactionChfCreditTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTransactionChfCreditTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "sender_address_country" => b.sender_address_country = Some(FromValueOpt::from_value(v)?), + "sender_address_line1" => b.sender_address_line1 = Some(FromValueOpt::from_value(v)?), + "sender_iban" => b.sender_iban = Some(FromValueOpt::from_value(v)?), + "sender_name" => b.sender_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_transaction_gbp_credit_transfer_data.rs b/generated/stripe_shared/src/source_transaction_gbp_credit_transfer_data.rs index da7082cda..77a6b92ee 100644 --- a/generated/stripe_shared/src/source_transaction_gbp_credit_transfer_data.rs +++ b/generated/stripe_shared/src/source_transaction_gbp_credit_transfer_data.rs @@ -1,26 +1,139 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTransactionGbpCreditTransferData { /// Bank account fingerprint associated with the Stripe owned bank account receiving the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, /// The credit transfer rails the sender used to push this transfer. /// The possible rails are: Faster Payments, BACS, CHAPS, and wire transfers. /// Currently only Faster Payments is supported. - #[serde(skip_serializing_if = "Option::is_none")] pub funding_method: Option<String>, /// Last 4 digits of sender account number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, /// Sender entered arbitrary information about the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option<String>, /// Sender account number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_account_number: Option<String>, /// Sender name associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_name: Option<String>, /// Sender sort code associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_sort_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTransactionGbpCreditTransferDataBuilder { + fingerprint: Option<Option<String>>, + funding_method: Option<Option<String>>, + last4: Option<Option<String>>, + reference: Option<Option<String>>, + sender_account_number: Option<Option<String>>, + sender_name: Option<Option<String>>, + sender_sort_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTransactionGbpCreditTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTransactionGbpCreditTransferData>, + builder: SourceTransactionGbpCreditTransferDataBuilder, + } + + impl Visitor for Place<SourceTransactionGbpCreditTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTransactionGbpCreditTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTransactionGbpCreditTransferDataBuilder { + type Out = SourceTransactionGbpCreditTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding_method" => Deserialize::begin(&mut self.funding_method), + "last4" => Deserialize::begin(&mut self.last4), + "reference" => Deserialize::begin(&mut self.reference), + "sender_account_number" => Deserialize::begin(&mut self.sender_account_number), + "sender_name" => Deserialize::begin(&mut self.sender_name), + "sender_sort_code" => Deserialize::begin(&mut self.sender_sort_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + fingerprint: Deserialize::default(), + funding_method: Deserialize::default(), + last4: Deserialize::default(), + reference: Deserialize::default(), + sender_account_number: Deserialize::default(), + sender_name: Deserialize::default(), + sender_sort_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let fingerprint = self.fingerprint.take()?; + let funding_method = self.funding_method.take()?; + let last4 = self.last4.take()?; + let reference = self.reference.take()?; + let sender_account_number = self.sender_account_number.take()?; + let sender_name = self.sender_name.take()?; + let sender_sort_code = self.sender_sort_code.take()?; + + Some(Self::Out { fingerprint, funding_method, last4, reference, sender_account_number, sender_name, sender_sort_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTransactionGbpCreditTransferData { + type Builder = SourceTransactionGbpCreditTransferDataBuilder; + } + + impl FromValueOpt for SourceTransactionGbpCreditTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTransactionGbpCreditTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding_method" => b.funding_method = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "sender_account_number" => b.sender_account_number = Some(FromValueOpt::from_value(v)?), + "sender_name" => b.sender_name = Some(FromValueOpt::from_value(v)?), + "sender_sort_code" => b.sender_sort_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_transaction_paper_check_data.rs b/generated/stripe_shared/src/source_transaction_paper_check_data.rs index fd465c5be..42e799ab3 100644 --- a/generated/stripe_shared/src/source_transaction_paper_check_data.rs +++ b/generated/stripe_shared/src/source_transaction_paper_check_data.rs @@ -1,10 +1,100 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTransactionPaperCheckData { /// Time at which the deposited funds will be available for use. /// Measured in seconds since the Unix epoch. - #[serde(skip_serializing_if = "Option::is_none")] pub available_at: Option<String>, /// Comma-separated list of invoice IDs associated with the paper check. - #[serde(skip_serializing_if = "Option::is_none")] pub invoices: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTransactionPaperCheckDataBuilder { + available_at: Option<Option<String>>, + invoices: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTransactionPaperCheckData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTransactionPaperCheckData>, + builder: SourceTransactionPaperCheckDataBuilder, + } + + impl Visitor for Place<SourceTransactionPaperCheckData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTransactionPaperCheckDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTransactionPaperCheckDataBuilder { + type Out = SourceTransactionPaperCheckData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "available_at" => Deserialize::begin(&mut self.available_at), + "invoices" => Deserialize::begin(&mut self.invoices), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available_at: Deserialize::default(), invoices: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let available_at = self.available_at.take()?; + let invoices = self.invoices.take()?; + + Some(Self::Out { available_at, invoices }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTransactionPaperCheckData { + type Builder = SourceTransactionPaperCheckDataBuilder; + } + + impl FromValueOpt for SourceTransactionPaperCheckData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTransactionPaperCheckDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "available_at" => b.available_at = Some(FromValueOpt::from_value(v)?), + "invoices" => b.invoices = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_transaction_sepa_credit_transfer_data.rs b/generated/stripe_shared/src/source_transaction_sepa_credit_transfer_data.rs index 99674772b..e1d13985d 100644 --- a/generated/stripe_shared/src/source_transaction_sepa_credit_transfer_data.rs +++ b/generated/stripe_shared/src/source_transaction_sepa_credit_transfer_data.rs @@ -1,12 +1,105 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTransactionSepaCreditTransferData { /// Reference associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option<String>, /// Sender's bank account IBAN. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_iban: Option<String>, /// Sender's name. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTransactionSepaCreditTransferDataBuilder { + reference: Option<Option<String>>, + sender_iban: Option<Option<String>>, + sender_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTransactionSepaCreditTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTransactionSepaCreditTransferData>, + builder: SourceTransactionSepaCreditTransferDataBuilder, + } + + impl Visitor for Place<SourceTransactionSepaCreditTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTransactionSepaCreditTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTransactionSepaCreditTransferDataBuilder { + type Out = SourceTransactionSepaCreditTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + "sender_iban" => Deserialize::begin(&mut self.sender_iban), + "sender_name" => Deserialize::begin(&mut self.sender_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default(), sender_iban: Deserialize::default(), sender_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reference = self.reference.take()?; + let sender_iban = self.sender_iban.take()?; + let sender_name = self.sender_name.take()?; + + Some(Self::Out { reference, sender_iban, sender_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTransactionSepaCreditTransferData { + type Builder = SourceTransactionSepaCreditTransferDataBuilder; + } + + impl FromValueOpt for SourceTransactionSepaCreditTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTransactionSepaCreditTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "sender_iban" => b.sender_iban = Some(FromValueOpt::from_value(v)?), + "sender_name" => b.sender_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_ach_credit_transfer.rs b/generated/stripe_shared/src/source_type_ach_credit_transfer.rs index fec1cfaa7..aefcf4f30 100644 --- a/generated/stripe_shared/src/source_type_ach_credit_transfer.rs +++ b/generated/stripe_shared/src/source_type_ach_credit_transfer.rs @@ -1,19 +1,136 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeAchCreditTransfer { - #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_type: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_routing_number: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub swift_code: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeAchCreditTransferBuilder { + account_number: Option<Option<String>>, + bank_name: Option<Option<String>>, + fingerprint: Option<Option<String>>, + refund_account_holder_name: Option<Option<String>>, + refund_account_holder_type: Option<Option<String>>, + refund_routing_number: Option<Option<String>>, + routing_number: Option<Option<String>>, + swift_code: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeAchCreditTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeAchCreditTransfer>, + builder: SourceTypeAchCreditTransferBuilder, + } + + impl Visitor for Place<SourceTypeAchCreditTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeAchCreditTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeAchCreditTransferBuilder { + type Out = SourceTypeAchCreditTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_number" => Deserialize::begin(&mut self.account_number), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "refund_account_holder_name" => Deserialize::begin(&mut self.refund_account_holder_name), + "refund_account_holder_type" => Deserialize::begin(&mut self.refund_account_holder_type), + "refund_routing_number" => Deserialize::begin(&mut self.refund_routing_number), + "routing_number" => Deserialize::begin(&mut self.routing_number), + "swift_code" => Deserialize::begin(&mut self.swift_code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_number: Deserialize::default(), + bank_name: Deserialize::default(), + fingerprint: Deserialize::default(), + refund_account_holder_name: Deserialize::default(), + refund_account_holder_type: Deserialize::default(), + refund_routing_number: Deserialize::default(), + routing_number: Deserialize::default(), + swift_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_number = self.account_number.take()?; + let bank_name = self.bank_name.take()?; + let fingerprint = self.fingerprint.take()?; + let refund_account_holder_name = self.refund_account_holder_name.take()?; + let refund_account_holder_type = self.refund_account_holder_type.take()?; + let refund_routing_number = self.refund_routing_number.take()?; + let routing_number = self.routing_number.take()?; + let swift_code = self.swift_code.take()?; + + Some(Self::Out { account_number, bank_name, fingerprint, refund_account_holder_name, refund_account_holder_type, refund_routing_number, routing_number, swift_code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeAchCreditTransfer { + type Builder = SourceTypeAchCreditTransferBuilder; + } + + impl FromValueOpt for SourceTypeAchCreditTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeAchCreditTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_number" => b.account_number = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_name" => b.refund_account_holder_name = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_type" => b.refund_account_holder_type = Some(FromValueOpt::from_value(v)?), + "refund_routing_number" => b.refund_routing_number = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + "swift_code" => b.swift_code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_ach_debit.rs b/generated/stripe_shared/src/source_type_ach_debit.rs index 3af75e8ad..0f9df5a00 100644 --- a/generated/stripe_shared/src/source_type_ach_debit.rs +++ b/generated/stripe_shared/src/source_type_ach_debit.rs @@ -1,16 +1,125 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeAchDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option<String>, - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeAchDebitBuilder { + bank_name: Option<Option<String>>, + country: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + routing_number: Option<Option<String>>, + type_: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeAchDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeAchDebit>, + builder: SourceTypeAchDebitBuilder, + } + + impl Visitor for Place<SourceTypeAchDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeAchDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeAchDebitBuilder { + type Out = SourceTypeAchDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_name" => Deserialize::begin(&mut self.bank_name), + "country" => Deserialize::begin(&mut self.country), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "routing_number" => Deserialize::begin(&mut self.routing_number), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_name: Deserialize::default(), + country: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + routing_number: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_name = self.bank_name.take()?; + let country = self.country.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let routing_number = self.routing_number.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { bank_name, country, fingerprint, last4, routing_number, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeAchDebit { + type Builder = SourceTypeAchDebitBuilder; + } + + impl FromValueOpt for SourceTypeAchDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeAchDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_acss_debit.rs b/generated/stripe_shared/src/source_type_acss_debit.rs index 5a5f28b88..af6b6dca5 100644 --- a/generated/stripe_shared/src/source_type_acss_debit.rs +++ b/generated/stripe_shared/src/source_type_acss_debit.rs @@ -1,23 +1,148 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeAcssDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_city: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_line_1: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_line_2: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_postal_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub category: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeAcssDebitBuilder { + bank_address_city: Option<Option<String>>, + bank_address_line_1: Option<Option<String>>, + bank_address_line_2: Option<Option<String>>, + bank_address_postal_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + category: Option<Option<String>>, + country: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeAcssDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeAcssDebit>, + builder: SourceTypeAcssDebitBuilder, + } + + impl Visitor for Place<SourceTypeAcssDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeAcssDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeAcssDebitBuilder { + type Out = SourceTypeAcssDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_address_city" => Deserialize::begin(&mut self.bank_address_city), + "bank_address_line_1" => Deserialize::begin(&mut self.bank_address_line_1), + "bank_address_line_2" => Deserialize::begin(&mut self.bank_address_line_2), + "bank_address_postal_code" => Deserialize::begin(&mut self.bank_address_postal_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "category" => Deserialize::begin(&mut self.category), + "country" => Deserialize::begin(&mut self.country), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_address_city: Deserialize::default(), + bank_address_line_1: Deserialize::default(), + bank_address_line_2: Deserialize::default(), + bank_address_postal_code: Deserialize::default(), + bank_name: Deserialize::default(), + category: Deserialize::default(), + country: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_address_city = self.bank_address_city.take()?; + let bank_address_line_1 = self.bank_address_line_1.take()?; + let bank_address_line_2 = self.bank_address_line_2.take()?; + let bank_address_postal_code = self.bank_address_postal_code.take()?; + let bank_name = self.bank_name.take()?; + let category = self.category.take()?; + let country = self.country.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { bank_address_city, bank_address_line_1, bank_address_line_2, bank_address_postal_code, bank_name, category, country, fingerprint, last4, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeAcssDebit { + type Builder = SourceTypeAcssDebitBuilder; + } + + impl FromValueOpt for SourceTypeAcssDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeAcssDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_address_city" => b.bank_address_city = Some(FromValueOpt::from_value(v)?), + "bank_address_line_1" => b.bank_address_line_1 = Some(FromValueOpt::from_value(v)?), + "bank_address_line_2" => b.bank_address_line_2 = Some(FromValueOpt::from_value(v)?), + "bank_address_postal_code" => b.bank_address_postal_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "category" => b.category = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_alipay.rs b/generated/stripe_shared/src/source_type_alipay.rs index bdc2da5e3..0f65294af 100644 --- a/generated/stripe_shared/src/source_type_alipay.rs +++ b/generated/stripe_shared/src/source_type_alipay.rs @@ -1,9 +1,102 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeAlipay { - #[serde(skip_serializing_if = "Option::is_none")] pub data_string: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub native_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeAlipayBuilder { + data_string: Option<Option<String>>, + native_url: Option<Option<String>>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeAlipay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeAlipay>, + builder: SourceTypeAlipayBuilder, + } + + impl Visitor for Place<SourceTypeAlipay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeAlipayBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeAlipayBuilder { + type Out = SourceTypeAlipay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "data_string" => Deserialize::begin(&mut self.data_string), + "native_url" => Deserialize::begin(&mut self.native_url), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { data_string: Deserialize::default(), native_url: Deserialize::default(), statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let data_string = self.data_string.take()?; + let native_url = self.native_url.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { data_string, native_url, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeAlipay { + type Builder = SourceTypeAlipayBuilder; + } + + impl FromValueOpt for SourceTypeAlipay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeAlipayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "data_string" => b.data_string = Some(FromValueOpt::from_value(v)?), + "native_url" => b.native_url = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_au_becs_debit.rs b/generated/stripe_shared/src/source_type_au_becs_debit.rs index 2d8f5e245..db8d732a2 100644 --- a/generated/stripe_shared/src/source_type_au_becs_debit.rs +++ b/generated/stripe_shared/src/source_type_au_becs_debit.rs @@ -1,9 +1,102 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeAuBecsDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bsb_number: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeAuBecsDebitBuilder { + bsb_number: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeAuBecsDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeAuBecsDebit>, + builder: SourceTypeAuBecsDebitBuilder, + } + + impl Visitor for Place<SourceTypeAuBecsDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeAuBecsDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeAuBecsDebitBuilder { + type Out = SourceTypeAuBecsDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bsb_number" => Deserialize::begin(&mut self.bsb_number), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bsb_number: Deserialize::default(), fingerprint: Deserialize::default(), last4: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bsb_number = self.bsb_number.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + + Some(Self::Out { bsb_number, fingerprint, last4 }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeAuBecsDebit { + type Builder = SourceTypeAuBecsDebitBuilder; + } + + impl FromValueOpt for SourceTypeAuBecsDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeAuBecsDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bsb_number" => b.bsb_number = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_bancontact.rs b/generated/stripe_shared/src/source_type_bancontact.rs index 718fc33e9..0dcb287ed 100644 --- a/generated/stripe_shared/src/source_type_bancontact.rs +++ b/generated/stripe_shared/src/source_type_bancontact.rs @@ -1,15 +1,124 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeBancontact { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub iban_last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_language: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeBancontactBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + iban_last4: Option<Option<String>>, + preferred_language: Option<Option<String>>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeBancontact { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeBancontact>, + builder: SourceTypeBancontactBuilder, + } + + impl Visitor for Place<SourceTypeBancontact> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeBancontactBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeBancontactBuilder { + type Out = SourceTypeBancontact; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + bic: Deserialize::default(), + iban_last4: Deserialize::default(), + preferred_language: Deserialize::default(), + statement_descriptor: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let iban_last4 = self.iban_last4.take()?; + let preferred_language = self.preferred_language.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { bank_code, bank_name, bic, iban_last4, preferred_language, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeBancontact { + type Builder = SourceTypeBancontactBuilder; + } + + impl FromValueOpt for SourceTypeBancontact { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeBancontactBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_card.rs b/generated/stripe_shared/src/source_type_card.rs index bdee83df8..a264e6715 100644 --- a/generated/stripe_shared/src/source_type_card.rs +++ b/generated/stripe_shared/src/source_type_card.rs @@ -1,37 +1,208 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeCard { - #[serde(skip_serializing_if = "Option::is_none")] pub address_line1_check: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub address_zip_check: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub brand: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub cvc_check: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_month: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_year: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub funding: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub three_d_secure: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub tokenization_method: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeCardBuilder { + address_line1_check: Option<Option<String>>, + address_zip_check: Option<Option<String>>, + brand: Option<Option<String>>, + country: Option<Option<String>>, + cvc_check: Option<Option<String>>, + description: Option<Option<String>>, + dynamic_last4: Option<Option<String>>, + exp_month: Option<Option<i64>>, + exp_year: Option<Option<i64>>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + name: Option<Option<String>>, + three_d_secure: Option<Option<String>>, + tokenization_method: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeCard>, + builder: SourceTypeCardBuilder, + } + + impl Visitor for Place<SourceTypeCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeCardBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeCardBuilder { + type Out = SourceTypeCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address_line1_check" => Deserialize::begin(&mut self.address_line1_check), + "address_zip_check" => Deserialize::begin(&mut self.address_zip_check), + "brand" => Deserialize::begin(&mut self.brand), + "country" => Deserialize::begin(&mut self.country), + "cvc_check" => Deserialize::begin(&mut self.cvc_check), + "description" => Deserialize::begin(&mut self.description), + "dynamic_last4" => Deserialize::begin(&mut self.dynamic_last4), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "name" => Deserialize::begin(&mut self.name), + "three_d_secure" => Deserialize::begin(&mut self.three_d_secure), + "tokenization_method" => Deserialize::begin(&mut self.tokenization_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address_line1_check: Deserialize::default(), + address_zip_check: Deserialize::default(), + brand: Deserialize::default(), + country: Deserialize::default(), + cvc_check: Deserialize::default(), + description: Deserialize::default(), + dynamic_last4: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + name: Deserialize::default(), + three_d_secure: Deserialize::default(), + tokenization_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address_line1_check = self.address_line1_check.take()?; + let address_zip_check = self.address_zip_check.take()?; + let brand = self.brand.take()?; + let country = self.country.take()?; + let cvc_check = self.cvc_check.take()?; + let description = self.description.take()?; + let dynamic_last4 = self.dynamic_last4.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let name = self.name.take()?; + let three_d_secure = self.three_d_secure.take()?; + let tokenization_method = self.tokenization_method.take()?; + + Some(Self::Out { + address_line1_check, + address_zip_check, + brand, + country, + cvc_check, + description, + dynamic_last4, + exp_month, + exp_year, + fingerprint, + funding, + iin, + issuer, + last4, + name, + three_d_secure, + tokenization_method, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeCard { + type Builder = SourceTypeCardBuilder; + } + + impl FromValueOpt for SourceTypeCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address_line1_check" => b.address_line1_check = Some(FromValueOpt::from_value(v)?), + "address_zip_check" => b.address_zip_check = Some(FromValueOpt::from_value(v)?), + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "cvc_check" => b.cvc_check = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "dynamic_last4" => b.dynamic_last4 = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "three_d_secure" => b.three_d_secure = Some(FromValueOpt::from_value(v)?), + "tokenization_method" => b.tokenization_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_card_present.rs b/generated/stripe_shared/src/source_type_card_present.rs index c1ba590f0..3b086bf1c 100644 --- a/generated/stripe_shared/src/source_type_card_present.rs +++ b/generated/stripe_shared/src/source_type_card_present.rs @@ -1,55 +1,271 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeCardPresent { - #[serde(skip_serializing_if = "Option::is_none")] pub application_cryptogram: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub application_preferred_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub authorization_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub authorization_response_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub brand: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub cvm_type: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub data_type: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub dedicated_file_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub emv_auth_data: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub evidence_customer_signature: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub evidence_transaction_certificate: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_month: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_year: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub funding: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pos_device_id: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pos_entry_mode: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub read_method: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub reader: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub terminal_verification_results: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub transaction_status_information: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeCardPresentBuilder { + application_cryptogram: Option<Option<String>>, + application_preferred_name: Option<Option<String>>, + authorization_code: Option<Option<String>>, + authorization_response_code: Option<Option<String>>, + brand: Option<Option<String>>, + country: Option<Option<String>>, + cvm_type: Option<Option<String>>, + data_type: Option<Option<String>>, + dedicated_file_name: Option<Option<String>>, + description: Option<Option<String>>, + emv_auth_data: Option<Option<String>>, + evidence_customer_signature: Option<Option<String>>, + evidence_transaction_certificate: Option<Option<String>>, + exp_month: Option<Option<i64>>, + exp_year: Option<Option<i64>>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + pos_device_id: Option<Option<String>>, + pos_entry_mode: Option<Option<String>>, + read_method: Option<Option<String>>, + reader: Option<Option<String>>, + terminal_verification_results: Option<Option<String>>, + transaction_status_information: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeCardPresent { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeCardPresent>, + builder: SourceTypeCardPresentBuilder, + } + + impl Visitor for Place<SourceTypeCardPresent> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeCardPresentBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeCardPresentBuilder { + type Out = SourceTypeCardPresent; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "application_cryptogram" => Deserialize::begin(&mut self.application_cryptogram), + "application_preferred_name" => Deserialize::begin(&mut self.application_preferred_name), + "authorization_code" => Deserialize::begin(&mut self.authorization_code), + "authorization_response_code" => Deserialize::begin(&mut self.authorization_response_code), + "brand" => Deserialize::begin(&mut self.brand), + "country" => Deserialize::begin(&mut self.country), + "cvm_type" => Deserialize::begin(&mut self.cvm_type), + "data_type" => Deserialize::begin(&mut self.data_type), + "dedicated_file_name" => Deserialize::begin(&mut self.dedicated_file_name), + "description" => Deserialize::begin(&mut self.description), + "emv_auth_data" => Deserialize::begin(&mut self.emv_auth_data), + "evidence_customer_signature" => Deserialize::begin(&mut self.evidence_customer_signature), + "evidence_transaction_certificate" => Deserialize::begin(&mut self.evidence_transaction_certificate), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "pos_device_id" => Deserialize::begin(&mut self.pos_device_id), + "pos_entry_mode" => Deserialize::begin(&mut self.pos_entry_mode), + "read_method" => Deserialize::begin(&mut self.read_method), + "reader" => Deserialize::begin(&mut self.reader), + "terminal_verification_results" => Deserialize::begin(&mut self.terminal_verification_results), + "transaction_status_information" => Deserialize::begin(&mut self.transaction_status_information), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + application_cryptogram: Deserialize::default(), + application_preferred_name: Deserialize::default(), + authorization_code: Deserialize::default(), + authorization_response_code: Deserialize::default(), + brand: Deserialize::default(), + country: Deserialize::default(), + cvm_type: Deserialize::default(), + data_type: Deserialize::default(), + dedicated_file_name: Deserialize::default(), + description: Deserialize::default(), + emv_auth_data: Deserialize::default(), + evidence_customer_signature: Deserialize::default(), + evidence_transaction_certificate: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + pos_device_id: Deserialize::default(), + pos_entry_mode: Deserialize::default(), + read_method: Deserialize::default(), + reader: Deserialize::default(), + terminal_verification_results: Deserialize::default(), + transaction_status_information: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let application_cryptogram = self.application_cryptogram.take()?; + let application_preferred_name = self.application_preferred_name.take()?; + let authorization_code = self.authorization_code.take()?; + let authorization_response_code = self.authorization_response_code.take()?; + let brand = self.brand.take()?; + let country = self.country.take()?; + let cvm_type = self.cvm_type.take()?; + let data_type = self.data_type.take()?; + let dedicated_file_name = self.dedicated_file_name.take()?; + let description = self.description.take()?; + let emv_auth_data = self.emv_auth_data.take()?; + let evidence_customer_signature = self.evidence_customer_signature.take()?; + let evidence_transaction_certificate = self.evidence_transaction_certificate.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let pos_device_id = self.pos_device_id.take()?; + let pos_entry_mode = self.pos_entry_mode.take()?; + let read_method = self.read_method.take()?; + let reader = self.reader.take()?; + let terminal_verification_results = self.terminal_verification_results.take()?; + let transaction_status_information = self.transaction_status_information.take()?; + + Some(Self::Out { + application_cryptogram, + application_preferred_name, + authorization_code, + authorization_response_code, + brand, + country, + cvm_type, + data_type, + dedicated_file_name, + description, + emv_auth_data, + evidence_customer_signature, + evidence_transaction_certificate, + exp_month, + exp_year, + fingerprint, + funding, + iin, + issuer, + last4, + pos_device_id, + pos_entry_mode, + read_method, + reader, + terminal_verification_results, + transaction_status_information, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeCardPresent { + type Builder = SourceTypeCardPresentBuilder; + } + + impl FromValueOpt for SourceTypeCardPresent { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeCardPresentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "application_cryptogram" => b.application_cryptogram = Some(FromValueOpt::from_value(v)?), + "application_preferred_name" => b.application_preferred_name = Some(FromValueOpt::from_value(v)?), + "authorization_code" => b.authorization_code = Some(FromValueOpt::from_value(v)?), + "authorization_response_code" => b.authorization_response_code = Some(FromValueOpt::from_value(v)?), + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "cvm_type" => b.cvm_type = Some(FromValueOpt::from_value(v)?), + "data_type" => b.data_type = Some(FromValueOpt::from_value(v)?), + "dedicated_file_name" => b.dedicated_file_name = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "emv_auth_data" => b.emv_auth_data = Some(FromValueOpt::from_value(v)?), + "evidence_customer_signature" => b.evidence_customer_signature = Some(FromValueOpt::from_value(v)?), + "evidence_transaction_certificate" => b.evidence_transaction_certificate = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "pos_device_id" => b.pos_device_id = Some(FromValueOpt::from_value(v)?), + "pos_entry_mode" => b.pos_entry_mode = Some(FromValueOpt::from_value(v)?), + "read_method" => b.read_method = Some(FromValueOpt::from_value(v)?), + "reader" => b.reader = Some(FromValueOpt::from_value(v)?), + "terminal_verification_results" => b.terminal_verification_results = Some(FromValueOpt::from_value(v)?), + "transaction_status_information" => b.transaction_status_information = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_eps.rs b/generated/stripe_shared/src/source_type_eps.rs index 38e2d3838..c8929868d 100644 --- a/generated/stripe_shared/src/source_type_eps.rs +++ b/generated/stripe_shared/src/source_type_eps.rs @@ -1,7 +1,97 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeEps { - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeEpsBuilder { + reference: Option<Option<String>>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeEps { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeEps>, + builder: SourceTypeEpsBuilder, + } + + impl Visitor for Place<SourceTypeEps> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeEpsBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeEpsBuilder { + type Out = SourceTypeEps; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default(), statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reference = self.reference.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { reference, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeEps { + type Builder = SourceTypeEpsBuilder; + } + + impl FromValueOpt for SourceTypeEps { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeEpsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_giropay.rs b/generated/stripe_shared/src/source_type_giropay.rs index 6815d3aa9..3d93a4ec4 100644 --- a/generated/stripe_shared/src/source_type_giropay.rs +++ b/generated/stripe_shared/src/source_type_giropay.rs @@ -1,11 +1,107 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeGiropay { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeGiropayBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeGiropay { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeGiropay>, + builder: SourceTypeGiropayBuilder, + } + + impl Visitor for Place<SourceTypeGiropay> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeGiropayBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeGiropayBuilder { + type Out = SourceTypeGiropay; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_code: Deserialize::default(), bank_name: Deserialize::default(), bic: Deserialize::default(), statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { bank_code, bank_name, bic, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeGiropay { + type Builder = SourceTypeGiropayBuilder; + } + + impl FromValueOpt for SourceTypeGiropay { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeGiropayBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_ideal.rs b/generated/stripe_shared/src/source_type_ideal.rs index e32bc18de..22efde105 100644 --- a/generated/stripe_shared/src/source_type_ideal.rs +++ b/generated/stripe_shared/src/source_type_ideal.rs @@ -1,11 +1,107 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeIdeal { - #[serde(skip_serializing_if = "Option::is_none")] pub bank: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub iban_last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeIdealBuilder { + bank: Option<Option<String>>, + bic: Option<Option<String>>, + iban_last4: Option<Option<String>>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeIdeal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeIdeal>, + builder: SourceTypeIdealBuilder, + } + + impl Visitor for Place<SourceTypeIdeal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeIdealBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeIdealBuilder { + type Out = SourceTypeIdeal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank" => Deserialize::begin(&mut self.bank), + "bic" => Deserialize::begin(&mut self.bic), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default(), bic: Deserialize::default(), iban_last4: Deserialize::default(), statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank = self.bank.take()?; + let bic = self.bic.take()?; + let iban_last4 = self.iban_last4.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { bank, bic, iban_last4, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeIdeal { + type Builder = SourceTypeIdealBuilder; + } + + impl FromValueOpt for SourceTypeIdeal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeIdealBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank" => b.bank = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_klarna.rs b/generated/stripe_shared/src/source_type_klarna.rs index 4af723679..58ee7abaa 100644 --- a/generated/stripe_shared/src/source_type_klarna.rs +++ b/generated/stripe_shared/src/source_type_klarna.rs @@ -1,55 +1,271 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeKlarna { - #[serde(skip_serializing_if = "Option::is_none")] pub background_image_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub client_token: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub first_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub locale: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub logo_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub page_title: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_asset_urls_descriptive: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_asset_urls_standard: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_redirect_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_asset_urls_descriptive: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_asset_urls_standard: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_redirect_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_asset_urls_descriptive: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_asset_urls_standard: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_redirect_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_method_categories: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub purchase_country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub purchase_type: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub redirect_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_delay: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_first_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_last_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeKlarnaBuilder { + background_image_url: Option<Option<String>>, + client_token: Option<Option<String>>, + first_name: Option<Option<String>>, + last_name: Option<Option<String>>, + locale: Option<Option<String>>, + logo_url: Option<Option<String>>, + page_title: Option<Option<String>>, + pay_later_asset_urls_descriptive: Option<Option<String>>, + pay_later_asset_urls_standard: Option<Option<String>>, + pay_later_name: Option<Option<String>>, + pay_later_redirect_url: Option<Option<String>>, + pay_now_asset_urls_descriptive: Option<Option<String>>, + pay_now_asset_urls_standard: Option<Option<String>>, + pay_now_name: Option<Option<String>>, + pay_now_redirect_url: Option<Option<String>>, + pay_over_time_asset_urls_descriptive: Option<Option<String>>, + pay_over_time_asset_urls_standard: Option<Option<String>>, + pay_over_time_name: Option<Option<String>>, + pay_over_time_redirect_url: Option<Option<String>>, + payment_method_categories: Option<Option<String>>, + purchase_country: Option<Option<String>>, + purchase_type: Option<Option<String>>, + redirect_url: Option<Option<String>>, + shipping_delay: Option<Option<i64>>, + shipping_first_name: Option<Option<String>>, + shipping_last_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeKlarna { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeKlarna>, + builder: SourceTypeKlarnaBuilder, + } + + impl Visitor for Place<SourceTypeKlarna> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeKlarnaBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeKlarnaBuilder { + type Out = SourceTypeKlarna; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "background_image_url" => Deserialize::begin(&mut self.background_image_url), + "client_token" => Deserialize::begin(&mut self.client_token), + "first_name" => Deserialize::begin(&mut self.first_name), + "last_name" => Deserialize::begin(&mut self.last_name), + "locale" => Deserialize::begin(&mut self.locale), + "logo_url" => Deserialize::begin(&mut self.logo_url), + "page_title" => Deserialize::begin(&mut self.page_title), + "pay_later_asset_urls_descriptive" => Deserialize::begin(&mut self.pay_later_asset_urls_descriptive), + "pay_later_asset_urls_standard" => Deserialize::begin(&mut self.pay_later_asset_urls_standard), + "pay_later_name" => Deserialize::begin(&mut self.pay_later_name), + "pay_later_redirect_url" => Deserialize::begin(&mut self.pay_later_redirect_url), + "pay_now_asset_urls_descriptive" => Deserialize::begin(&mut self.pay_now_asset_urls_descriptive), + "pay_now_asset_urls_standard" => Deserialize::begin(&mut self.pay_now_asset_urls_standard), + "pay_now_name" => Deserialize::begin(&mut self.pay_now_name), + "pay_now_redirect_url" => Deserialize::begin(&mut self.pay_now_redirect_url), + "pay_over_time_asset_urls_descriptive" => Deserialize::begin(&mut self.pay_over_time_asset_urls_descriptive), + "pay_over_time_asset_urls_standard" => Deserialize::begin(&mut self.pay_over_time_asset_urls_standard), + "pay_over_time_name" => Deserialize::begin(&mut self.pay_over_time_name), + "pay_over_time_redirect_url" => Deserialize::begin(&mut self.pay_over_time_redirect_url), + "payment_method_categories" => Deserialize::begin(&mut self.payment_method_categories), + "purchase_country" => Deserialize::begin(&mut self.purchase_country), + "purchase_type" => Deserialize::begin(&mut self.purchase_type), + "redirect_url" => Deserialize::begin(&mut self.redirect_url), + "shipping_delay" => Deserialize::begin(&mut self.shipping_delay), + "shipping_first_name" => Deserialize::begin(&mut self.shipping_first_name), + "shipping_last_name" => Deserialize::begin(&mut self.shipping_last_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + background_image_url: Deserialize::default(), + client_token: Deserialize::default(), + first_name: Deserialize::default(), + last_name: Deserialize::default(), + locale: Deserialize::default(), + logo_url: Deserialize::default(), + page_title: Deserialize::default(), + pay_later_asset_urls_descriptive: Deserialize::default(), + pay_later_asset_urls_standard: Deserialize::default(), + pay_later_name: Deserialize::default(), + pay_later_redirect_url: Deserialize::default(), + pay_now_asset_urls_descriptive: Deserialize::default(), + pay_now_asset_urls_standard: Deserialize::default(), + pay_now_name: Deserialize::default(), + pay_now_redirect_url: Deserialize::default(), + pay_over_time_asset_urls_descriptive: Deserialize::default(), + pay_over_time_asset_urls_standard: Deserialize::default(), + pay_over_time_name: Deserialize::default(), + pay_over_time_redirect_url: Deserialize::default(), + payment_method_categories: Deserialize::default(), + purchase_country: Deserialize::default(), + purchase_type: Deserialize::default(), + redirect_url: Deserialize::default(), + shipping_delay: Deserialize::default(), + shipping_first_name: Deserialize::default(), + shipping_last_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let background_image_url = self.background_image_url.take()?; + let client_token = self.client_token.take()?; + let first_name = self.first_name.take()?; + let last_name = self.last_name.take()?; + let locale = self.locale.take()?; + let logo_url = self.logo_url.take()?; + let page_title = self.page_title.take()?; + let pay_later_asset_urls_descriptive = self.pay_later_asset_urls_descriptive.take()?; + let pay_later_asset_urls_standard = self.pay_later_asset_urls_standard.take()?; + let pay_later_name = self.pay_later_name.take()?; + let pay_later_redirect_url = self.pay_later_redirect_url.take()?; + let pay_now_asset_urls_descriptive = self.pay_now_asset_urls_descriptive.take()?; + let pay_now_asset_urls_standard = self.pay_now_asset_urls_standard.take()?; + let pay_now_name = self.pay_now_name.take()?; + let pay_now_redirect_url = self.pay_now_redirect_url.take()?; + let pay_over_time_asset_urls_descriptive = self.pay_over_time_asset_urls_descriptive.take()?; + let pay_over_time_asset_urls_standard = self.pay_over_time_asset_urls_standard.take()?; + let pay_over_time_name = self.pay_over_time_name.take()?; + let pay_over_time_redirect_url = self.pay_over_time_redirect_url.take()?; + let payment_method_categories = self.payment_method_categories.take()?; + let purchase_country = self.purchase_country.take()?; + let purchase_type = self.purchase_type.take()?; + let redirect_url = self.redirect_url.take()?; + let shipping_delay = self.shipping_delay.take()?; + let shipping_first_name = self.shipping_first_name.take()?; + let shipping_last_name = self.shipping_last_name.take()?; + + Some(Self::Out { + background_image_url, + client_token, + first_name, + last_name, + locale, + logo_url, + page_title, + pay_later_asset_urls_descriptive, + pay_later_asset_urls_standard, + pay_later_name, + pay_later_redirect_url, + pay_now_asset_urls_descriptive, + pay_now_asset_urls_standard, + pay_now_name, + pay_now_redirect_url, + pay_over_time_asset_urls_descriptive, + pay_over_time_asset_urls_standard, + pay_over_time_name, + pay_over_time_redirect_url, + payment_method_categories, + purchase_country, + purchase_type, + redirect_url, + shipping_delay, + shipping_first_name, + shipping_last_name, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeKlarna { + type Builder = SourceTypeKlarnaBuilder; + } + + impl FromValueOpt for SourceTypeKlarna { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeKlarnaBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "background_image_url" => b.background_image_url = Some(FromValueOpt::from_value(v)?), + "client_token" => b.client_token = Some(FromValueOpt::from_value(v)?), + "first_name" => b.first_name = Some(FromValueOpt::from_value(v)?), + "last_name" => b.last_name = Some(FromValueOpt::from_value(v)?), + "locale" => b.locale = Some(FromValueOpt::from_value(v)?), + "logo_url" => b.logo_url = Some(FromValueOpt::from_value(v)?), + "page_title" => b.page_title = Some(FromValueOpt::from_value(v)?), + "pay_later_asset_urls_descriptive" => b.pay_later_asset_urls_descriptive = Some(FromValueOpt::from_value(v)?), + "pay_later_asset_urls_standard" => b.pay_later_asset_urls_standard = Some(FromValueOpt::from_value(v)?), + "pay_later_name" => b.pay_later_name = Some(FromValueOpt::from_value(v)?), + "pay_later_redirect_url" => b.pay_later_redirect_url = Some(FromValueOpt::from_value(v)?), + "pay_now_asset_urls_descriptive" => b.pay_now_asset_urls_descriptive = Some(FromValueOpt::from_value(v)?), + "pay_now_asset_urls_standard" => b.pay_now_asset_urls_standard = Some(FromValueOpt::from_value(v)?), + "pay_now_name" => b.pay_now_name = Some(FromValueOpt::from_value(v)?), + "pay_now_redirect_url" => b.pay_now_redirect_url = Some(FromValueOpt::from_value(v)?), + "pay_over_time_asset_urls_descriptive" => b.pay_over_time_asset_urls_descriptive = Some(FromValueOpt::from_value(v)?), + "pay_over_time_asset_urls_standard" => b.pay_over_time_asset_urls_standard = Some(FromValueOpt::from_value(v)?), + "pay_over_time_name" => b.pay_over_time_name = Some(FromValueOpt::from_value(v)?), + "pay_over_time_redirect_url" => b.pay_over_time_redirect_url = Some(FromValueOpt::from_value(v)?), + "payment_method_categories" => b.payment_method_categories = Some(FromValueOpt::from_value(v)?), + "purchase_country" => b.purchase_country = Some(FromValueOpt::from_value(v)?), + "purchase_type" => b.purchase_type = Some(FromValueOpt::from_value(v)?), + "redirect_url" => b.redirect_url = Some(FromValueOpt::from_value(v)?), + "shipping_delay" => b.shipping_delay = Some(FromValueOpt::from_value(v)?), + "shipping_first_name" => b.shipping_first_name = Some(FromValueOpt::from_value(v)?), + "shipping_last_name" => b.shipping_last_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_multibanco.rs b/generated/stripe_shared/src/source_type_multibanco.rs index 8765f2828..ccd32e0af 100644 --- a/generated/stripe_shared/src/source_type_multibanco.rs +++ b/generated/stripe_shared/src/source_type_multibanco.rs @@ -1,23 +1,159 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeMultibanco { - #[serde(skip_serializing_if = "Option::is_none")] pub entity: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_city: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line1: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line2: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_postal_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_state: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_iban: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeMultibancoBuilder { + entity: Option<Option<String>>, + reference: Option<Option<String>>, + refund_account_holder_address_city: Option<Option<String>>, + refund_account_holder_address_country: Option<Option<String>>, + refund_account_holder_address_line1: Option<Option<String>>, + refund_account_holder_address_line2: Option<Option<String>>, + refund_account_holder_address_postal_code: Option<Option<String>>, + refund_account_holder_address_state: Option<Option<String>>, + refund_account_holder_name: Option<Option<String>>, + refund_iban: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeMultibanco { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeMultibanco>, + builder: SourceTypeMultibancoBuilder, + } + + impl Visitor for Place<SourceTypeMultibanco> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeMultibancoBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeMultibancoBuilder { + type Out = SourceTypeMultibanco; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "entity" => Deserialize::begin(&mut self.entity), + "reference" => Deserialize::begin(&mut self.reference), + "refund_account_holder_address_city" => Deserialize::begin(&mut self.refund_account_holder_address_city), + "refund_account_holder_address_country" => Deserialize::begin(&mut self.refund_account_holder_address_country), + "refund_account_holder_address_line1" => Deserialize::begin(&mut self.refund_account_holder_address_line1), + "refund_account_holder_address_line2" => Deserialize::begin(&mut self.refund_account_holder_address_line2), + "refund_account_holder_address_postal_code" => Deserialize::begin(&mut self.refund_account_holder_address_postal_code), + "refund_account_holder_address_state" => Deserialize::begin(&mut self.refund_account_holder_address_state), + "refund_account_holder_name" => Deserialize::begin(&mut self.refund_account_holder_name), + "refund_iban" => Deserialize::begin(&mut self.refund_iban), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + entity: Deserialize::default(), + reference: Deserialize::default(), + refund_account_holder_address_city: Deserialize::default(), + refund_account_holder_address_country: Deserialize::default(), + refund_account_holder_address_line1: Deserialize::default(), + refund_account_holder_address_line2: Deserialize::default(), + refund_account_holder_address_postal_code: Deserialize::default(), + refund_account_holder_address_state: Deserialize::default(), + refund_account_holder_name: Deserialize::default(), + refund_iban: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let entity = self.entity.take()?; + let reference = self.reference.take()?; + let refund_account_holder_address_city = self.refund_account_holder_address_city.take()?; + let refund_account_holder_address_country = self.refund_account_holder_address_country.take()?; + let refund_account_holder_address_line1 = self.refund_account_holder_address_line1.take()?; + let refund_account_holder_address_line2 = self.refund_account_holder_address_line2.take()?; + let refund_account_holder_address_postal_code = self.refund_account_holder_address_postal_code.take()?; + let refund_account_holder_address_state = self.refund_account_holder_address_state.take()?; + let refund_account_holder_name = self.refund_account_holder_name.take()?; + let refund_iban = self.refund_iban.take()?; + + Some(Self::Out { + entity, + reference, + refund_account_holder_address_city, + refund_account_holder_address_country, + refund_account_holder_address_line1, + refund_account_holder_address_line2, + refund_account_holder_address_postal_code, + refund_account_holder_address_state, + refund_account_holder_name, + refund_iban, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeMultibanco { + type Builder = SourceTypeMultibancoBuilder; + } + + impl FromValueOpt for SourceTypeMultibanco { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeMultibancoBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "entity" => b.entity = Some(FromValueOpt::from_value(v)?), + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_city" => b.refund_account_holder_address_city = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_country" => b.refund_account_holder_address_country = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_line1" => b.refund_account_holder_address_line1 = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_line2" => b.refund_account_holder_address_line2 = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_postal_code" => b.refund_account_holder_address_postal_code = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_state" => b.refund_account_holder_address_state = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_name" => b.refund_account_holder_name = Some(FromValueOpt::from_value(v)?), + "refund_iban" => b.refund_iban = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_p24.rs b/generated/stripe_shared/src/source_type_p24.rs index c7bb5edda..3c8c25123 100644 --- a/generated/stripe_shared/src/source_type_p24.rs +++ b/generated/stripe_shared/src/source_type_p24.rs @@ -1,5 +1,92 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeP24 { - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeP24Builder { + reference: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeP24 { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeP24>, + builder: SourceTypeP24Builder, + } + + impl Visitor for Place<SourceTypeP24> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeP24Builder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeP24Builder { + type Out = SourceTypeP24; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reference = self.reference.take()?; + + Some(Self::Out { reference }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeP24 { + type Builder = SourceTypeP24Builder; + } + + impl FromValueOpt for SourceTypeP24 { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeP24Builder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_sepa_credit_transfer.rs b/generated/stripe_shared/src/source_type_sepa_credit_transfer.rs index 6fc345841..54cbde12c 100644 --- a/generated/stripe_shared/src/source_type_sepa_credit_transfer.rs +++ b/generated/stripe_shared/src/source_type_sepa_credit_transfer.rs @@ -1,25 +1,166 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeSepaCreditTransfer { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub iban: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_city: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line1: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line2: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_postal_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_state: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_iban: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeSepaCreditTransferBuilder { + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + iban: Option<Option<String>>, + refund_account_holder_address_city: Option<Option<String>>, + refund_account_holder_address_country: Option<Option<String>>, + refund_account_holder_address_line1: Option<Option<String>>, + refund_account_holder_address_line2: Option<Option<String>>, + refund_account_holder_address_postal_code: Option<Option<String>>, + refund_account_holder_address_state: Option<Option<String>>, + refund_account_holder_name: Option<Option<String>>, + refund_iban: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeSepaCreditTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeSepaCreditTransfer>, + builder: SourceTypeSepaCreditTransferBuilder, + } + + impl Visitor for Place<SourceTypeSepaCreditTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeSepaCreditTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeSepaCreditTransferBuilder { + type Out = SourceTypeSepaCreditTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "iban" => Deserialize::begin(&mut self.iban), + "refund_account_holder_address_city" => Deserialize::begin(&mut self.refund_account_holder_address_city), + "refund_account_holder_address_country" => Deserialize::begin(&mut self.refund_account_holder_address_country), + "refund_account_holder_address_line1" => Deserialize::begin(&mut self.refund_account_holder_address_line1), + "refund_account_holder_address_line2" => Deserialize::begin(&mut self.refund_account_holder_address_line2), + "refund_account_holder_address_postal_code" => Deserialize::begin(&mut self.refund_account_holder_address_postal_code), + "refund_account_holder_address_state" => Deserialize::begin(&mut self.refund_account_holder_address_state), + "refund_account_holder_name" => Deserialize::begin(&mut self.refund_account_holder_name), + "refund_iban" => Deserialize::begin(&mut self.refund_iban), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_name: Deserialize::default(), + bic: Deserialize::default(), + iban: Deserialize::default(), + refund_account_holder_address_city: Deserialize::default(), + refund_account_holder_address_country: Deserialize::default(), + refund_account_holder_address_line1: Deserialize::default(), + refund_account_holder_address_line2: Deserialize::default(), + refund_account_holder_address_postal_code: Deserialize::default(), + refund_account_holder_address_state: Deserialize::default(), + refund_account_holder_name: Deserialize::default(), + refund_iban: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let iban = self.iban.take()?; + let refund_account_holder_address_city = self.refund_account_holder_address_city.take()?; + let refund_account_holder_address_country = self.refund_account_holder_address_country.take()?; + let refund_account_holder_address_line1 = self.refund_account_holder_address_line1.take()?; + let refund_account_holder_address_line2 = self.refund_account_holder_address_line2.take()?; + let refund_account_holder_address_postal_code = self.refund_account_holder_address_postal_code.take()?; + let refund_account_holder_address_state = self.refund_account_holder_address_state.take()?; + let refund_account_holder_name = self.refund_account_holder_name.take()?; + let refund_iban = self.refund_iban.take()?; + + Some(Self::Out { + bank_name, + bic, + iban, + refund_account_holder_address_city, + refund_account_holder_address_country, + refund_account_holder_address_line1, + refund_account_holder_address_line2, + refund_account_holder_address_postal_code, + refund_account_holder_address_state, + refund_account_holder_name, + refund_iban, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeSepaCreditTransfer { + type Builder = SourceTypeSepaCreditTransferBuilder; + } + + impl FromValueOpt for SourceTypeSepaCreditTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeSepaCreditTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "iban" => b.iban = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_city" => b.refund_account_holder_address_city = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_country" => b.refund_account_holder_address_country = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_line1" => b.refund_account_holder_address_line1 = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_line2" => b.refund_account_holder_address_line2 = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_postal_code" => b.refund_account_holder_address_postal_code = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_address_state" => b.refund_account_holder_address_state = Some(FromValueOpt::from_value(v)?), + "refund_account_holder_name" => b.refund_account_holder_name = Some(FromValueOpt::from_value(v)?), + "refund_iban" => b.refund_iban = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_sepa_debit.rs b/generated/stripe_shared/src/source_type_sepa_debit.rs index 30b5d9495..6201aa7f1 100644 --- a/generated/stripe_shared/src/source_type_sepa_debit.rs +++ b/generated/stripe_shared/src/source_type_sepa_debit.rs @@ -1,17 +1,130 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeSepaDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub branch_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_reference: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_url: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeSepaDebitBuilder { + bank_code: Option<Option<String>>, + branch_code: Option<Option<String>>, + country: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + mandate_reference: Option<Option<String>>, + mandate_url: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeSepaDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeSepaDebit>, + builder: SourceTypeSepaDebitBuilder, + } + + impl Visitor for Place<SourceTypeSepaDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeSepaDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeSepaDebitBuilder { + type Out = SourceTypeSepaDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "branch_code" => Deserialize::begin(&mut self.branch_code), + "country" => Deserialize::begin(&mut self.country), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "mandate_reference" => Deserialize::begin(&mut self.mandate_reference), + "mandate_url" => Deserialize::begin(&mut self.mandate_url), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + branch_code: Deserialize::default(), + country: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + mandate_reference: Deserialize::default(), + mandate_url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let branch_code = self.branch_code.take()?; + let country = self.country.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let mandate_reference = self.mandate_reference.take()?; + let mandate_url = self.mandate_url.take()?; + + Some(Self::Out { bank_code, branch_code, country, fingerprint, last4, mandate_reference, mandate_url }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeSepaDebit { + type Builder = SourceTypeSepaDebitBuilder; + } + + impl FromValueOpt for SourceTypeSepaDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeSepaDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "branch_code" => b.branch_code = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "mandate_reference" => b.mandate_reference = Some(FromValueOpt::from_value(v)?), + "mandate_url" => b.mandate_url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_sofort.rs b/generated/stripe_shared/src/source_type_sofort.rs index 8cd9f2f9f..31ee02e0e 100644 --- a/generated/stripe_shared/src/source_type_sofort.rs +++ b/generated/stripe_shared/src/source_type_sofort.rs @@ -1,17 +1,130 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeSofort { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub iban_last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_language: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeSofortBuilder { + bank_code: Option<Option<String>>, + bank_name: Option<Option<String>>, + bic: Option<Option<String>>, + country: Option<Option<String>>, + iban_last4: Option<Option<String>>, + preferred_language: Option<Option<String>>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeSofort { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeSofort>, + builder: SourceTypeSofortBuilder, + } + + impl Visitor for Place<SourceTypeSofort> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeSofortBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeSofortBuilder { + type Out = SourceTypeSofort; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_code" => Deserialize::begin(&mut self.bank_code), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "bic" => Deserialize::begin(&mut self.bic), + "country" => Deserialize::begin(&mut self.country), + "iban_last4" => Deserialize::begin(&mut self.iban_last4), + "preferred_language" => Deserialize::begin(&mut self.preferred_language), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + bic: Deserialize::default(), + country: Deserialize::default(), + iban_last4: Deserialize::default(), + preferred_language: Deserialize::default(), + statement_descriptor: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_code = self.bank_code.take()?; + let bank_name = self.bank_name.take()?; + let bic = self.bic.take()?; + let country = self.country.take()?; + let iban_last4 = self.iban_last4.take()?; + let preferred_language = self.preferred_language.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { bank_code, bank_name, bic, country, iban_last4, preferred_language, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeSofort { + type Builder = SourceTypeSofortBuilder; + } + + impl FromValueOpt for SourceTypeSofort { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeSofortBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_code" => b.bank_code = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "bic" => b.bic = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "iban_last4" => b.iban_last4 = Some(FromValueOpt::from_value(v)?), + "preferred_language" => b.preferred_language = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_three_d_secure.rs b/generated/stripe_shared/src/source_type_three_d_secure.rs index 5a64afe54..9d45c3b73 100644 --- a/generated/stripe_shared/src/source_type_three_d_secure.rs +++ b/generated/stripe_shared/src/source_type_three_d_secure.rs @@ -1,43 +1,229 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeThreeDSecure { - #[serde(skip_serializing_if = "Option::is_none")] pub address_line1_check: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub address_zip_check: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub authenticated: Option<bool>, - #[serde(skip_serializing_if = "Option::is_none")] pub brand: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub cvc_check: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_month: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_year: Option<i64>, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub funding: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub three_d_secure: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub tokenization_method: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeThreeDSecureBuilder { + address_line1_check: Option<Option<String>>, + address_zip_check: Option<Option<String>>, + authenticated: Option<Option<bool>>, + brand: Option<Option<String>>, + card: Option<Option<String>>, + country: Option<Option<String>>, + customer: Option<Option<String>>, + cvc_check: Option<Option<String>>, + description: Option<Option<String>>, + dynamic_last4: Option<Option<String>>, + exp_month: Option<Option<i64>>, + exp_year: Option<Option<i64>>, + fingerprint: Option<Option<String>>, + funding: Option<Option<String>>, + iin: Option<Option<String>>, + issuer: Option<Option<String>>, + last4: Option<Option<String>>, + name: Option<Option<String>>, + three_d_secure: Option<Option<String>>, + tokenization_method: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeThreeDSecure { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeThreeDSecure>, + builder: SourceTypeThreeDSecureBuilder, + } + + impl Visitor for Place<SourceTypeThreeDSecure> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeThreeDSecureBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeThreeDSecureBuilder { + type Out = SourceTypeThreeDSecure; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address_line1_check" => Deserialize::begin(&mut self.address_line1_check), + "address_zip_check" => Deserialize::begin(&mut self.address_zip_check), + "authenticated" => Deserialize::begin(&mut self.authenticated), + "brand" => Deserialize::begin(&mut self.brand), + "card" => Deserialize::begin(&mut self.card), + "country" => Deserialize::begin(&mut self.country), + "customer" => Deserialize::begin(&mut self.customer), + "cvc_check" => Deserialize::begin(&mut self.cvc_check), + "description" => Deserialize::begin(&mut self.description), + "dynamic_last4" => Deserialize::begin(&mut self.dynamic_last4), + "exp_month" => Deserialize::begin(&mut self.exp_month), + "exp_year" => Deserialize::begin(&mut self.exp_year), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "funding" => Deserialize::begin(&mut self.funding), + "iin" => Deserialize::begin(&mut self.iin), + "issuer" => Deserialize::begin(&mut self.issuer), + "last4" => Deserialize::begin(&mut self.last4), + "name" => Deserialize::begin(&mut self.name), + "three_d_secure" => Deserialize::begin(&mut self.three_d_secure), + "tokenization_method" => Deserialize::begin(&mut self.tokenization_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address_line1_check: Deserialize::default(), + address_zip_check: Deserialize::default(), + authenticated: Deserialize::default(), + brand: Deserialize::default(), + card: Deserialize::default(), + country: Deserialize::default(), + customer: Deserialize::default(), + cvc_check: Deserialize::default(), + description: Deserialize::default(), + dynamic_last4: Deserialize::default(), + exp_month: Deserialize::default(), + exp_year: Deserialize::default(), + fingerprint: Deserialize::default(), + funding: Deserialize::default(), + iin: Deserialize::default(), + issuer: Deserialize::default(), + last4: Deserialize::default(), + name: Deserialize::default(), + three_d_secure: Deserialize::default(), + tokenization_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address_line1_check = self.address_line1_check.take()?; + let address_zip_check = self.address_zip_check.take()?; + let authenticated = self.authenticated.take()?; + let brand = self.brand.take()?; + let card = self.card.take()?; + let country = self.country.take()?; + let customer = self.customer.take()?; + let cvc_check = self.cvc_check.take()?; + let description = self.description.take()?; + let dynamic_last4 = self.dynamic_last4.take()?; + let exp_month = self.exp_month.take()?; + let exp_year = self.exp_year.take()?; + let fingerprint = self.fingerprint.take()?; + let funding = self.funding.take()?; + let iin = self.iin.take()?; + let issuer = self.issuer.take()?; + let last4 = self.last4.take()?; + let name = self.name.take()?; + let three_d_secure = self.three_d_secure.take()?; + let tokenization_method = self.tokenization_method.take()?; + + Some(Self::Out { + address_line1_check, + address_zip_check, + authenticated, + brand, + card, + country, + customer, + cvc_check, + description, + dynamic_last4, + exp_month, + exp_year, + fingerprint, + funding, + iin, + issuer, + last4, + name, + three_d_secure, + tokenization_method, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeThreeDSecure { + type Builder = SourceTypeThreeDSecureBuilder; + } + + impl FromValueOpt for SourceTypeThreeDSecure { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeThreeDSecureBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address_line1_check" => b.address_line1_check = Some(FromValueOpt::from_value(v)?), + "address_zip_check" => b.address_zip_check = Some(FromValueOpt::from_value(v)?), + "authenticated" => b.authenticated = Some(FromValueOpt::from_value(v)?), + "brand" => b.brand = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "cvc_check" => b.cvc_check = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "dynamic_last4" => b.dynamic_last4 = Some(FromValueOpt::from_value(v)?), + "exp_month" => b.exp_month = Some(FromValueOpt::from_value(v)?), + "exp_year" => b.exp_year = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "funding" => b.funding = Some(FromValueOpt::from_value(v)?), + "iin" => b.iin = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "three_d_secure" => b.three_d_secure = Some(FromValueOpt::from_value(v)?), + "tokenization_method" => b.tokenization_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/source_type_wechat.rs b/generated/stripe_shared/src/source_type_wechat.rs index 72ba418f9..93c88a807 100644 --- a/generated/stripe_shared/src/source_type_wechat.rs +++ b/generated/stripe_shared/src/source_type_wechat.rs @@ -1,9 +1,102 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SourceTypeWechat { - #[serde(skip_serializing_if = "Option::is_none")] pub prepay_id: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub qr_code_url: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct SourceTypeWechatBuilder { + prepay_id: Option<Option<String>>, + qr_code_url: Option<Option<String>>, + statement_descriptor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SourceTypeWechat { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SourceTypeWechat>, + builder: SourceTypeWechatBuilder, + } + + impl Visitor for Place<SourceTypeWechat> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SourceTypeWechatBuilder::deser_default() })) + } + } + + impl MapBuilder for SourceTypeWechatBuilder { + type Out = SourceTypeWechat; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "prepay_id" => Deserialize::begin(&mut self.prepay_id), + "qr_code_url" => Deserialize::begin(&mut self.qr_code_url), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { prepay_id: Deserialize::default(), qr_code_url: Deserialize::default(), statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let prepay_id = self.prepay_id.take()?; + let qr_code_url = self.qr_code_url.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + + Some(Self::Out { prepay_id, qr_code_url, statement_descriptor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SourceTypeWechat { + type Builder = SourceTypeWechatBuilder; + } + + impl FromValueOpt for SourceTypeWechat { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SourceTypeWechatBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "prepay_id" => b.prepay_id = Some(FromValueOpt::from_value(v)?), + "qr_code_url" => b.qr_code_url = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription.rs b/generated/stripe_shared/src/subscription.rs index 587fcf24a..a0c88762f 100644 --- a/generated/stripe_shared/src/subscription.rs +++ b/generated/stripe_shared/src/subscription.rs @@ -3,7 +3,9 @@ /// Related guide: [Creating subscriptions](https://stripe.com/docs/billing/subscriptions/creating) /// /// For more details see <<https://stripe.com/docs/api/subscriptions/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Subscription { /// ID of the Connect Application that created the subscription. pub application: Option<stripe_types::Expandable<stripe_shared::Application>>, @@ -11,13 +13,9 @@ pub struct Subscription { /// This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account. pub application_fee_percent: Option<f64>, pub automatic_tax: stripe_shared::SubscriptionAutomaticTax, - /// The reference point that aligns future [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle) dates. - /// It sets the day of week for `week` intervals, the day of month for `month` and `year` intervals, and the month of year for `year` intervals. + /// Determines the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. /// The timestamp is in UTC format. pub billing_cycle_anchor: stripe_types::Timestamp, - /// The fixed values used to calculate the `billing_cycle_anchor`. - pub billing_cycle_anchor_config: - Option<stripe_shared::SubscriptionsResourceBillingCycleAnchorConfig>, /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. pub billing_thresholds: Option<stripe_shared::SubscriptionBillingThresholds>, /// A date in the future at which the subscription will automatically get canceled @@ -61,7 +59,6 @@ pub struct Subscription { pub default_source: Option<stripe_types::Expandable<stripe_shared::PaymentSource>>, /// The tax rates that will apply to any subscription item that does not have `tax_rates` set. /// Invoices created will have their `default_tax_rates` populated from the subscription. - #[serde(skip_serializing_if = "Option::is_none")] pub default_tax_rates: Option<Vec<stripe_shared::TaxRate>>, /// The subscription's description, meant to be displayable to the customer. /// Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs. @@ -93,8 +90,7 @@ pub struct Subscription { pub payment_settings: Option<stripe_shared::SubscriptionsResourcePaymentSettings>, /// Specifies an interval for how often to bill for any pending invoice items. /// It is analogous to calling [Create an invoice](https://stripe.com/docs/api#create_invoice) for the given subscription at the specified interval. - pub pending_invoice_item_interval: - Option<stripe_shared::SubscriptionPendingInvoiceItemInterval>, + pub pending_invoice_item_interval: Option<stripe_shared::SubscriptionPendingInvoiceItemInterval>, /// You can use this [SetupIntent](https://stripe.com/docs/api/setup_intents) to collect user authentication when creating a subscription without immediate payment or updating a subscription's payment method, allowing you to optimize for off-session payments. /// Learn more in the [SCA Migration Guide](https://stripe.com/docs/billing/migration/strong-customer-authentication#scenario-2). pub pending_setup_intent: Option<stripe_types::Expandable<stripe_shared::SetupIntent>>, @@ -137,6 +133,342 @@ pub struct Subscription { /// If the subscription has a trial, the beginning of that trial. pub trial_start: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionBuilder { + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + application_fee_percent: Option<Option<f64>>, + automatic_tax: Option<stripe_shared::SubscriptionAutomaticTax>, + billing_cycle_anchor: Option<stripe_types::Timestamp>, + billing_thresholds: Option<Option<stripe_shared::SubscriptionBillingThresholds>>, + cancel_at: Option<Option<stripe_types::Timestamp>>, + cancel_at_period_end: Option<bool>, + canceled_at: Option<Option<stripe_types::Timestamp>>, + cancellation_details: Option<Option<stripe_shared::CancellationDetails>>, + collection_method: Option<stripe_shared::SubscriptionCollectionMethod>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + current_period_end: Option<stripe_types::Timestamp>, + current_period_start: Option<stripe_types::Timestamp>, + customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, + days_until_due: Option<Option<u32>>, + default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + default_source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>, + default_tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>, + description: Option<Option<String>>, + discount: Option<Option<stripe_shared::Discount>>, + ended_at: Option<Option<stripe_types::Timestamp>>, + id: Option<stripe_shared::SubscriptionId>, + items: Option<stripe_types::List<stripe_shared::SubscriptionItem>>, + latest_invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + next_pending_invoice_item_invoice: Option<Option<stripe_types::Timestamp>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + pause_collection: Option<Option<stripe_shared::SubscriptionsResourcePauseCollection>>, + payment_settings: Option<Option<stripe_shared::SubscriptionsResourcePaymentSettings>>, + pending_invoice_item_interval: Option<Option<stripe_shared::SubscriptionPendingInvoiceItemInterval>>, + pending_setup_intent: Option<Option<stripe_types::Expandable<stripe_shared::SetupIntent>>>, + pending_update: Option<Option<stripe_shared::SubscriptionsResourcePendingUpdate>>, + schedule: Option<Option<stripe_types::Expandable<stripe_shared::SubscriptionSchedule>>>, + start_date: Option<stripe_types::Timestamp>, + status: Option<SubscriptionStatus>, + test_clock: Option<Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>>, + transfer_data: Option<Option<stripe_shared::SubscriptionTransferData>>, + trial_end: Option<Option<stripe_types::Timestamp>>, + trial_settings: Option<Option<stripe_shared::SubscriptionsTrialsResourceTrialSettings>>, + trial_start: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Subscription { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Subscription>, + builder: SubscriptionBuilder, + } + + impl Visitor for Place<Subscription> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionBuilder { + type Out = Subscription; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "application" => Deserialize::begin(&mut self.application), + "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent), + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "billing_cycle_anchor" => Deserialize::begin(&mut self.billing_cycle_anchor), + "billing_thresholds" => Deserialize::begin(&mut self.billing_thresholds), + "cancel_at" => Deserialize::begin(&mut self.cancel_at), + "cancel_at_period_end" => Deserialize::begin(&mut self.cancel_at_period_end), + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "cancellation_details" => Deserialize::begin(&mut self.cancellation_details), + "collection_method" => Deserialize::begin(&mut self.collection_method), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "current_period_end" => Deserialize::begin(&mut self.current_period_end), + "current_period_start" => Deserialize::begin(&mut self.current_period_start), + "customer" => Deserialize::begin(&mut self.customer), + "days_until_due" => Deserialize::begin(&mut self.days_until_due), + "default_payment_method" => Deserialize::begin(&mut self.default_payment_method), + "default_source" => Deserialize::begin(&mut self.default_source), + "default_tax_rates" => Deserialize::begin(&mut self.default_tax_rates), + "description" => Deserialize::begin(&mut self.description), + "discount" => Deserialize::begin(&mut self.discount), + "ended_at" => Deserialize::begin(&mut self.ended_at), + "id" => Deserialize::begin(&mut self.id), + "items" => Deserialize::begin(&mut self.items), + "latest_invoice" => Deserialize::begin(&mut self.latest_invoice), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "next_pending_invoice_item_invoice" => Deserialize::begin(&mut self.next_pending_invoice_item_invoice), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "pause_collection" => Deserialize::begin(&mut self.pause_collection), + "payment_settings" => Deserialize::begin(&mut self.payment_settings), + "pending_invoice_item_interval" => Deserialize::begin(&mut self.pending_invoice_item_interval), + "pending_setup_intent" => Deserialize::begin(&mut self.pending_setup_intent), + "pending_update" => Deserialize::begin(&mut self.pending_update), + "schedule" => Deserialize::begin(&mut self.schedule), + "start_date" => Deserialize::begin(&mut self.start_date), + "status" => Deserialize::begin(&mut self.status), + "test_clock" => Deserialize::begin(&mut self.test_clock), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + "trial_end" => Deserialize::begin(&mut self.trial_end), + "trial_settings" => Deserialize::begin(&mut self.trial_settings), + "trial_start" => Deserialize::begin(&mut self.trial_start), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + application: Deserialize::default(), + application_fee_percent: Deserialize::default(), + automatic_tax: Deserialize::default(), + billing_cycle_anchor: Deserialize::default(), + billing_thresholds: Deserialize::default(), + cancel_at: Deserialize::default(), + cancel_at_period_end: Deserialize::default(), + canceled_at: Deserialize::default(), + cancellation_details: Deserialize::default(), + collection_method: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + current_period_end: Deserialize::default(), + current_period_start: Deserialize::default(), + customer: Deserialize::default(), + days_until_due: Deserialize::default(), + default_payment_method: Deserialize::default(), + default_source: Deserialize::default(), + default_tax_rates: Deserialize::default(), + description: Deserialize::default(), + discount: Deserialize::default(), + ended_at: Deserialize::default(), + id: Deserialize::default(), + items: Deserialize::default(), + latest_invoice: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + next_pending_invoice_item_invoice: Deserialize::default(), + on_behalf_of: Deserialize::default(), + pause_collection: Deserialize::default(), + payment_settings: Deserialize::default(), + pending_invoice_item_interval: Deserialize::default(), + pending_setup_intent: Deserialize::default(), + pending_update: Deserialize::default(), + schedule: Deserialize::default(), + start_date: Deserialize::default(), + status: Deserialize::default(), + test_clock: Deserialize::default(), + transfer_data: Deserialize::default(), + trial_end: Deserialize::default(), + trial_settings: Deserialize::default(), + trial_start: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let application = self.application.take()?; + let application_fee_percent = self.application_fee_percent.take()?; + let automatic_tax = self.automatic_tax.take()?; + let billing_cycle_anchor = self.billing_cycle_anchor.take()?; + let billing_thresholds = self.billing_thresholds.take()?; + let cancel_at = self.cancel_at.take()?; + let cancel_at_period_end = self.cancel_at_period_end.take()?; + let canceled_at = self.canceled_at.take()?; + let cancellation_details = self.cancellation_details.take()?; + let collection_method = self.collection_method.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let current_period_end = self.current_period_end.take()?; + let current_period_start = self.current_period_start.take()?; + let customer = self.customer.take()?; + let days_until_due = self.days_until_due.take()?; + let default_payment_method = self.default_payment_method.take()?; + let default_source = self.default_source.take()?; + let default_tax_rates = self.default_tax_rates.take()?; + let description = self.description.take()?; + let discount = self.discount.take()?; + let ended_at = self.ended_at.take()?; + let id = self.id.take()?; + let items = self.items.take()?; + let latest_invoice = self.latest_invoice.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let next_pending_invoice_item_invoice = self.next_pending_invoice_item_invoice.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let pause_collection = self.pause_collection.take()?; + let payment_settings = self.payment_settings.take()?; + let pending_invoice_item_interval = self.pending_invoice_item_interval.take()?; + let pending_setup_intent = self.pending_setup_intent.take()?; + let pending_update = self.pending_update.take()?; + let schedule = self.schedule.take()?; + let start_date = self.start_date.take()?; + let status = self.status.take()?; + let test_clock = self.test_clock.take()?; + let transfer_data = self.transfer_data.take()?; + let trial_end = self.trial_end.take()?; + let trial_settings = self.trial_settings.take()?; + let trial_start = self.trial_start.take()?; + + Some(Self::Out { + application, + application_fee_percent, + automatic_tax, + billing_cycle_anchor, + billing_thresholds, + cancel_at, + cancel_at_period_end, + canceled_at, + cancellation_details, + collection_method, + created, + currency, + current_period_end, + current_period_start, + customer, + days_until_due, + default_payment_method, + default_source, + default_tax_rates, + description, + discount, + ended_at, + id, + items, + latest_invoice, + livemode, + metadata, + next_pending_invoice_item_invoice, + on_behalf_of, + pause_collection, + payment_settings, + pending_invoice_item_interval, + pending_setup_intent, + pending_update, + schedule, + start_date, + status, + test_clock, + transfer_data, + trial_end, + trial_settings, + trial_start, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Subscription { + type Builder = SubscriptionBuilder; + } + + impl FromValueOpt for Subscription { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "application_fee_percent" => b.application_fee_percent = Some(FromValueOpt::from_value(v)?), + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "billing_cycle_anchor" => b.billing_cycle_anchor = Some(FromValueOpt::from_value(v)?), + "billing_thresholds" => b.billing_thresholds = Some(FromValueOpt::from_value(v)?), + "cancel_at" => b.cancel_at = Some(FromValueOpt::from_value(v)?), + "cancel_at_period_end" => b.cancel_at_period_end = Some(FromValueOpt::from_value(v)?), + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "cancellation_details" => b.cancellation_details = Some(FromValueOpt::from_value(v)?), + "collection_method" => b.collection_method = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "current_period_end" => b.current_period_end = Some(FromValueOpt::from_value(v)?), + "current_period_start" => b.current_period_start = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "days_until_due" => b.days_until_due = Some(FromValueOpt::from_value(v)?), + "default_payment_method" => b.default_payment_method = Some(FromValueOpt::from_value(v)?), + "default_source" => b.default_source = Some(FromValueOpt::from_value(v)?), + "default_tax_rates" => b.default_tax_rates = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "discount" => b.discount = Some(FromValueOpt::from_value(v)?), + "ended_at" => b.ended_at = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "items" => b.items = Some(FromValueOpt::from_value(v)?), + "latest_invoice" => b.latest_invoice = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "next_pending_invoice_item_invoice" => b.next_pending_invoice_item_invoice = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "pause_collection" => b.pause_collection = Some(FromValueOpt::from_value(v)?), + "payment_settings" => b.payment_settings = Some(FromValueOpt::from_value(v)?), + "pending_invoice_item_interval" => b.pending_invoice_item_interval = Some(FromValueOpt::from_value(v)?), + "pending_setup_intent" => b.pending_setup_intent = Some(FromValueOpt::from_value(v)?), + "pending_update" => b.pending_update = Some(FromValueOpt::from_value(v)?), + "schedule" => b.schedule = Some(FromValueOpt::from_value(v)?), + "start_date" => b.start_date = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "test_clock" => b.test_clock = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + "trial_end" => b.trial_end = Some(FromValueOpt::from_value(v)?), + "trial_settings" => b.trial_settings = Some(FromValueOpt::from_value(v)?), + "trial_start" => b.trial_start = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, or `unpaid`. /// /// @@ -224,10 +556,27 @@ impl<'de> serde::Deserialize<'de> for SubscriptionStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionStatus); impl stripe_types::Object for Subscription { type Id = stripe_shared::SubscriptionId; fn id(&self) -> &Self::Id { @@ -284,7 +633,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionCollectionMethod { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionCollectionMethod")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionCollectionMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionCollectionMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionCollectionMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionCollectionMethod); diff --git a/generated/stripe_shared/src/subscription_automatic_tax.rs b/generated/stripe_shared/src/subscription_automatic_tax.rs index 4328f2c5f..c26a75788 100644 --- a/generated/stripe_shared/src/subscription_automatic_tax.rs +++ b/generated/stripe_shared/src/subscription_automatic_tax.rs @@ -1,9 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionAutomaticTax { /// Whether Stripe automatically computes tax on this subscription. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - pub liability: Option<stripe_shared::ConnectAccountReference>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionAutomaticTaxBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionAutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionAutomaticTax>, + builder: SubscriptionAutomaticTaxBuilder, + } + + impl Visitor for Place<SubscriptionAutomaticTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionAutomaticTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionAutomaticTaxBuilder { + type Out = SubscriptionAutomaticTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionAutomaticTax { + type Builder = SubscriptionAutomaticTaxBuilder; + } + + impl FromValueOpt for SubscriptionAutomaticTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionAutomaticTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_billing_thresholds.rs b/generated/stripe_shared/src/subscription_billing_thresholds.rs index fd4a84121..c88b36205 100644 --- a/generated/stripe_shared/src/subscription_billing_thresholds.rs +++ b/generated/stripe_shared/src/subscription_billing_thresholds.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionBillingThresholds { /// Monetary threshold that triggers the subscription to create an invoice pub amount_gte: Option<i64>, @@ -7,3 +9,93 @@ pub struct SubscriptionBillingThresholds { /// This value may not be `true` if the subscription contains items with plans that have `aggregate_usage=last_ever`. pub reset_billing_cycle_anchor: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionBillingThresholdsBuilder { + amount_gte: Option<Option<i64>>, + reset_billing_cycle_anchor: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionBillingThresholds { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionBillingThresholds>, + builder: SubscriptionBillingThresholdsBuilder, + } + + impl Visitor for Place<SubscriptionBillingThresholds> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionBillingThresholdsBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionBillingThresholdsBuilder { + type Out = SubscriptionBillingThresholds; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_gte" => Deserialize::begin(&mut self.amount_gte), + "reset_billing_cycle_anchor" => Deserialize::begin(&mut self.reset_billing_cycle_anchor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_gte: Deserialize::default(), reset_billing_cycle_anchor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_gte = self.amount_gte.take()?; + let reset_billing_cycle_anchor = self.reset_billing_cycle_anchor.take()?; + + Some(Self::Out { amount_gte, reset_billing_cycle_anchor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionBillingThresholds { + type Builder = SubscriptionBillingThresholdsBuilder; + } + + impl FromValueOpt for SubscriptionBillingThresholds { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionBillingThresholdsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_gte" => b.amount_gte = Some(FromValueOpt::from_value(v)?), + "reset_billing_cycle_anchor" => b.reset_billing_cycle_anchor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_details_data.rs b/generated/stripe_shared/src/subscription_details_data.rs index 9aaed6099..664f09404 100644 --- a/generated/stripe_shared/src/subscription_details_data.rs +++ b/generated/stripe_shared/src/subscription_details_data.rs @@ -1,6 +1,94 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionDetailsData { /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that will reflect the metadata of the subscription at the time of invoice creation. /// *Note: This attribute is populated only for invoices created on or after June 29, 2023.*. pub metadata: Option<std::collections::HashMap<String, String>>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionDetailsDataBuilder { + metadata: Option<Option<std::collections::HashMap<String, String>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionDetailsData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionDetailsData>, + builder: SubscriptionDetailsDataBuilder, + } + + impl Visitor for Place<SubscriptionDetailsData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionDetailsDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionDetailsDataBuilder { + type Out = SubscriptionDetailsData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "metadata" => Deserialize::begin(&mut self.metadata), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { metadata: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let metadata = self.metadata.take()?; + + Some(Self::Out { metadata }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionDetailsData { + type Builder = SubscriptionDetailsDataBuilder; + } + + impl FromValueOpt for SubscriptionDetailsData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionDetailsDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_item.rs b/generated/stripe_shared/src/subscription_item.rs index f77fbbacf..f623d9a45 100644 --- a/generated/stripe_shared/src/subscription_item.rs +++ b/generated/stripe_shared/src/subscription_item.rs @@ -2,7 +2,9 @@ /// one plan, making it easy to represent complex billing relationships. /// /// For more details see <<https://stripe.com/docs/api/subscription_items/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionItem { /// Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period. pub billing_thresholds: Option<stripe_shared::SubscriptionItemBillingThresholds>, @@ -16,7 +18,6 @@ pub struct SubscriptionItem { pub plan: stripe_shared::Plan, pub price: stripe_shared::Price, /// The [quantity](https://stripe.com/docs/subscriptions/quantities) of the plan to which the customer should be subscribed. - #[serde(skip_serializing_if = "Option::is_none")] pub quantity: Option<u64>, /// The `subscription` this `subscription_item` belongs to. pub subscription: String, @@ -24,6 +25,134 @@ pub struct SubscriptionItem { /// When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`. pub tax_rates: Option<Vec<stripe_shared::TaxRate>>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionItemBuilder { + billing_thresholds: Option<Option<stripe_shared::SubscriptionItemBillingThresholds>>, + created: Option<i64>, + id: Option<stripe_shared::SubscriptionItemId>, + metadata: Option<std::collections::HashMap<String, String>>, + plan: Option<stripe_shared::Plan>, + price: Option<stripe_shared::Price>, + quantity: Option<Option<u64>>, + subscription: Option<String>, + tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionItem>, + builder: SubscriptionItemBuilder, + } + + impl Visitor for Place<SubscriptionItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionItemBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionItemBuilder { + type Out = SubscriptionItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_thresholds" => Deserialize::begin(&mut self.billing_thresholds), + "created" => Deserialize::begin(&mut self.created), + "id" => Deserialize::begin(&mut self.id), + "metadata" => Deserialize::begin(&mut self.metadata), + "plan" => Deserialize::begin(&mut self.plan), + "price" => Deserialize::begin(&mut self.price), + "quantity" => Deserialize::begin(&mut self.quantity), + "subscription" => Deserialize::begin(&mut self.subscription), + "tax_rates" => Deserialize::begin(&mut self.tax_rates), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing_thresholds: Deserialize::default(), + created: Deserialize::default(), + id: Deserialize::default(), + metadata: Deserialize::default(), + plan: Deserialize::default(), + price: Deserialize::default(), + quantity: Deserialize::default(), + subscription: Deserialize::default(), + tax_rates: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_thresholds = self.billing_thresholds.take()?; + let created = self.created.take()?; + let id = self.id.take()?; + let metadata = self.metadata.take()?; + let plan = self.plan.take()?; + let price = self.price.take()?; + let quantity = self.quantity.take()?; + let subscription = self.subscription.take()?; + let tax_rates = self.tax_rates.take()?; + + Some(Self::Out { billing_thresholds, created, id, metadata, plan, price, quantity, subscription, tax_rates }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionItem { + type Builder = SubscriptionItemBuilder; + } + + impl FromValueOpt for SubscriptionItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_thresholds" => b.billing_thresholds = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "plan" => b.plan = Some(FromValueOpt::from_value(v)?), + "price" => b.price = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + "tax_rates" => b.tax_rates = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for SubscriptionItem { type Id = stripe_shared::SubscriptionItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/subscription_item_billing_thresholds.rs b/generated/stripe_shared/src/subscription_item_billing_thresholds.rs index 31d4f7f63..8ba92ea51 100644 --- a/generated/stripe_shared/src/subscription_item_billing_thresholds.rs +++ b/generated/stripe_shared/src/subscription_item_billing_thresholds.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionItemBillingThresholds { /// Usage threshold that triggers the subscription to create an invoice pub usage_gte: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionItemBillingThresholdsBuilder { + usage_gte: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionItemBillingThresholds { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionItemBillingThresholds>, + builder: SubscriptionItemBillingThresholdsBuilder, + } + + impl Visitor for Place<SubscriptionItemBillingThresholds> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionItemBillingThresholdsBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionItemBillingThresholdsBuilder { + type Out = SubscriptionItemBillingThresholds; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "usage_gte" => Deserialize::begin(&mut self.usage_gte), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { usage_gte: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let usage_gte = self.usage_gte.take()?; + + Some(Self::Out { usage_gte }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionItemBillingThresholds { + type Builder = SubscriptionItemBillingThresholdsBuilder; + } + + impl FromValueOpt for SubscriptionItemBillingThresholds { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionItemBillingThresholdsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "usage_gte" => b.usage_gte = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_payment_method_options_card.rs b/generated/stripe_shared/src/subscription_payment_method_options_card.rs index eea74be21..5ff80c5b1 100644 --- a/generated/stripe_shared/src/subscription_payment_method_options_card.rs +++ b/generated/stripe_shared/src/subscription_payment_method_options_card.rs @@ -1,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionPaymentMethodOptionsCard { - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option<stripe_shared::InvoiceMandateOptionsCard>, /// Selected network to process this Subscription on. /// Depends on the available networks of the card attached to the Subscription. @@ -11,6 +12,100 @@ pub struct SubscriptionPaymentMethodOptionsCard { /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. pub request_three_d_secure: Option<SubscriptionPaymentMethodOptionsCardRequestThreeDSecure>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionPaymentMethodOptionsCardBuilder { + mandate_options: Option<Option<stripe_shared::InvoiceMandateOptionsCard>>, + network: Option<Option<SubscriptionPaymentMethodOptionsCardNetwork>>, + request_three_d_secure: Option<Option<SubscriptionPaymentMethodOptionsCardRequestThreeDSecure>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionPaymentMethodOptionsCard { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionPaymentMethodOptionsCard>, + builder: SubscriptionPaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place<SubscriptionPaymentMethodOptionsCard> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionPaymentMethodOptionsCardBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionPaymentMethodOptionsCardBuilder { + type Out = SubscriptionPaymentMethodOptionsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "network" => Deserialize::begin(&mut self.network), + "request_three_d_secure" => Deserialize::begin(&mut self.request_three_d_secure), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { mandate_options: Deserialize::default(), network: Deserialize::default(), request_three_d_secure: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let mandate_options = self.mandate_options.take()?; + let network = self.network.take()?; + let request_three_d_secure = self.request_three_d_secure.take()?; + + Some(Self::Out { mandate_options, network, request_three_d_secure }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionPaymentMethodOptionsCard { + type Builder = SubscriptionPaymentMethodOptionsCardBuilder; + } + + impl FromValueOpt for SubscriptionPaymentMethodOptionsCard { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionPaymentMethodOptionsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "mandate_options" => b.mandate_options = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "request_three_d_secure" => b.request_three_d_secure = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Selected network to process this Subscription on. /// Depends on the available networks of the card attached to the Subscription. /// Can be only set confirm-time. @@ -90,13 +185,27 @@ impl<'de> serde::Deserialize<'de> for SubscriptionPaymentMethodOptionsCardNetwor fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionPaymentMethodOptionsCardNetwork", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionPaymentMethodOptionsCardNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionPaymentMethodOptionsCardNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionPaymentMethodOptionsCardNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionPaymentMethodOptionsCardNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionPaymentMethodOptionsCardNetwork); /// We strongly recommend that you rely on our SCA Engine to automatically prompt your customers for authentication based on risk level and [other requirements](https://stripe.com/docs/strong-customer-authentication). /// However, if you wish to request 3D Secure based on logic from your own fraud engine, provide this option. /// Read our guide on [manually requesting 3D Secure](https://stripe.com/docs/payments/3d-secure#manual-three-ds) for more information on how this configuration interacts with Radar and our SCA Engine. @@ -104,7 +213,6 @@ impl<'de> serde::Deserialize<'de> for SubscriptionPaymentMethodOptionsCardNetwor pub enum SubscriptionPaymentMethodOptionsCardRequestThreeDSecure { Any, Automatic, - Challenge, } impl SubscriptionPaymentMethodOptionsCardRequestThreeDSecure { pub fn as_str(self) -> &'static str { @@ -112,7 +220,6 @@ impl SubscriptionPaymentMethodOptionsCardRequestThreeDSecure { match self { Any => "any", Automatic => "automatic", - Challenge => "challenge", } } } @@ -124,7 +231,6 @@ impl std::str::FromStr for SubscriptionPaymentMethodOptionsCardRequestThreeDSecu match s { "any" => Ok(Any), "automatic" => Ok(Automatic), - "challenge" => Ok(Challenge), _ => Err(()), } } @@ -152,10 +258,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionPaymentMethodOptionsCardReques fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionPaymentMethodOptionsCardRequestThreeDSecure> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionPaymentMethodOptionsCardRequestThreeDSecure::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionPaymentMethodOptionsCardRequestThreeDSecure); diff --git a/generated/stripe_shared/src/subscription_pending_invoice_item_interval.rs b/generated/stripe_shared/src/subscription_pending_invoice_item_interval.rs index e5e9ebb90..8ba9761f6 100644 --- a/generated/stripe_shared/src/subscription_pending_invoice_item_interval.rs +++ b/generated/stripe_shared/src/subscription_pending_invoice_item_interval.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionPendingInvoiceItemInterval { /// Specifies invoicing frequency. Either `day`, `week`, `month` or `year`. pub interval: SubscriptionPendingInvoiceItemIntervalInterval, @@ -7,6 +9,96 @@ pub struct SubscriptionPendingInvoiceItemInterval { /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). pub interval_count: u64, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionPendingInvoiceItemIntervalBuilder { + interval: Option<SubscriptionPendingInvoiceItemIntervalInterval>, + interval_count: Option<u64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionPendingInvoiceItemInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionPendingInvoiceItemInterval>, + builder: SubscriptionPendingInvoiceItemIntervalBuilder, + } + + impl Visitor for Place<SubscriptionPendingInvoiceItemInterval> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionPendingInvoiceItemIntervalBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionPendingInvoiceItemIntervalBuilder { + type Out = SubscriptionPendingInvoiceItemInterval; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "interval" => Deserialize::begin(&mut self.interval), + "interval_count" => Deserialize::begin(&mut self.interval_count), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { interval: Deserialize::default(), interval_count: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let interval = self.interval.take()?; + let interval_count = self.interval_count.take()?; + + Some(Self::Out { interval, interval_count }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionPendingInvoiceItemInterval { + type Builder = SubscriptionPendingInvoiceItemIntervalBuilder; + } + + impl FromValueOpt for SubscriptionPendingInvoiceItemInterval { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionPendingInvoiceItemIntervalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "interval_count" => b.interval_count = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Specifies invoicing frequency. Either `day`, `week`, `month` or `year`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SubscriptionPendingInvoiceItemIntervalInterval { @@ -63,10 +155,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionPendingInvoiceItemIntervalInte fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionPendingInvoiceItemIntervalInterval", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionPendingInvoiceItemIntervalInterval")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionPendingInvoiceItemIntervalInterval { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionPendingInvoiceItemIntervalInterval> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionPendingInvoiceItemIntervalInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionPendingInvoiceItemIntervalInterval); diff --git a/generated/stripe_shared/src/subscription_schedule.rs b/generated/stripe_shared/src/subscription_schedule.rs index 7672ad33d..6f8f425d0 100644 --- a/generated/stripe_shared/src/subscription_schedule.rs +++ b/generated/stripe_shared/src/subscription_schedule.rs @@ -3,7 +3,9 @@ /// Related guide: [Subscription schedules](https://stripe.com/docs/billing/subscriptions/subscription-schedules). /// /// For more details see <<https://stripe.com/docs/api/subscription_schedules/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionSchedule { /// ID of the Connect Application that created the schedule. pub application: Option<stripe_types::Expandable<stripe_shared::Application>>, @@ -20,8 +22,7 @@ pub struct SubscriptionSchedule { pub default_settings: stripe_shared::SubscriptionSchedulesResourceDefaultSettings, /// Behavior of the subscription schedule and underlying subscription when it ends. /// Possible values are `release` or `cancel` with the default being `release`. - /// `release` will end the subscription schedule and keep the underlying subscription running. - /// `cancel` will end the subscription schedule and cancel the underlying subscription. + /// `release` will end the subscription schedule and keep the underlying subscription running.`cancel` will end the subscription schedule and cancel the underlying subscription. pub end_behavior: stripe_shared::SubscriptionScheduleEndBehavior, /// Unique identifier for the object. pub id: stripe_shared::SubscriptionScheduleId, @@ -45,6 +46,192 @@ pub struct SubscriptionSchedule { /// ID of the test clock this subscription schedule belongs to. pub test_clock: Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionScheduleBuilder { + application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>, + canceled_at: Option<Option<stripe_types::Timestamp>>, + completed_at: Option<Option<stripe_types::Timestamp>>, + created: Option<stripe_types::Timestamp>, + current_phase: Option<Option<stripe_shared::SubscriptionScheduleCurrentPhase>>, + customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, + default_settings: Option<stripe_shared::SubscriptionSchedulesResourceDefaultSettings>, + end_behavior: Option<stripe_shared::SubscriptionScheduleEndBehavior>, + id: Option<stripe_shared::SubscriptionScheduleId>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + phases: Option<Vec<stripe_shared::SubscriptionSchedulePhaseConfiguration>>, + released_at: Option<Option<stripe_types::Timestamp>>, + released_subscription: Option<Option<String>>, + status: Option<SubscriptionScheduleStatus>, + subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>, + test_clock: Option<Option<stripe_types::Expandable<stripe_shared::TestHelpersTestClock>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionSchedule { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionSchedule>, + builder: SubscriptionScheduleBuilder, + } + + impl Visitor for Place<SubscriptionSchedule> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionScheduleBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionScheduleBuilder { + type Out = SubscriptionSchedule; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "application" => Deserialize::begin(&mut self.application), + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "completed_at" => Deserialize::begin(&mut self.completed_at), + "created" => Deserialize::begin(&mut self.created), + "current_phase" => Deserialize::begin(&mut self.current_phase), + "customer" => Deserialize::begin(&mut self.customer), + "default_settings" => Deserialize::begin(&mut self.default_settings), + "end_behavior" => Deserialize::begin(&mut self.end_behavior), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "phases" => Deserialize::begin(&mut self.phases), + "released_at" => Deserialize::begin(&mut self.released_at), + "released_subscription" => Deserialize::begin(&mut self.released_subscription), + "status" => Deserialize::begin(&mut self.status), + "subscription" => Deserialize::begin(&mut self.subscription), + "test_clock" => Deserialize::begin(&mut self.test_clock), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + application: Deserialize::default(), + canceled_at: Deserialize::default(), + completed_at: Deserialize::default(), + created: Deserialize::default(), + current_phase: Deserialize::default(), + customer: Deserialize::default(), + default_settings: Deserialize::default(), + end_behavior: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + phases: Deserialize::default(), + released_at: Deserialize::default(), + released_subscription: Deserialize::default(), + status: Deserialize::default(), + subscription: Deserialize::default(), + test_clock: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let application = self.application.take()?; + let canceled_at = self.canceled_at.take()?; + let completed_at = self.completed_at.take()?; + let created = self.created.take()?; + let current_phase = self.current_phase.take()?; + let customer = self.customer.take()?; + let default_settings = self.default_settings.take()?; + let end_behavior = self.end_behavior.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let phases = self.phases.take()?; + let released_at = self.released_at.take()?; + let released_subscription = self.released_subscription.take()?; + let status = self.status.take()?; + let subscription = self.subscription.take()?; + let test_clock = self.test_clock.take()?; + + Some(Self::Out { + application, + canceled_at, + completed_at, + created, + current_phase, + customer, + default_settings, + end_behavior, + id, + livemode, + metadata, + phases, + released_at, + released_subscription, + status, + subscription, + test_clock, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionSchedule { + type Builder = SubscriptionScheduleBuilder; + } + + impl FromValueOpt for SubscriptionSchedule { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionScheduleBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "application" => b.application = Some(FromValueOpt::from_value(v)?), + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "completed_at" => b.completed_at = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "current_phase" => b.current_phase = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "default_settings" => b.default_settings = Some(FromValueOpt::from_value(v)?), + "end_behavior" => b.end_behavior = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "phases" => b.phases = Some(FromValueOpt::from_value(v)?), + "released_at" => b.released_at = Some(FromValueOpt::from_value(v)?), + "released_subscription" => b.released_subscription = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "subscription" => b.subscription = Some(FromValueOpt::from_value(v)?), + "test_clock" => b.test_clock = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The present status of the subscription schedule. /// Possible values are `not_started`, `active`, `completed`, `released`, and `canceled`. /// You can read more about the different states in our [behavior guide](https://stripe.com/docs/billing/subscriptions/subscription-schedules). @@ -106,10 +293,27 @@ impl<'de> serde::Deserialize<'de> for SubscriptionScheduleStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionScheduleStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionScheduleStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionScheduleStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionScheduleStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionScheduleStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionScheduleStatus); impl stripe_types::Object for SubscriptionSchedule { type Id = stripe_shared::SubscriptionScheduleId; fn id(&self) -> &Self::Id { @@ -172,8 +376,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionScheduleEndBehavior { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for SubscriptionScheduleEndBehavior") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionScheduleEndBehavior")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionScheduleEndBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionScheduleEndBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionScheduleEndBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionScheduleEndBehavior); diff --git a/generated/stripe_shared/src/subscription_schedule_add_invoice_item.rs b/generated/stripe_shared/src/subscription_schedule_add_invoice_item.rs index 3d164892c..f91c811bd 100644 --- a/generated/stripe_shared/src/subscription_schedule_add_invoice_item.rs +++ b/generated/stripe_shared/src/subscription_schedule_add_invoice_item.rs @@ -1,11 +1,106 @@ /// An Add Invoice Item describes the prices and quantities that will be added as pending invoice items when entering a phase. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionScheduleAddInvoiceItem { /// ID of the price used to generate the invoice item. pub price: stripe_types::Expandable<stripe_shared::Price>, /// The quantity of the invoice item. pub quantity: Option<u64>, /// The tax rates which apply to the item. When set, the `default_tax_rates` do not apply to this item. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option<Vec<stripe_shared::TaxRate>>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionScheduleAddInvoiceItemBuilder { + price: Option<stripe_types::Expandable<stripe_shared::Price>>, + quantity: Option<Option<u64>>, + tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionScheduleAddInvoiceItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionScheduleAddInvoiceItem>, + builder: SubscriptionScheduleAddInvoiceItemBuilder, + } + + impl Visitor for Place<SubscriptionScheduleAddInvoiceItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionScheduleAddInvoiceItemBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionScheduleAddInvoiceItemBuilder { + type Out = SubscriptionScheduleAddInvoiceItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "price" => Deserialize::begin(&mut self.price), + "quantity" => Deserialize::begin(&mut self.quantity), + "tax_rates" => Deserialize::begin(&mut self.tax_rates), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { price: Deserialize::default(), quantity: Deserialize::default(), tax_rates: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let price = self.price.take()?; + let quantity = self.quantity.take()?; + let tax_rates = self.tax_rates.take()?; + + Some(Self::Out { price, quantity, tax_rates }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionScheduleAddInvoiceItem { + type Builder = SubscriptionScheduleAddInvoiceItemBuilder; + } + + impl FromValueOpt for SubscriptionScheduleAddInvoiceItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionScheduleAddInvoiceItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "price" => b.price = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "tax_rates" => b.tax_rates = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_schedule_configuration_item.rs b/generated/stripe_shared/src/subscription_schedule_configuration_item.rs index 11148bfdb..d6b818f3e 100644 --- a/generated/stripe_shared/src/subscription_schedule_configuration_item.rs +++ b/generated/stripe_shared/src/subscription_schedule_configuration_item.rs @@ -1,5 +1,7 @@ /// A phase item describes the price and quantity of a phase. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionScheduleConfigurationItem { /// Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period. pub billing_thresholds: Option<stripe_shared::SubscriptionItemBillingThresholds>, @@ -11,10 +13,121 @@ pub struct SubscriptionScheduleConfigurationItem { /// ID of the price to which the customer should be subscribed. pub price: stripe_types::Expandable<stripe_shared::Price>, /// Quantity of the plan to which the customer should be subscribed. - #[serde(skip_serializing_if = "Option::is_none")] pub quantity: Option<u64>, /// The tax rates which apply to this `phase_item`. /// When set, the `default_tax_rates` on the phase do not apply to this `phase_item`. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option<Vec<stripe_shared::TaxRate>>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionScheduleConfigurationItemBuilder { + billing_thresholds: Option<Option<stripe_shared::SubscriptionItemBillingThresholds>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + plan: Option<stripe_types::Expandable<stripe_shared::Plan>>, + price: Option<stripe_types::Expandable<stripe_shared::Price>>, + quantity: Option<Option<u64>>, + tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionScheduleConfigurationItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionScheduleConfigurationItem>, + builder: SubscriptionScheduleConfigurationItemBuilder, + } + + impl Visitor for Place<SubscriptionScheduleConfigurationItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionScheduleConfigurationItemBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionScheduleConfigurationItemBuilder { + type Out = SubscriptionScheduleConfigurationItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_thresholds" => Deserialize::begin(&mut self.billing_thresholds), + "metadata" => Deserialize::begin(&mut self.metadata), + "plan" => Deserialize::begin(&mut self.plan), + "price" => Deserialize::begin(&mut self.price), + "quantity" => Deserialize::begin(&mut self.quantity), + "tax_rates" => Deserialize::begin(&mut self.tax_rates), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing_thresholds: Deserialize::default(), + metadata: Deserialize::default(), + plan: Deserialize::default(), + price: Deserialize::default(), + quantity: Deserialize::default(), + tax_rates: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_thresholds = self.billing_thresholds.take()?; + let metadata = self.metadata.take()?; + let plan = self.plan.take()?; + let price = self.price.take()?; + let quantity = self.quantity.take()?; + let tax_rates = self.tax_rates.take()?; + + Some(Self::Out { billing_thresholds, metadata, plan, price, quantity, tax_rates }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionScheduleConfigurationItem { + type Builder = SubscriptionScheduleConfigurationItemBuilder; + } + + impl FromValueOpt for SubscriptionScheduleConfigurationItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionScheduleConfigurationItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_thresholds" => b.billing_thresholds = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "plan" => b.plan = Some(FromValueOpt::from_value(v)?), + "price" => b.price = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + "tax_rates" => b.tax_rates = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_schedule_current_phase.rs b/generated/stripe_shared/src/subscription_schedule_current_phase.rs index 28d2195a8..f8796f29e 100644 --- a/generated/stripe_shared/src/subscription_schedule_current_phase.rs +++ b/generated/stripe_shared/src/subscription_schedule_current_phase.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionScheduleCurrentPhase { /// The end of this phase of the subscription schedule. pub end_date: stripe_types::Timestamp, /// The start of this phase of the subscription schedule. pub start_date: stripe_types::Timestamp, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionScheduleCurrentPhaseBuilder { + end_date: Option<stripe_types::Timestamp>, + start_date: Option<stripe_types::Timestamp>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionScheduleCurrentPhase { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionScheduleCurrentPhase>, + builder: SubscriptionScheduleCurrentPhaseBuilder, + } + + impl Visitor for Place<SubscriptionScheduleCurrentPhase> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionScheduleCurrentPhaseBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionScheduleCurrentPhaseBuilder { + type Out = SubscriptionScheduleCurrentPhase; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "end_date" => Deserialize::begin(&mut self.end_date), + "start_date" => Deserialize::begin(&mut self.start_date), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end_date: Deserialize::default(), start_date: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let end_date = self.end_date.take()?; + let start_date = self.start_date.take()?; + + Some(Self::Out { end_date, start_date }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionScheduleCurrentPhase { + type Builder = SubscriptionScheduleCurrentPhaseBuilder; + } + + impl FromValueOpt for SubscriptionScheduleCurrentPhase { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionScheduleCurrentPhaseBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "end_date" => b.end_date = Some(FromValueOpt::from_value(v)?), + "start_date" => b.start_date = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_schedule_phase_configuration.rs b/generated/stripe_shared/src/subscription_schedule_phase_configuration.rs index 43c9fde1b..91a349fb3 100644 --- a/generated/stripe_shared/src/subscription_schedule_phase_configuration.rs +++ b/generated/stripe_shared/src/subscription_schedule_phase_configuration.rs @@ -1,12 +1,13 @@ /// A phase describes the plans, coupon, and trialing status of a subscription for a predefined time period. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionSchedulePhaseConfiguration { /// A list of prices and quantities that will generate invoice items appended to the next invoice for this phase. pub add_invoice_items: Vec<stripe_shared::SubscriptionScheduleAddInvoiceItem>, /// A non-negative decimal between 0 and 100, with at most two decimal places. /// This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account during this phase of the schedule. pub application_fee_percent: Option<f64>, - #[serde(skip_serializing_if = "Option::is_none")] pub automatic_tax: Option<stripe_shared::SchedulesPhaseAutomaticTax>, /// Possible values are `phase_start` or `automatic`. /// If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase. @@ -29,7 +30,6 @@ pub struct SubscriptionSchedulePhaseConfiguration { /// If not set, invoices will use the default payment method in the customer's invoice settings. pub default_payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>, /// The default tax rates to apply to the subscription during this phase of the subscription schedule. - #[serde(skip_serializing_if = "Option::is_none")] pub default_tax_rates: Option<Vec<stripe_shared::TaxRate>>, /// Subscription description, meant to be displayable to the customer. /// Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs. @@ -57,6 +57,210 @@ pub struct SubscriptionSchedulePhaseConfiguration { /// When the trial ends within the phase. pub trial_end: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionSchedulePhaseConfigurationBuilder { + add_invoice_items: Option<Vec<stripe_shared::SubscriptionScheduleAddInvoiceItem>>, + application_fee_percent: Option<Option<f64>>, + automatic_tax: Option<Option<stripe_shared::SchedulesPhaseAutomaticTax>>, + billing_cycle_anchor: Option<Option<SubscriptionSchedulePhaseConfigurationBillingCycleAnchor>>, + billing_thresholds: Option<Option<stripe_shared::SubscriptionBillingThresholds>>, + collection_method: Option<Option<SubscriptionSchedulePhaseConfigurationCollectionMethod>>, + coupon: Option<Option<stripe_types::Expandable<stripe_shared::Coupon>>>, + currency: Option<stripe_types::Currency>, + default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + default_tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>, + description: Option<Option<String>>, + end_date: Option<stripe_types::Timestamp>, + invoice_settings: Option<Option<stripe_shared::InvoiceSettingSubscriptionSchedulePhaseSetting>>, + items: Option<Vec<stripe_shared::SubscriptionScheduleConfigurationItem>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + proration_behavior: Option<SubscriptionSchedulePhaseConfigurationProrationBehavior>, + start_date: Option<stripe_types::Timestamp>, + transfer_data: Option<Option<stripe_shared::SubscriptionTransferData>>, + trial_end: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionSchedulePhaseConfiguration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionSchedulePhaseConfiguration>, + builder: SubscriptionSchedulePhaseConfigurationBuilder, + } + + impl Visitor for Place<SubscriptionSchedulePhaseConfiguration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionSchedulePhaseConfigurationBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionSchedulePhaseConfigurationBuilder { + type Out = SubscriptionSchedulePhaseConfiguration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "add_invoice_items" => Deserialize::begin(&mut self.add_invoice_items), + "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent), + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "billing_cycle_anchor" => Deserialize::begin(&mut self.billing_cycle_anchor), + "billing_thresholds" => Deserialize::begin(&mut self.billing_thresholds), + "collection_method" => Deserialize::begin(&mut self.collection_method), + "coupon" => Deserialize::begin(&mut self.coupon), + "currency" => Deserialize::begin(&mut self.currency), + "default_payment_method" => Deserialize::begin(&mut self.default_payment_method), + "default_tax_rates" => Deserialize::begin(&mut self.default_tax_rates), + "description" => Deserialize::begin(&mut self.description), + "end_date" => Deserialize::begin(&mut self.end_date), + "invoice_settings" => Deserialize::begin(&mut self.invoice_settings), + "items" => Deserialize::begin(&mut self.items), + "metadata" => Deserialize::begin(&mut self.metadata), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "proration_behavior" => Deserialize::begin(&mut self.proration_behavior), + "start_date" => Deserialize::begin(&mut self.start_date), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + "trial_end" => Deserialize::begin(&mut self.trial_end), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + add_invoice_items: Deserialize::default(), + application_fee_percent: Deserialize::default(), + automatic_tax: Deserialize::default(), + billing_cycle_anchor: Deserialize::default(), + billing_thresholds: Deserialize::default(), + collection_method: Deserialize::default(), + coupon: Deserialize::default(), + currency: Deserialize::default(), + default_payment_method: Deserialize::default(), + default_tax_rates: Deserialize::default(), + description: Deserialize::default(), + end_date: Deserialize::default(), + invoice_settings: Deserialize::default(), + items: Deserialize::default(), + metadata: Deserialize::default(), + on_behalf_of: Deserialize::default(), + proration_behavior: Deserialize::default(), + start_date: Deserialize::default(), + transfer_data: Deserialize::default(), + trial_end: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let add_invoice_items = self.add_invoice_items.take()?; + let application_fee_percent = self.application_fee_percent.take()?; + let automatic_tax = self.automatic_tax.take()?; + let billing_cycle_anchor = self.billing_cycle_anchor.take()?; + let billing_thresholds = self.billing_thresholds.take()?; + let collection_method = self.collection_method.take()?; + let coupon = self.coupon.take()?; + let currency = self.currency.take()?; + let default_payment_method = self.default_payment_method.take()?; + let default_tax_rates = self.default_tax_rates.take()?; + let description = self.description.take()?; + let end_date = self.end_date.take()?; + let invoice_settings = self.invoice_settings.take()?; + let items = self.items.take()?; + let metadata = self.metadata.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let proration_behavior = self.proration_behavior.take()?; + let start_date = self.start_date.take()?; + let transfer_data = self.transfer_data.take()?; + let trial_end = self.trial_end.take()?; + + Some(Self::Out { + add_invoice_items, + application_fee_percent, + automatic_tax, + billing_cycle_anchor, + billing_thresholds, + collection_method, + coupon, + currency, + default_payment_method, + default_tax_rates, + description, + end_date, + invoice_settings, + items, + metadata, + on_behalf_of, + proration_behavior, + start_date, + transfer_data, + trial_end, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionSchedulePhaseConfiguration { + type Builder = SubscriptionSchedulePhaseConfigurationBuilder; + } + + impl FromValueOpt for SubscriptionSchedulePhaseConfiguration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionSchedulePhaseConfigurationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "add_invoice_items" => b.add_invoice_items = Some(FromValueOpt::from_value(v)?), + "application_fee_percent" => b.application_fee_percent = Some(FromValueOpt::from_value(v)?), + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "billing_cycle_anchor" => b.billing_cycle_anchor = Some(FromValueOpt::from_value(v)?), + "billing_thresholds" => b.billing_thresholds = Some(FromValueOpt::from_value(v)?), + "collection_method" => b.collection_method = Some(FromValueOpt::from_value(v)?), + "coupon" => b.coupon = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "default_payment_method" => b.default_payment_method = Some(FromValueOpt::from_value(v)?), + "default_tax_rates" => b.default_tax_rates = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "end_date" => b.end_date = Some(FromValueOpt::from_value(v)?), + "invoice_settings" => b.invoice_settings = Some(FromValueOpt::from_value(v)?), + "items" => b.items = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "proration_behavior" => b.proration_behavior = Some(FromValueOpt::from_value(v)?), + "start_date" => b.start_date = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + "trial_end" => b.trial_end = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Possible values are `phase_start` or `automatic`. /// If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase. /// If `automatic` then the billing cycle anchor is automatically modified as needed when entering the phase. @@ -110,13 +314,27 @@ impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationBill fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionSchedulePhaseConfigurationBillingCycleAnchor> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionSchedulePhaseConfigurationBillingCycleAnchor::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulePhaseConfigurationBillingCycleAnchor); /// Either `charge_automatically`, or `send_invoice`. /// When charging automatically, Stripe will attempt to pay the underlying subscription at the end of each billing cycle using the default source attached to the customer. /// When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. @@ -169,13 +387,27 @@ impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationColl fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionSchedulePhaseConfigurationCollectionMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionSchedulePhaseConfigurationCollectionMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationCollectionMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionSchedulePhaseConfigurationCollectionMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionSchedulePhaseConfigurationCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulePhaseConfigurationCollectionMethod); /// If the subscription schedule will prorate when transitioning to this phase. /// Possible values are `create_prorations` and `none`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -230,10 +462,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationPror fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionSchedulePhaseConfigurationProrationBehavior", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionSchedulePhaseConfigurationProrationBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationProrationBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionSchedulePhaseConfigurationProrationBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionSchedulePhaseConfigurationProrationBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulePhaseConfigurationProrationBehavior); diff --git a/generated/stripe_shared/src/subscription_schedules_resource_default_settings.rs b/generated/stripe_shared/src/subscription_schedules_resource_default_settings.rs index c83761673..e03431e37 100644 --- a/generated/stripe_shared/src/subscription_schedules_resource_default_settings.rs +++ b/generated/stripe_shared/src/subscription_schedules_resource_default_settings.rs @@ -1,11 +1,11 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionSchedulesResourceDefaultSettings { /// A non-negative decimal between 0 and 100, with at most two decimal places. /// This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account during this phase of the schedule. pub application_fee_percent: Option<f64>, - #[serde(skip_serializing_if = "Option::is_none")] - pub automatic_tax: - Option<stripe_shared::SubscriptionSchedulesResourceDefaultSettingsAutomaticTax>, + pub automatic_tax: Option<stripe_shared::SubscriptionSchedulesResourceDefaultSettingsAutomaticTax>, /// Possible values are `phase_start` or `automatic`. /// If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase. /// If `automatic` then the billing cycle anchor is automatically modified as needed when entering the phase. @@ -23,13 +23,158 @@ pub struct SubscriptionSchedulesResourceDefaultSettings { /// Subscription description, meant to be displayable to the customer. /// Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs. pub description: Option<String>, - pub invoice_settings: stripe_shared::InvoiceSettingSubscriptionScheduleSetting, + /// The subscription schedule's default invoice settings. + pub invoice_settings: Option<stripe_shared::InvoiceSettingSubscriptionScheduleSetting>, /// The account (if any) the charge was made on behalf of for charges associated with the schedule's subscription. /// See the Connect documentation for details. pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>, /// The account (if any) the associated subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices. pub transfer_data: Option<stripe_shared::SubscriptionTransferData>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionSchedulesResourceDefaultSettingsBuilder { + application_fee_percent: Option<Option<f64>>, + automatic_tax: Option<Option<stripe_shared::SubscriptionSchedulesResourceDefaultSettingsAutomaticTax>>, + billing_cycle_anchor: Option<SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor>, + billing_thresholds: Option<Option<stripe_shared::SubscriptionBillingThresholds>>, + collection_method: Option<Option<SubscriptionSchedulesResourceDefaultSettingsCollectionMethod>>, + default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>, + description: Option<Option<String>>, + invoice_settings: Option<Option<stripe_shared::InvoiceSettingSubscriptionScheduleSetting>>, + on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + transfer_data: Option<Option<stripe_shared::SubscriptionTransferData>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionSchedulesResourceDefaultSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionSchedulesResourceDefaultSettings>, + builder: SubscriptionSchedulesResourceDefaultSettingsBuilder, + } + + impl Visitor for Place<SubscriptionSchedulesResourceDefaultSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionSchedulesResourceDefaultSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionSchedulesResourceDefaultSettingsBuilder { + type Out = SubscriptionSchedulesResourceDefaultSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent), + "automatic_tax" => Deserialize::begin(&mut self.automatic_tax), + "billing_cycle_anchor" => Deserialize::begin(&mut self.billing_cycle_anchor), + "billing_thresholds" => Deserialize::begin(&mut self.billing_thresholds), + "collection_method" => Deserialize::begin(&mut self.collection_method), + "default_payment_method" => Deserialize::begin(&mut self.default_payment_method), + "description" => Deserialize::begin(&mut self.description), + "invoice_settings" => Deserialize::begin(&mut self.invoice_settings), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "transfer_data" => Deserialize::begin(&mut self.transfer_data), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + application_fee_percent: Deserialize::default(), + automatic_tax: Deserialize::default(), + billing_cycle_anchor: Deserialize::default(), + billing_thresholds: Deserialize::default(), + collection_method: Deserialize::default(), + default_payment_method: Deserialize::default(), + description: Deserialize::default(), + invoice_settings: Deserialize::default(), + on_behalf_of: Deserialize::default(), + transfer_data: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let application_fee_percent = self.application_fee_percent.take()?; + let automatic_tax = self.automatic_tax.take()?; + let billing_cycle_anchor = self.billing_cycle_anchor.take()?; + let billing_thresholds = self.billing_thresholds.take()?; + let collection_method = self.collection_method.take()?; + let default_payment_method = self.default_payment_method.take()?; + let description = self.description.take()?; + let invoice_settings = self.invoice_settings.take()?; + let on_behalf_of = self.on_behalf_of.take()?; + let transfer_data = self.transfer_data.take()?; + + Some(Self::Out { + application_fee_percent, + automatic_tax, + billing_cycle_anchor, + billing_thresholds, + collection_method, + default_payment_method, + description, + invoice_settings, + on_behalf_of, + transfer_data, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionSchedulesResourceDefaultSettings { + type Builder = SubscriptionSchedulesResourceDefaultSettingsBuilder; + } + + impl FromValueOpt for SubscriptionSchedulesResourceDefaultSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionSchedulesResourceDefaultSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "application_fee_percent" => b.application_fee_percent = Some(FromValueOpt::from_value(v)?), + "automatic_tax" => b.automatic_tax = Some(FromValueOpt::from_value(v)?), + "billing_cycle_anchor" => b.billing_cycle_anchor = Some(FromValueOpt::from_value(v)?), + "billing_thresholds" => b.billing_thresholds = Some(FromValueOpt::from_value(v)?), + "collection_method" => b.collection_method = Some(FromValueOpt::from_value(v)?), + "default_payment_method" => b.default_payment_method = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "invoice_settings" => b.invoice_settings = Some(FromValueOpt::from_value(v)?), + "on_behalf_of" => b.on_behalf_of = Some(FromValueOpt::from_value(v)?), + "transfer_data" => b.transfer_data = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Possible values are `phase_start` or `automatic`. /// If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase. /// If `automatic` then the billing cycle anchor is automatically modified as needed when entering the phase. @@ -79,19 +224,31 @@ impl serde::Serialize for SubscriptionSchedulesResourceDefaultSettingsBillingCyc serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor -{ +impl<'de> serde::Deserialize<'de> for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor); /// Either `charge_automatically`, or `send_invoice`. /// When charging automatically, Stripe will attempt to pay the underlying subscription at the end of each billing cycle using the default source attached to the customer. /// When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. @@ -144,10 +301,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionSchedulesResourceDefaultSettin fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionSchedulesResourceDefaultSettingsCollectionMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionSchedulesResourceDefaultSettingsCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulesResourceDefaultSettingsCollectionMethod); diff --git a/generated/stripe_shared/src/subscription_schedules_resource_default_settings_automatic_tax.rs b/generated/stripe_shared/src/subscription_schedules_resource_default_settings_automatic_tax.rs index 78b1fd762..d5646079a 100644 --- a/generated/stripe_shared/src/subscription_schedules_resource_default_settings_automatic_tax.rs +++ b/generated/stripe_shared/src/subscription_schedules_resource_default_settings_automatic_tax.rs @@ -1,9 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionSchedulesResourceDefaultSettingsAutomaticTax { /// Whether Stripe automatically computes tax on invoices created during this phase. pub enabled: bool, - /// The account that's liable for tax. - /// If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. - /// The tax transaction is returned in the report of the connected account. - pub liability: Option<stripe_shared::ConnectAccountReference>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder { + enabled: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionSchedulesResourceDefaultSettingsAutomaticTax { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionSchedulesResourceDefaultSettingsAutomaticTax>, + builder: SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder, + } + + impl Visitor for Place<SubscriptionSchedulesResourceDefaultSettingsAutomaticTax> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder { + type Out = SubscriptionSchedulesResourceDefaultSettingsAutomaticTax; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionSchedulesResourceDefaultSettingsAutomaticTax { + type Builder = SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder; + } + + impl FromValueOpt for SubscriptionSchedulesResourceDefaultSettingsAutomaticTax { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscription_transfer_data.rs b/generated/stripe_shared/src/subscription_transfer_data.rs index 07682dcc7..70f86b0e2 100644 --- a/generated/stripe_shared/src/subscription_transfer_data.rs +++ b/generated/stripe_shared/src/subscription_transfer_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionTransferData { /// A non-negative decimal between 0 and 100, with at most two decimal places. /// This represents the percentage of the subscription invoice total that will be transferred to the destination account. @@ -7,3 +9,93 @@ pub struct SubscriptionTransferData { /// The account where funds from the payment will be transferred to upon payment success. pub destination: stripe_types::Expandable<stripe_shared::Account>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionTransferDataBuilder { + amount_percent: Option<Option<f64>>, + destination: Option<stripe_types::Expandable<stripe_shared::Account>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionTransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionTransferData>, + builder: SubscriptionTransferDataBuilder, + } + + impl Visitor for Place<SubscriptionTransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionTransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionTransferDataBuilder { + type Out = SubscriptionTransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_percent" => Deserialize::begin(&mut self.amount_percent), + "destination" => Deserialize::begin(&mut self.destination), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_percent: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_percent = self.amount_percent.take()?; + let destination = self.destination.take()?; + + Some(Self::Out { amount_percent, destination }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionTransferData { + type Builder = SubscriptionTransferDataBuilder; + } + + impl FromValueOpt for SubscriptionTransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionTransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_percent" => b.amount_percent = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscriptions_resource_billing_cycle_anchor_config.rs b/generated/stripe_shared/src/subscriptions_resource_billing_cycle_anchor_config.rs deleted file mode 100644 index f1b2614f9..000000000 --- a/generated/stripe_shared/src/subscriptions_resource_billing_cycle_anchor_config.rs +++ /dev/null @@ -1,13 +0,0 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct SubscriptionsResourceBillingCycleAnchorConfig { - /// The day of the month of the billing_cycle_anchor. - pub day_of_month: i64, - /// The hour of the day of the billing_cycle_anchor. - pub hour: Option<i64>, - /// The minute of the hour of the billing_cycle_anchor. - pub minute: Option<i64>, - /// The month to start full cycle billing periods. - pub month: Option<i64>, - /// The second of the minute of the billing_cycle_anchor. - pub second: Option<i64>, -} diff --git a/generated/stripe_shared/src/subscriptions_resource_pause_collection.rs b/generated/stripe_shared/src/subscriptions_resource_pause_collection.rs index 0ff0713ff..88e4d4483 100644 --- a/generated/stripe_shared/src/subscriptions_resource_pause_collection.rs +++ b/generated/stripe_shared/src/subscriptions_resource_pause_collection.rs @@ -1,6 +1,8 @@ /// The Pause Collection settings determine how we will pause collection for this subscription and for how long the subscription. /// should be paused. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionsResourcePauseCollection { /// The payment collection behavior for this subscription while paused. /// One of `keep_as_draft`, `mark_uncollectible`, or `void`. @@ -8,6 +10,96 @@ pub struct SubscriptionsResourcePauseCollection { /// The time after which the subscription will resume collecting payments. pub resumes_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionsResourcePauseCollectionBuilder { + behavior: Option<SubscriptionsResourcePauseCollectionBehavior>, + resumes_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionsResourcePauseCollection { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionsResourcePauseCollection>, + builder: SubscriptionsResourcePauseCollectionBuilder, + } + + impl Visitor for Place<SubscriptionsResourcePauseCollection> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionsResourcePauseCollectionBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionsResourcePauseCollectionBuilder { + type Out = SubscriptionsResourcePauseCollection; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "behavior" => Deserialize::begin(&mut self.behavior), + "resumes_at" => Deserialize::begin(&mut self.resumes_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { behavior: Deserialize::default(), resumes_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let behavior = self.behavior.take()?; + let resumes_at = self.resumes_at.take()?; + + Some(Self::Out { behavior, resumes_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionsResourcePauseCollection { + type Builder = SubscriptionsResourcePauseCollectionBuilder; + } + + impl FromValueOpt for SubscriptionsResourcePauseCollection { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionsResourcePauseCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "behavior" => b.behavior = Some(FromValueOpt::from_value(v)?), + "resumes_at" => b.resumes_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The payment collection behavior for this subscription while paused. /// One of `keep_as_draft`, `mark_uncollectible`, or `void`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -62,10 +154,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePauseCollectionBehavi fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionsResourcePauseCollectionBehavior", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionsResourcePauseCollectionBehavior")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionsResourcePauseCollectionBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionsResourcePauseCollectionBehavior> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionsResourcePauseCollectionBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionsResourcePauseCollectionBehavior); diff --git a/generated/stripe_shared/src/subscriptions_resource_payment_method_options.rs b/generated/stripe_shared/src/subscriptions_resource_payment_method_options.rs index 57e8ea013..a23514190 100644 --- a/generated/stripe_shared/src/subscriptions_resource_payment_method_options.rs +++ b/generated/stripe_shared/src/subscriptions_resource_payment_method_options.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionsResourcePaymentMethodOptions { /// This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to invoices created by the subscription. pub acss_debit: Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebit>, @@ -13,3 +15,116 @@ pub struct SubscriptionsResourcePaymentMethodOptions { /// This sub-hash contains details about the ACH direct debit payment method options to pass to invoices created by the subscription. pub us_bank_account: Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionsResourcePaymentMethodOptionsBuilder { + acss_debit: Option<Option<stripe_shared::InvoicePaymentMethodOptionsAcssDebit>>, + bancontact: Option<Option<stripe_shared::InvoicePaymentMethodOptionsBancontact>>, + card: Option<Option<stripe_shared::SubscriptionPaymentMethodOptionsCard>>, + customer_balance: Option<Option<stripe_shared::InvoicePaymentMethodOptionsCustomerBalance>>, + konbini: Option<Option<stripe_shared::InvoicePaymentMethodOptionsKonbini>>, + us_bank_account: Option<Option<stripe_shared::InvoicePaymentMethodOptionsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionsResourcePaymentMethodOptions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionsResourcePaymentMethodOptions>, + builder: SubscriptionsResourcePaymentMethodOptionsBuilder, + } + + impl Visitor for Place<SubscriptionsResourcePaymentMethodOptions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionsResourcePaymentMethodOptionsBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionsResourcePaymentMethodOptionsBuilder { + type Out = SubscriptionsResourcePaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "acss_debit" => Deserialize::begin(&mut self.acss_debit), + "bancontact" => Deserialize::begin(&mut self.bancontact), + "card" => Deserialize::begin(&mut self.card), + "customer_balance" => Deserialize::begin(&mut self.customer_balance), + "konbini" => Deserialize::begin(&mut self.konbini), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + acss_debit: Deserialize::default(), + bancontact: Deserialize::default(), + card: Deserialize::default(), + customer_balance: Deserialize::default(), + konbini: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let acss_debit = self.acss_debit.take()?; + let bancontact = self.bancontact.take()?; + let card = self.card.take()?; + let customer_balance = self.customer_balance.take()?; + let konbini = self.konbini.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { acss_debit, bancontact, card, customer_balance, konbini, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionsResourcePaymentMethodOptions { + type Builder = SubscriptionsResourcePaymentMethodOptionsBuilder; + } + + impl FromValueOpt for SubscriptionsResourcePaymentMethodOptions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionsResourcePaymentMethodOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "acss_debit" => b.acss_debit = Some(FromValueOpt::from_value(v)?), + "bancontact" => b.bancontact = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "customer_balance" => b.customer_balance = Some(FromValueOpt::from_value(v)?), + "konbini" => b.konbini = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscriptions_resource_payment_settings.rs b/generated/stripe_shared/src/subscriptions_resource_payment_settings.rs index 2f53272f5..215ce185d 100644 --- a/generated/stripe_shared/src/subscriptions_resource_payment_settings.rs +++ b/generated/stripe_shared/src/subscriptions_resource_payment_settings.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionsResourcePaymentSettings { /// Payment-method-specific configuration to provide to invoices created by the subscription. pub payment_method_options: Option<stripe_shared::SubscriptionsResourcePaymentMethodOptions>, @@ -7,9 +9,102 @@ pub struct SubscriptionsResourcePaymentSettings { pub payment_method_types: Option<Vec<SubscriptionsResourcePaymentSettingsPaymentMethodTypes>>, /// Either `off`, or `on_subscription`. /// With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds. - pub save_default_payment_method: - Option<SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod>, + pub save_default_payment_method: Option<SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionsResourcePaymentSettingsBuilder { + payment_method_options: Option<Option<stripe_shared::SubscriptionsResourcePaymentMethodOptions>>, + payment_method_types: Option<Option<Vec<SubscriptionsResourcePaymentSettingsPaymentMethodTypes>>>, + save_default_payment_method: Option<Option<SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionsResourcePaymentSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionsResourcePaymentSettings>, + builder: SubscriptionsResourcePaymentSettingsBuilder, + } + + impl Visitor for Place<SubscriptionsResourcePaymentSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionsResourcePaymentSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionsResourcePaymentSettingsBuilder { + type Out = SubscriptionsResourcePaymentSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "payment_method_options" => Deserialize::begin(&mut self.payment_method_options), + "payment_method_types" => Deserialize::begin(&mut self.payment_method_types), + "save_default_payment_method" => Deserialize::begin(&mut self.save_default_payment_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payment_method_options: Deserialize::default(), payment_method_types: Deserialize::default(), save_default_payment_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let payment_method_options = self.payment_method_options.take()?; + let payment_method_types = self.payment_method_types.take()?; + let save_default_payment_method = self.save_default_payment_method.take()?; + + Some(Self::Out { payment_method_options, payment_method_types, save_default_payment_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionsResourcePaymentSettings { + type Builder = SubscriptionsResourcePaymentSettingsBuilder; + } + + impl FromValueOpt for SubscriptionsResourcePaymentSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionsResourcePaymentSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payment_method_options" => b.payment_method_options = Some(FromValueOpt::from_value(v)?), + "payment_method_types" => b.payment_method_types = Some(FromValueOpt::from_value(v)?), + "save_default_payment_method" => b.save_default_payment_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The list of payment method types to provide to every invoice created by the subscription. /// If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your [invoice template settings](https://dashboard.stripe.com/settings/billing/invoice). #[derive(Copy, Clone, Eq, PartialEq)] @@ -25,14 +120,12 @@ pub enum SubscriptionsResourcePaymentSettingsPaymentMethodTypes { Card, Cashapp, CustomerBalance, - Eps, Fpx, Giropay, Grabpay, Ideal, Konbini, Link, - P24, Paynow, Paypal, Promptpay, @@ -58,14 +151,12 @@ impl SubscriptionsResourcePaymentSettingsPaymentMethodTypes { Card => "card", Cashapp => "cashapp", CustomerBalance => "customer_balance", - Eps => "eps", Fpx => "fpx", Giropay => "giropay", Grabpay => "grabpay", Ideal => "ideal", Konbini => "konbini", Link => "link", - P24 => "p24", Paynow => "paynow", Paypal => "paypal", Promptpay => "promptpay", @@ -94,14 +185,12 @@ impl std::str::FromStr for SubscriptionsResourcePaymentSettingsPaymentMethodType "card" => Ok(Card), "cashapp" => Ok(Cashapp), "customer_balance" => Ok(CustomerBalance), - "eps" => Ok(Eps), "fpx" => Ok(Fpx), "giropay" => Ok(Giropay), "grabpay" => Ok(Grabpay), "ideal" => Ok(Ideal), "konbini" => Ok(Konbini), "link" => Ok(Link), - "p24" => Ok(P24), "paynow" => Ok(Paynow), "paypal" => Ok(Paypal), "promptpay" => Ok(Promptpay), @@ -137,10 +226,27 @@ impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePaymentSettingsPaymen fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s) - .unwrap_or(SubscriptionsResourcePaymentSettingsPaymentMethodTypes::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionsResourcePaymentSettingsPaymentMethodTypes { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionsResourcePaymentSettingsPaymentMethodTypes> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionsResourcePaymentSettingsPaymentMethodTypes::from_str(s).unwrap_or(SubscriptionsResourcePaymentSettingsPaymentMethodTypes::Unknown)); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionsResourcePaymentSettingsPaymentMethodTypes); /// Either `off`, or `on_subscription`. /// With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds. #[derive(Copy, Clone, Eq, PartialEq)] @@ -192,10 +298,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePaymentSettingsSaveDe fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod); diff --git a/generated/stripe_shared/src/subscriptions_resource_pending_update.rs b/generated/stripe_shared/src/subscriptions_resource_pending_update.rs index ef129a0dc..ace6a5492 100644 --- a/generated/stripe_shared/src/subscriptions_resource_pending_update.rs +++ b/generated/stripe_shared/src/subscriptions_resource_pending_update.rs @@ -1,6 +1,8 @@ /// Pending Updates store the changes pending from a previous update that will be applied /// to the Subscription upon successful payment. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionsResourcePendingUpdate { /// If the update is applied, determines the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. /// The timestamp is in UTC format. @@ -17,3 +19,111 @@ pub struct SubscriptionsResourcePendingUpdate { /// See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more. pub trial_from_plan: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionsResourcePendingUpdateBuilder { + billing_cycle_anchor: Option<Option<stripe_types::Timestamp>>, + expires_at: Option<stripe_types::Timestamp>, + subscription_items: Option<Option<Vec<stripe_shared::SubscriptionItem>>>, + trial_end: Option<Option<stripe_types::Timestamp>>, + trial_from_plan: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionsResourcePendingUpdate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionsResourcePendingUpdate>, + builder: SubscriptionsResourcePendingUpdateBuilder, + } + + impl Visitor for Place<SubscriptionsResourcePendingUpdate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionsResourcePendingUpdateBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionsResourcePendingUpdateBuilder { + type Out = SubscriptionsResourcePendingUpdate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_cycle_anchor" => Deserialize::begin(&mut self.billing_cycle_anchor), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "subscription_items" => Deserialize::begin(&mut self.subscription_items), + "trial_end" => Deserialize::begin(&mut self.trial_end), + "trial_from_plan" => Deserialize::begin(&mut self.trial_from_plan), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing_cycle_anchor: Deserialize::default(), + expires_at: Deserialize::default(), + subscription_items: Deserialize::default(), + trial_end: Deserialize::default(), + trial_from_plan: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_cycle_anchor = self.billing_cycle_anchor.take()?; + let expires_at = self.expires_at.take()?; + let subscription_items = self.subscription_items.take()?; + let trial_end = self.trial_end.take()?; + let trial_from_plan = self.trial_from_plan.take()?; + + Some(Self::Out { billing_cycle_anchor, expires_at, subscription_items, trial_end, trial_from_plan }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionsResourcePendingUpdate { + type Builder = SubscriptionsResourcePendingUpdateBuilder; + } + + impl FromValueOpt for SubscriptionsResourcePendingUpdate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionsResourcePendingUpdateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_cycle_anchor" => b.billing_cycle_anchor = Some(FromValueOpt::from_value(v)?), + "expires_at" => b.expires_at = Some(FromValueOpt::from_value(v)?), + "subscription_items" => b.subscription_items = Some(FromValueOpt::from_value(v)?), + "trial_end" => b.trial_end = Some(FromValueOpt::from_value(v)?), + "trial_from_plan" => b.trial_from_plan = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscriptions_trials_resource_end_behavior.rs b/generated/stripe_shared/src/subscriptions_trials_resource_end_behavior.rs index 8fded3031..9d68245ab 100644 --- a/generated/stripe_shared/src/subscriptions_trials_resource_end_behavior.rs +++ b/generated/stripe_shared/src/subscriptions_trials_resource_end_behavior.rs @@ -1,9 +1,97 @@ /// Defines how a subscription behaves when a free trial ends. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionsTrialsResourceEndBehavior { /// Indicates how the subscription should change when the trial ends if the user did not provide a payment method. pub missing_payment_method: SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionsTrialsResourceEndBehaviorBuilder { + missing_payment_method: Option<SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionsTrialsResourceEndBehavior { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionsTrialsResourceEndBehavior>, + builder: SubscriptionsTrialsResourceEndBehaviorBuilder, + } + + impl Visitor for Place<SubscriptionsTrialsResourceEndBehavior> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionsTrialsResourceEndBehaviorBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionsTrialsResourceEndBehaviorBuilder { + type Out = SubscriptionsTrialsResourceEndBehavior; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "missing_payment_method" => Deserialize::begin(&mut self.missing_payment_method), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { missing_payment_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let missing_payment_method = self.missing_payment_method.take()?; + + Some(Self::Out { missing_payment_method }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionsTrialsResourceEndBehavior { + type Builder = SubscriptionsTrialsResourceEndBehaviorBuilder; + } + + impl FromValueOpt for SubscriptionsTrialsResourceEndBehavior { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionsTrialsResourceEndBehaviorBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "missing_payment_method" => b.missing_payment_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Indicates how the subscription should change when the trial ends if the user did not provide a payment method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod { @@ -57,10 +145,24 @@ impl<'de> serde::Deserialize<'de> for SubscriptionsTrialsResourceEndBehaviorMiss fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod); diff --git a/generated/stripe_shared/src/subscriptions_trials_resource_trial_settings.rs b/generated/stripe_shared/src/subscriptions_trials_resource_trial_settings.rs index c83a12296..6b23fc4bb 100644 --- a/generated/stripe_shared/src/subscriptions_trials_resource_trial_settings.rs +++ b/generated/stripe_shared/src/subscriptions_trials_resource_trial_settings.rs @@ -1,5 +1,93 @@ /// Configures how this subscription behaves during the trial period. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct SubscriptionsTrialsResourceTrialSettings { pub end_behavior: stripe_shared::SubscriptionsTrialsResourceEndBehavior, } +#[cfg(feature = "min-ser")] +pub struct SubscriptionsTrialsResourceTrialSettingsBuilder { + end_behavior: Option<stripe_shared::SubscriptionsTrialsResourceEndBehavior>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionsTrialsResourceTrialSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<SubscriptionsTrialsResourceTrialSettings>, + builder: SubscriptionsTrialsResourceTrialSettingsBuilder, + } + + impl Visitor for Place<SubscriptionsTrialsResourceTrialSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: SubscriptionsTrialsResourceTrialSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for SubscriptionsTrialsResourceTrialSettingsBuilder { + type Out = SubscriptionsTrialsResourceTrialSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "end_behavior" => Deserialize::begin(&mut self.end_behavior), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end_behavior: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let end_behavior = self.end_behavior.take()?; + + Some(Self::Out { end_behavior }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionsTrialsResourceTrialSettings { + type Builder = SubscriptionsTrialsResourceTrialSettingsBuilder; + } + + impl FromValueOpt for SubscriptionsTrialsResourceTrialSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionsTrialsResourceTrialSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "end_behavior" => b.end_behavior = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/tax_code.rs b/generated/stripe_shared/src/tax_code.rs index a1df43358..0087b25d3 100644 --- a/generated/stripe_shared/src/tax_code.rs +++ b/generated/stripe_shared/src/tax_code.rs @@ -1,7 +1,9 @@ /// [Tax codes](https://stripe.com/docs/tax/tax-categories) classify goods and services for tax purposes. /// /// For more details see <<https://stripe.com/docs/api/tax_codes/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxCode { /// A detailed description of which types of products the tax code represents. pub description: String, @@ -10,6 +12,100 @@ pub struct TaxCode { /// A short name for the tax code. pub name: String, } +#[cfg(feature = "min-ser")] +pub struct TaxCodeBuilder { + description: Option<String>, + id: Option<stripe_shared::TaxCodeId>, + name: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxCode { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxCode>, + builder: TaxCodeBuilder, + } + + impl Visitor for Place<TaxCode> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxCodeBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxCodeBuilder { + type Out = TaxCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "description" => Deserialize::begin(&mut self.description), + "id" => Deserialize::begin(&mut self.id), + "name" => Deserialize::begin(&mut self.name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { description: Deserialize::default(), id: Deserialize::default(), name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let description = self.description.take()?; + let id = self.id.take()?; + let name = self.name.take()?; + + Some(Self::Out { description, id, name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxCode { + type Builder = TaxCodeBuilder; + } + + impl FromValueOpt for TaxCode { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TaxCode { type Id = stripe_shared::TaxCodeId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/tax_deducted_at_source.rs b/generated/stripe_shared/src/tax_deducted_at_source.rs index 9e9fd08f7..5e6f4f801 100644 --- a/generated/stripe_shared/src/tax_deducted_at_source.rs +++ b/generated/stripe_shared/src/tax_deducted_at_source.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxDeductedAtSource { /// Unique identifier for the object. pub id: stripe_shared::TaxDeductedAtSourceId, @@ -11,6 +13,104 @@ pub struct TaxDeductedAtSource { /// The TAN that was supplied to Stripe when TDS was assessed pub tax_deduction_account_number: String, } +#[cfg(feature = "min-ser")] +pub struct TaxDeductedAtSourceBuilder { + id: Option<stripe_shared::TaxDeductedAtSourceId>, + period_end: Option<stripe_types::Timestamp>, + period_start: Option<stripe_types::Timestamp>, + tax_deduction_account_number: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxDeductedAtSource { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxDeductedAtSource>, + builder: TaxDeductedAtSourceBuilder, + } + + impl Visitor for Place<TaxDeductedAtSource> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxDeductedAtSourceBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxDeductedAtSourceBuilder { + type Out = TaxDeductedAtSource; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "period_end" => Deserialize::begin(&mut self.period_end), + "period_start" => Deserialize::begin(&mut self.period_start), + "tax_deduction_account_number" => Deserialize::begin(&mut self.tax_deduction_account_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), period_end: Deserialize::default(), period_start: Deserialize::default(), tax_deduction_account_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let period_end = self.period_end.take()?; + let period_start = self.period_start.take()?; + let tax_deduction_account_number = self.tax_deduction_account_number.take()?; + + Some(Self::Out { id, period_end, period_start, tax_deduction_account_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxDeductedAtSource { + type Builder = TaxDeductedAtSourceBuilder; + } + + impl FromValueOpt for TaxDeductedAtSource { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxDeductedAtSourceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "period_end" => b.period_end = Some(FromValueOpt::from_value(v)?), + "period_start" => b.period_start = Some(FromValueOpt::from_value(v)?), + "tax_deduction_account_number" => b.tax_deduction_account_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TaxDeductedAtSource { type Id = stripe_shared::TaxDeductedAtSourceId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/tax_i_ds_owner.rs b/generated/stripe_shared/src/tax_i_ds_owner.rs deleted file mode 100644 index 79a1ffa55..000000000 --- a/generated/stripe_shared/src/tax_i_ds_owner.rs +++ /dev/null @@ -1,75 +0,0 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct TaxIDsOwner { - /// The account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub account: Option<stripe_types::Expandable<stripe_shared::Account>>, - /// The Connect Application being referenced when `type` is `application`. - #[serde(skip_serializing_if = "Option::is_none")] - pub application: Option<stripe_types::Expandable<stripe_shared::Application>>, - /// The customer being referenced when `type` is `customer`. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>, - /// Type of owner referenced. - #[serde(rename = "type")] - pub type_: TaxIDsOwnerType, -} -/// Type of owner referenced. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum TaxIDsOwnerType { - Account, - Application, - Customer, - Self_, -} -impl TaxIDsOwnerType { - pub fn as_str(self) -> &'static str { - use TaxIDsOwnerType::*; - match self { - Account => "account", - Application => "application", - Customer => "customer", - Self_ => "self", - } - } -} - -impl std::str::FromStr for TaxIDsOwnerType { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use TaxIDsOwnerType::*; - match s { - "account" => Ok(Account), - "application" => Ok(Application), - "customer" => Ok(Customer), - "self" => Ok(Self_), - _ => Err(()), - } - } -} -impl std::fmt::Display for TaxIDsOwnerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for TaxIDsOwnerType { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for TaxIDsOwnerType { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for TaxIDsOwnerType { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TaxIDsOwnerType")) - } -} diff --git a/generated/stripe_shared/src/tax_id.rs b/generated/stripe_shared/src/tax_id.rs index d8bceb5c0..a0c2e1a04 100644 --- a/generated/stripe_shared/src/tax_id.rs +++ b/generated/stripe_shared/src/tax_id.rs @@ -4,7 +4,9 @@ /// Related guides: [Customer tax identification numbers](https://stripe.com/docs/billing/taxes/tax-ids), [Account tax IDs](https://stripe.com/docs/invoicing/connect#account-tax-ids). /// /// For more details see <<https://stripe.com/docs/api/tax_ids/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxId { /// Two-letter ISO code representing the country of the tax ID. pub country: Option<String>, @@ -16,18 +18,138 @@ pub struct TaxId { pub id: stripe_shared::TaxIdId, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, - /// The account or customer the tax ID belongs to. - #[serde(skip_serializing_if = "Option::is_none")] - pub owner: Option<stripe_shared::TaxIDsOwner>, /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. /// Note that some legacy tax IDs have type `unknown`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TaxIdType, /// Value of the tax ID. pub value: String, /// Tax ID verification information. pub verification: Option<stripe_shared::TaxIdVerification>, } +#[cfg(feature = "min-ser")] +pub struct TaxIdBuilder { + country: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>, + id: Option<stripe_shared::TaxIdId>, + livemode: Option<bool>, + type_: Option<TaxIdType>, + value: Option<String>, + verification: Option<Option<stripe_shared::TaxIdVerification>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxId { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxId>, + builder: TaxIdBuilder, + } + + impl Visitor for Place<TaxId> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxIdBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxIdBuilder { + type Out = TaxId; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "country" => Deserialize::begin(&mut self.country), + "created" => Deserialize::begin(&mut self.created), + "customer" => Deserialize::begin(&mut self.customer), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "type" => Deserialize::begin(&mut self.type_), + "value" => Deserialize::begin(&mut self.value), + "verification" => Deserialize::begin(&mut self.verification), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + country: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + type_: Deserialize::default(), + value: Deserialize::default(), + verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let country = self.country.take()?; + let created = self.created.take()?; + let customer = self.customer.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let type_ = self.type_.take()?; + let value = self.value.take()?; + let verification = self.verification.take()?; + + Some(Self::Out { country, created, customer, id, livemode, type_, value, verification }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxId { + type Builder = TaxIdBuilder; + } + + impl FromValueOpt for TaxId { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxIdBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "value" => b.value = Some(FromValueOpt::from_value(v)?), + "verification" => b.verification = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `ar_cuit`, `au_abn`, `au_arn`, `bg_uic`, `bo_tin`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sv_nit`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, `uy_ruc`, `ve_rif`, `vn_tin`, or `za_vat`. /// Note that some legacy tax IDs have type `unknown`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -277,6 +399,24 @@ impl<'de> serde::Deserialize<'de> for TaxIdType { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxIdType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxIdType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxIdType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxIdType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxIdType); impl stripe_types::Object for TaxId { type Id = stripe_shared::TaxIdId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/tax_id_verification.rs b/generated/stripe_shared/src/tax_id_verification.rs index 2b50c88d2..86fdc7011 100644 --- a/generated/stripe_shared/src/tax_id_verification.rs +++ b/generated/stripe_shared/src/tax_id_verification.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxIdVerification { /// Verification status, one of `pending`, `verified`, `unverified`, or `unavailable`. pub status: TaxIdVerificationStatus, @@ -7,6 +9,100 @@ pub struct TaxIdVerification { /// Verified name. pub verified_name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TaxIdVerificationBuilder { + status: Option<TaxIdVerificationStatus>, + verified_address: Option<Option<String>>, + verified_name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxIdVerification { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TaxIdVerification>, + builder: TaxIdVerificationBuilder, + } + + impl Visitor for Place<TaxIdVerification> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxIdVerificationBuilder::deser_default() })) + } + } + + impl MapBuilder for TaxIdVerificationBuilder { + type Out = TaxIdVerification; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "status" => Deserialize::begin(&mut self.status), + "verified_address" => Deserialize::begin(&mut self.verified_address), + "verified_name" => Deserialize::begin(&mut self.verified_name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default(), verified_address: Deserialize::default(), verified_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let status = self.status.take()?; + let verified_address = self.verified_address.take()?; + let verified_name = self.verified_name.take()?; + + Some(Self::Out { status, verified_address, verified_name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TaxIdVerification { + type Builder = TaxIdVerificationBuilder; + } + + impl FromValueOpt for TaxIdVerification { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxIdVerificationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "verified_address" => b.verified_address = Some(FromValueOpt::from_value(v)?), + "verified_name" => b.verified_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Verification status, one of `pending`, `verified`, `unverified`, or `unavailable`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxIdVerificationStatus { @@ -63,7 +159,24 @@ impl<'de> serde::Deserialize<'de> for TaxIdVerificationStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TaxIdVerificationStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TaxIdVerificationStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxIdVerificationStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxIdVerificationStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxIdVerificationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxIdVerificationStatus); diff --git a/generated/stripe_shared/src/tax_rate.rs b/generated/stripe_shared/src/tax_rate.rs index d45339be6..b0ac52bc3 100644 --- a/generated/stripe_shared/src/tax_rate.rs +++ b/generated/stripe_shared/src/tax_rate.rs @@ -3,7 +3,9 @@ /// Related guide: [Tax rates](https://stripe.com/docs/billing/taxes/tax-rates) /// /// For more details see <<https://stripe.com/docs/api/tax_rates/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TaxRate { /// Defaults to `true`. /// When set to `false`, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set. @@ -30,9 +32,6 @@ pub struct TaxRate { /// You can use this label field for tax reporting purposes. /// It also appears on your customer’s invoice. pub jurisdiction: Option<String>, - /// The level of the jurisdiction that imposes this tax rate. - /// Will be `null` for manually defined tax rates. - pub jurisdiction_level: Option<TaxRateJurisdictionLevel>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. @@ -47,73 +46,159 @@ pub struct TaxRate { /// The high-level tax type, such as `vat` or `sales_tax`. pub tax_type: Option<stripe_shared::TaxRateTaxType>, } -/// The level of the jurisdiction that imposes this tax rate. -/// Will be `null` for manually defined tax rates. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum TaxRateJurisdictionLevel { - City, - Country, - County, - District, - Multiple, - State, +#[cfg(feature = "min-ser")] +pub struct TaxRateBuilder { + active: Option<bool>, + country: Option<Option<String>>, + created: Option<stripe_types::Timestamp>, + description: Option<Option<String>>, + display_name: Option<String>, + effective_percentage: Option<Option<f64>>, + id: Option<stripe_shared::TaxRateId>, + inclusive: Option<bool>, + jurisdiction: Option<Option<String>>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + percentage: Option<f64>, + state: Option<Option<String>>, + tax_type: Option<Option<stripe_shared::TaxRateTaxType>>, } -impl TaxRateJurisdictionLevel { - pub fn as_str(self) -> &'static str { - use TaxRateJurisdictionLevel::*; - match self { - City => "city", - Country => "country", - County => "county", - District => "district", - Multiple => "multiple", - State => "state", + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxRate { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) } } -} -impl std::str::FromStr for TaxRateJurisdictionLevel { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use TaxRateJurisdictionLevel::*; - match s { - "city" => Ok(City), - "country" => Ok(Country), - "county" => Ok(County), - "district" => Ok(District), - "multiple" => Ok(Multiple), - "state" => Ok(State), - _ => Err(()), + struct Builder<'a> { + out: &'a mut Option<TaxRate>, + builder: TaxRateBuilder, + } + + impl Visitor for Place<TaxRate> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxRateBuilder::deser_default() })) } } -} -impl std::fmt::Display for TaxRateJurisdictionLevel { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + + impl MapBuilder for TaxRateBuilder { + type Out = TaxRate; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active" => Deserialize::begin(&mut self.active), + "country" => Deserialize::begin(&mut self.country), + "created" => Deserialize::begin(&mut self.created), + "description" => Deserialize::begin(&mut self.description), + "display_name" => Deserialize::begin(&mut self.display_name), + "effective_percentage" => Deserialize::begin(&mut self.effective_percentage), + "id" => Deserialize::begin(&mut self.id), + "inclusive" => Deserialize::begin(&mut self.inclusive), + "jurisdiction" => Deserialize::begin(&mut self.jurisdiction), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "percentage" => Deserialize::begin(&mut self.percentage), + "state" => Deserialize::begin(&mut self.state), + "tax_type" => Deserialize::begin(&mut self.tax_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active: Deserialize::default(), + country: Deserialize::default(), + created: Deserialize::default(), + description: Deserialize::default(), + display_name: Deserialize::default(), + effective_percentage: Deserialize::default(), + id: Deserialize::default(), + inclusive: Deserialize::default(), + jurisdiction: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + percentage: Deserialize::default(), + state: Deserialize::default(), + tax_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active = self.active.take()?; + let country = self.country.take()?; + let created = self.created.take()?; + let description = self.description.take()?; + let display_name = self.display_name.take()?; + let effective_percentage = self.effective_percentage.take()?; + let id = self.id.take()?; + let inclusive = self.inclusive.take()?; + let jurisdiction = self.jurisdiction.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let percentage = self.percentage.take()?; + let state = self.state.take()?; + let tax_type = self.tax_type.take()?; + + Some(Self::Out { active, country, created, description, display_name, effective_percentage, id, inclusive, jurisdiction, livemode, metadata, percentage, state, tax_type }) + } } -} -impl std::fmt::Debug for TaxRateJurisdictionLevel { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } } -} -impl serde::Serialize for TaxRateJurisdictionLevel { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) + + impl ObjectDeser for TaxRate { + type Builder = TaxRateBuilder; } -} -impl<'de> serde::Deserialize<'de> for TaxRateJurisdictionLevel { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TaxRateJurisdictionLevel")) + + impl FromValueOpt for TaxRate { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxRateBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active" => b.active = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "effective_percentage" => b.effective_percentage = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "inclusive" => b.inclusive = Some(FromValueOpt::from_value(v)?), + "jurisdiction" => b.jurisdiction = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "percentage" => b.percentage = Some(FromValueOpt::from_value(v)?), + "state" => b.state = Some(FromValueOpt::from_value(v)?), + "tax_type" => b.tax_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } } -} +}; impl stripe_types::Object for TaxRate { type Id = stripe_shared::TaxRateId; fn id(&self) -> &Self::Id { @@ -207,6 +292,24 @@ impl<'de> serde::Deserialize<'de> for TaxRateTaxType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(TaxRateTaxType::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TaxRateTaxType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TaxRateTaxType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxRateTaxType::from_str(s).unwrap_or(TaxRateTaxType::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TaxRateTaxType); diff --git a/generated/stripe_shared/src/test_helpers_test_clock.rs b/generated/stripe_shared/src/test_helpers_test_clock.rs index af1af728e..c9a78f5d9 100644 --- a/generated/stripe_shared/src/test_helpers_test_clock.rs +++ b/generated/stripe_shared/src/test_helpers_test_clock.rs @@ -3,7 +3,9 @@ /// objects at a frozen time in the past or future, and advance to a specific future time to observe webhooks and state changes. /// After the clock advances,. /// you can either validate the current state of your scenario (and test your assumptions), change the current state of your scenario (and test more complex scenarios), or keep advancing forward in time. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TestHelpersTestClock { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -20,6 +22,124 @@ pub struct TestHelpersTestClock { /// The status of the Test Clock. pub status: TestHelpersTestClockStatus, } +#[cfg(feature = "min-ser")] +pub struct TestHelpersTestClockBuilder { + created: Option<stripe_types::Timestamp>, + deletes_after: Option<stripe_types::Timestamp>, + frozen_time: Option<stripe_types::Timestamp>, + id: Option<stripe_shared::TestHelpersTestClockId>, + livemode: Option<bool>, + name: Option<Option<String>>, + status: Option<TestHelpersTestClockStatus>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TestHelpersTestClock { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TestHelpersTestClock>, + builder: TestHelpersTestClockBuilder, + } + + impl Visitor for Place<TestHelpersTestClock> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TestHelpersTestClockBuilder::deser_default() })) + } + } + + impl MapBuilder for TestHelpersTestClockBuilder { + type Out = TestHelpersTestClock; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "deletes_after" => Deserialize::begin(&mut self.deletes_after), + "frozen_time" => Deserialize::begin(&mut self.frozen_time), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "name" => Deserialize::begin(&mut self.name), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + deletes_after: Deserialize::default(), + frozen_time: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + name: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let created = self.created.take()?; + let deletes_after = self.deletes_after.take()?; + let frozen_time = self.frozen_time.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let name = self.name.take()?; + let status = self.status.take()?; + + Some(Self::Out { created, deletes_after, frozen_time, id, livemode, name, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TestHelpersTestClock { + type Builder = TestHelpersTestClockBuilder; + } + + impl FromValueOpt for TestHelpersTestClock { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TestHelpersTestClockBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "deletes_after" => b.deletes_after = Some(FromValueOpt::from_value(v)?), + "frozen_time" => b.frozen_time = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the Test Clock. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TestHelpersTestClockStatus { @@ -73,10 +193,27 @@ impl<'de> serde::Deserialize<'de> for TestHelpersTestClockStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TestHelpersTestClockStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TestHelpersTestClockStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TestHelpersTestClockStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TestHelpersTestClockStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TestHelpersTestClockStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TestHelpersTestClockStatus); impl stripe_types::Object for TestHelpersTestClock { type Id = stripe_shared::TestHelpersTestClockId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/three_d_secure_details.rs b/generated/stripe_shared/src/three_d_secure_details.rs index b61bbeab4..4e741275e 100644 --- a/generated/stripe_shared/src/three_d_secure_details.rs +++ b/generated/stripe_shared/src/three_d_secure_details.rs @@ -1,22 +1,116 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ThreeDSecureDetails { /// For authenticated transactions: how the customer was authenticated by /// the issuing bank. pub authentication_flow: Option<ThreeDSecureDetailsAuthenticationFlow>, - /// The Electronic Commerce Indicator (ECI). A protocol-level field - /// indicating what degree of authentication was performed. - pub electronic_commerce_indicator: Option<ThreeDSecureDetailsElectronicCommerceIndicator>, /// Indicates the outcome of 3D Secure authentication. pub result: Option<ThreeDSecureDetailsResult>, /// Additional information about why 3D Secure succeeded or failed based /// on the `result`. pub result_reason: Option<ThreeDSecureDetailsResultReason>, - /// The 3D Secure 1 XID or 3D Secure 2 Directory Server Transaction ID - /// (dsTransId) for this payment. - pub transaction_id: Option<String>, /// The version of 3D Secure that was used. pub version: Option<ThreeDSecureDetailsVersion>, } +#[cfg(feature = "min-ser")] +pub struct ThreeDSecureDetailsBuilder { + authentication_flow: Option<Option<ThreeDSecureDetailsAuthenticationFlow>>, + result: Option<Option<ThreeDSecureDetailsResult>>, + result_reason: Option<Option<ThreeDSecureDetailsResultReason>>, + version: Option<Option<ThreeDSecureDetailsVersion>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ThreeDSecureDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ThreeDSecureDetails>, + builder: ThreeDSecureDetailsBuilder, + } + + impl Visitor for Place<ThreeDSecureDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ThreeDSecureDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for ThreeDSecureDetailsBuilder { + type Out = ThreeDSecureDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "authentication_flow" => Deserialize::begin(&mut self.authentication_flow), + "result" => Deserialize::begin(&mut self.result), + "result_reason" => Deserialize::begin(&mut self.result_reason), + "version" => Deserialize::begin(&mut self.version), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { authentication_flow: Deserialize::default(), result: Deserialize::default(), result_reason: Deserialize::default(), version: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let authentication_flow = self.authentication_flow.take()?; + let result = self.result.take()?; + let result_reason = self.result_reason.take()?; + let version = self.version.take()?; + + Some(Self::Out { authentication_flow, result, result_reason, version }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ThreeDSecureDetails { + type Builder = ThreeDSecureDetailsBuilder; + } + + impl FromValueOpt for ThreeDSecureDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ThreeDSecureDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "authentication_flow" => b.authentication_flow = Some(FromValueOpt::from_value(v)?), + "result" => b.result = Some(FromValueOpt::from_value(v)?), + "result_reason" => b.result_reason = Some(FromValueOpt::from_value(v)?), + "version" => b.version = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// For authenticated transactions: how the customer was authenticated by /// the issuing bank. #[derive(Copy, Clone, Eq, PartialEq)] @@ -68,78 +162,27 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsAuthenticationFlow { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ThreeDSecureDetailsAuthenticationFlow") - }) - } -} -/// The Electronic Commerce Indicator (ECI). A protocol-level field -/// indicating what degree of authentication was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ThreeDSecureDetailsElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl ThreeDSecureDetailsElectronicCommerceIndicator { - pub fn as_str(self) -> &'static str { - use ThreeDSecureDetailsElectronicCommerceIndicator::*; - match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", - } - } -} - -impl std::str::FromStr for ThreeDSecureDetailsElectronicCommerceIndicator { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ThreeDSecureDetailsElectronicCommerceIndicator::*; - match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), - _ => Err(()), - } + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsAuthenticationFlow")) } } -impl std::fmt::Display for ThreeDSecureDetailsElectronicCommerceIndicator { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsAuthenticationFlow { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } -impl std::fmt::Debug for ThreeDSecureDetailsElectronicCommerceIndicator { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ThreeDSecureDetailsElectronicCommerceIndicator { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsElectronicCommerceIndicator { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsAuthenticationFlow> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for ThreeDSecureDetailsElectronicCommerceIndicator", - ) - }) + self.out = Some(ThreeDSecureDetailsAuthenticationFlow::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsAuthenticationFlow); /// Indicates the outcome of 3D Secure authentication. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ThreeDSecureDetailsResult { @@ -202,10 +245,27 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsResult { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsResult")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsResult")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsResult { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsResult> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsResult::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsResult); /// Additional information about why 3D Secure succeeded or failed based /// on the `result`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -272,11 +332,27 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsResultReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ThreeDSecureDetailsResultReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsResultReason")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsResultReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsResultReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsResultReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsResultReason); /// The version of 3D Secure that was used. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ThreeDSecureDetailsVersion { @@ -330,7 +406,24 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsVersion { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsVersion")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsVersion")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsVersion { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsVersion> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsVersion::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsVersion); diff --git a/generated/stripe_shared/src/three_d_secure_details_charge.rs b/generated/stripe_shared/src/three_d_secure_details_charge.rs index 39a51b6ca..7008fed7f 100644 --- a/generated/stripe_shared/src/three_d_secure_details_charge.rs +++ b/generated/stripe_shared/src/three_d_secure_details_charge.rs @@ -1,28 +1,116 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ThreeDSecureDetailsCharge { /// For authenticated transactions: how the customer was authenticated by /// the issuing bank. pub authentication_flow: Option<ThreeDSecureDetailsChargeAuthenticationFlow>, - /// The Electronic Commerce Indicator (ECI). A protocol-level field - /// indicating what degree of authentication was performed. - pub electronic_commerce_indicator: Option<ThreeDSecureDetailsChargeElectronicCommerceIndicator>, - /// The exemption requested via 3DS and accepted by the issuer at authentication time. - pub exemption_indicator: Option<ThreeDSecureDetailsChargeExemptionIndicator>, - /// Whether Stripe requested the value of `exemption_indicator` in the transaction. This will depend on - /// the outcome of Stripe's internal risk assessment. - #[serde(skip_serializing_if = "Option::is_none")] - pub exemption_indicator_applied: Option<bool>, /// Indicates the outcome of 3D Secure authentication. pub result: Option<ThreeDSecureDetailsChargeResult>, /// Additional information about why 3D Secure succeeded or failed based /// on the `result`. pub result_reason: Option<ThreeDSecureDetailsChargeResultReason>, - /// The 3D Secure 1 XID or 3D Secure 2 Directory Server Transaction ID - /// (dsTransId) for this payment. - pub transaction_id: Option<String>, /// The version of 3D Secure that was used. pub version: Option<ThreeDSecureDetailsChargeVersion>, } +#[cfg(feature = "min-ser")] +pub struct ThreeDSecureDetailsChargeBuilder { + authentication_flow: Option<Option<ThreeDSecureDetailsChargeAuthenticationFlow>>, + result: Option<Option<ThreeDSecureDetailsChargeResult>>, + result_reason: Option<Option<ThreeDSecureDetailsChargeResultReason>>, + version: Option<Option<ThreeDSecureDetailsChargeVersion>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ThreeDSecureDetailsCharge { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ThreeDSecureDetailsCharge>, + builder: ThreeDSecureDetailsChargeBuilder, + } + + impl Visitor for Place<ThreeDSecureDetailsCharge> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ThreeDSecureDetailsChargeBuilder::deser_default() })) + } + } + + impl MapBuilder for ThreeDSecureDetailsChargeBuilder { + type Out = ThreeDSecureDetailsCharge; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "authentication_flow" => Deserialize::begin(&mut self.authentication_flow), + "result" => Deserialize::begin(&mut self.result), + "result_reason" => Deserialize::begin(&mut self.result_reason), + "version" => Deserialize::begin(&mut self.version), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { authentication_flow: Deserialize::default(), result: Deserialize::default(), result_reason: Deserialize::default(), version: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let authentication_flow = self.authentication_flow.take()?; + let result = self.result.take()?; + let result_reason = self.result_reason.take()?; + let version = self.version.take()?; + + Some(Self::Out { authentication_flow, result, result_reason, version }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ThreeDSecureDetailsCharge { + type Builder = ThreeDSecureDetailsChargeBuilder; + } + + impl FromValueOpt for ThreeDSecureDetailsCharge { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ThreeDSecureDetailsChargeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "authentication_flow" => b.authentication_flow = Some(FromValueOpt::from_value(v)?), + "result" => b.result = Some(FromValueOpt::from_value(v)?), + "result_reason" => b.result_reason = Some(FromValueOpt::from_value(v)?), + "version" => b.version = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// For authenticated transactions: how the customer was authenticated by /// the issuing bank. #[derive(Copy, Clone, Eq, PartialEq)] @@ -74,137 +162,27 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeAuthenticationFlo fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for ThreeDSecureDetailsChargeAuthenticationFlow", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsChargeAuthenticationFlow")) } } -/// The Electronic Commerce Indicator (ECI). A protocol-level field -/// indicating what degree of authentication was performed. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ThreeDSecureDetailsChargeElectronicCommerceIndicator { - V01, - V02, - V05, - V06, - V07, -} -impl ThreeDSecureDetailsChargeElectronicCommerceIndicator { - pub fn as_str(self) -> &'static str { - use ThreeDSecureDetailsChargeElectronicCommerceIndicator::*; - match self { - V01 => "01", - V02 => "02", - V05 => "05", - V06 => "06", - V07 => "07", - } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsChargeAuthenticationFlow { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } -impl std::str::FromStr for ThreeDSecureDetailsChargeElectronicCommerceIndicator { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ThreeDSecureDetailsChargeElectronicCommerceIndicator::*; - match s { - "01" => Ok(V01), - "02" => Ok(V02), - "05" => Ok(V05), - "06" => Ok(V06), - "07" => Ok(V07), - _ => Err(()), - } - } -} -impl std::fmt::Display for ThreeDSecureDetailsChargeElectronicCommerceIndicator { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ThreeDSecureDetailsChargeElectronicCommerceIndicator { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ThreeDSecureDetailsChargeElectronicCommerceIndicator { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeElectronicCommerceIndicator { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeAuthenticationFlow> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for ThreeDSecureDetailsChargeElectronicCommerceIndicator", - ) - }) - } -} -/// The exemption requested via 3DS and accepted by the issuer at authentication time. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ThreeDSecureDetailsChargeExemptionIndicator { - LowRisk, - None, -} -impl ThreeDSecureDetailsChargeExemptionIndicator { - pub fn as_str(self) -> &'static str { - use ThreeDSecureDetailsChargeExemptionIndicator::*; - match self { - LowRisk => "low_risk", - None => "none", - } + self.out = Some(ThreeDSecureDetailsChargeAuthenticationFlow::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } -impl std::str::FromStr for ThreeDSecureDetailsChargeExemptionIndicator { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ThreeDSecureDetailsChargeExemptionIndicator::*; - match s { - "low_risk" => Ok(LowRisk), - "none" => Ok(None), - _ => Err(()), - } - } -} -impl std::fmt::Display for ThreeDSecureDetailsChargeExemptionIndicator { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ThreeDSecureDetailsChargeExemptionIndicator { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ThreeDSecureDetailsChargeExemptionIndicator { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeExemptionIndicator { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { - use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for ThreeDSecureDetailsChargeExemptionIndicator", - ) - }) - } -} +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeAuthenticationFlow); /// Indicates the outcome of 3D Secure authentication. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ThreeDSecureDetailsChargeResult { @@ -267,11 +245,27 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeResult { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ThreeDSecureDetailsChargeResult") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsChargeResult")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsChargeResult { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeResult> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsChargeResult::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeResult); /// Additional information about why 3D Secure succeeded or failed based /// on the `result`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -338,11 +332,27 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeResultReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ThreeDSecureDetailsChargeResultReason") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsChargeResultReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsChargeResultReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeResultReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsChargeResultReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeResultReason); /// The version of 3D Secure that was used. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ThreeDSecureDetailsChargeVersion { @@ -396,8 +406,24 @@ impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeVersion { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for ThreeDSecureDetailsChargeVersion") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ThreeDSecureDetailsChargeVersion")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ThreeDSecureDetailsChargeVersion { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ThreeDSecureDetailsChargeVersion> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsChargeVersion::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeVersion); diff --git a/generated/stripe_shared/src/three_d_secure_usage.rs b/generated/stripe_shared/src/three_d_secure_usage.rs index c2869dd18..c8e513f35 100644 --- a/generated/stripe_shared/src/three_d_secure_usage.rs +++ b/generated/stripe_shared/src/three_d_secure_usage.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ThreeDSecureUsage { /// Whether 3D Secure is supported on this card. pub supported: bool, } +#[cfg(feature = "min-ser")] +pub struct ThreeDSecureUsageBuilder { + supported: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ThreeDSecureUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ThreeDSecureUsage>, + builder: ThreeDSecureUsageBuilder, + } + + impl Visitor for Place<ThreeDSecureUsage> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ThreeDSecureUsageBuilder::deser_default() })) + } + } + + impl MapBuilder for ThreeDSecureUsageBuilder { + type Out = ThreeDSecureUsage; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "supported" => Deserialize::begin(&mut self.supported), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { supported: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let supported = self.supported.take()?; + + Some(Self::Out { supported }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ThreeDSecureUsage { + type Builder = ThreeDSecureUsageBuilder; + } + + impl FromValueOpt for ThreeDSecureUsage { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ThreeDSecureUsageBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "supported" => b.supported = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/topup.rs b/generated/stripe_shared/src/topup.rs index a4a4bc5ac..f98796bb2 100644 --- a/generated/stripe_shared/src/topup.rs +++ b/generated/stripe_shared/src/topup.rs @@ -5,7 +5,9 @@ /// Related guide: [Topping up your platform account](https://stripe.com/docs/connect/top-ups) /// /// For more details see <<https://stripe.com/docs/api/topups/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Topup { /// Amount transferred. pub amount: i64, @@ -45,6 +47,180 @@ pub struct Topup { /// A string that identifies this top-up as part of a group. pub transfer_group: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TopupBuilder { + amount: Option<i64>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + expected_availability_date: Option<Option<stripe_types::Timestamp>>, + failure_code: Option<Option<String>>, + failure_message: Option<Option<String>>, + id: Option<stripe_shared::TopupId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + source: Option<Option<stripe_shared::Source>>, + statement_descriptor: Option<Option<String>>, + status: Option<TopupStatus>, + transfer_group: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Topup { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Topup>, + builder: TopupBuilder, + } + + impl Visitor for Place<Topup> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TopupBuilder::deser_default() })) + } + } + + impl MapBuilder for TopupBuilder { + type Out = Topup; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "expected_availability_date" => Deserialize::begin(&mut self.expected_availability_date), + "failure_code" => Deserialize::begin(&mut self.failure_code), + "failure_message" => Deserialize::begin(&mut self.failure_message), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "source" => Deserialize::begin(&mut self.source), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "status" => Deserialize::begin(&mut self.status), + "transfer_group" => Deserialize::begin(&mut self.transfer_group), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + balance_transaction: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + expected_availability_date: Deserialize::default(), + failure_code: Deserialize::default(), + failure_message: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + source: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + transfer_group: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let balance_transaction = self.balance_transaction.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let expected_availability_date = self.expected_availability_date.take()?; + let failure_code = self.failure_code.take()?; + let failure_message = self.failure_message.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let source = self.source.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let status = self.status.take()?; + let transfer_group = self.transfer_group.take()?; + + Some(Self::Out { + amount, + balance_transaction, + created, + currency, + description, + expected_availability_date, + failure_code, + failure_message, + id, + livemode, + metadata, + source, + statement_descriptor, + status, + transfer_group, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Topup { + type Builder = TopupBuilder; + } + + impl FromValueOpt for Topup { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TopupBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "expected_availability_date" => b.expected_availability_date = Some(FromValueOpt::from_value(v)?), + "failure_code" => b.failure_code = Some(FromValueOpt::from_value(v)?), + "failure_message" => b.failure_message = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "source" => b.source = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "transfer_group" => b.transfer_group = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The status of the top-up is either `canceled`, `failed`, `pending`, `reversed`, or `succeeded`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TopupStatus { @@ -107,6 +283,24 @@ impl<'de> serde::Deserialize<'de> for TopupStatus { Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TopupStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TopupStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TopupStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TopupStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TopupStatus); impl stripe_types::Object for Topup { type Id = stripe_shared::TopupId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/transfer.rs b/generated/stripe_shared/src/transfer.rs index ac70f0ce6..defb7dc18 100644 --- a/generated/stripe_shared/src/transfer.rs +++ b/generated/stripe_shared/src/transfer.rs @@ -11,7 +11,9 @@ /// Related guide: [Creating separate charges and transfers](https://stripe.com/docs/connect/separate-charges-and-transfers). /// /// For more details see <<https://stripe.com/docs/api/transfers/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct Transfer { /// Amount in cents (or local equivalent) to be transferred. pub amount: i64, @@ -29,7 +31,6 @@ pub struct Transfer { /// ID of the Stripe account the transfer was sent to. pub destination: Option<stripe_types::Expandable<stripe_shared::Account>>, /// If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub destination_payment: Option<stripe_types::Expandable<stripe_shared::Charge>>, /// Unique identifier for the object. pub id: stripe_shared::TransferId, @@ -47,12 +48,191 @@ pub struct Transfer { /// If null, the transfer was funded from the available balance. pub source_transaction: Option<stripe_types::Expandable<stripe_shared::Charge>>, /// The source balance this transfer came from. One of `card`, `fpx`, or `bank_account`. - #[serde(skip_serializing_if = "Option::is_none")] pub source_type: Option<String>, /// A string that identifies this transaction as part of a group. /// See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details. pub transfer_group: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TransferBuilder { + amount: Option<i64>, + amount_reversed: Option<i64>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + destination: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>, + destination_payment: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + id: Option<stripe_shared::TransferId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + reversals: Option<stripe_types::List<stripe_shared::TransferReversal>>, + reversed: Option<bool>, + source_transaction: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + source_type: Option<Option<String>>, + transfer_group: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for Transfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<Transfer>, + builder: TransferBuilder, + } + + impl Visitor for Place<Transfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TransferBuilder::deser_default() })) + } + } + + impl MapBuilder for TransferBuilder { + type Out = Transfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "amount_reversed" => Deserialize::begin(&mut self.amount_reversed), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "destination" => Deserialize::begin(&mut self.destination), + "destination_payment" => Deserialize::begin(&mut self.destination_payment), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "reversals" => Deserialize::begin(&mut self.reversals), + "reversed" => Deserialize::begin(&mut self.reversed), + "source_transaction" => Deserialize::begin(&mut self.source_transaction), + "source_type" => Deserialize::begin(&mut self.source_type), + "transfer_group" => Deserialize::begin(&mut self.transfer_group), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_reversed: Deserialize::default(), + balance_transaction: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + destination: Deserialize::default(), + destination_payment: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + reversals: Deserialize::default(), + reversed: Deserialize::default(), + source_transaction: Deserialize::default(), + source_type: Deserialize::default(), + transfer_group: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let amount_reversed = self.amount_reversed.take()?; + let balance_transaction = self.balance_transaction.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let destination = self.destination.take()?; + let destination_payment = self.destination_payment.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let reversals = self.reversals.take()?; + let reversed = self.reversed.take()?; + let source_transaction = self.source_transaction.take()?; + let source_type = self.source_type.take()?; + let transfer_group = self.transfer_group.take()?; + + Some(Self::Out { + amount, + amount_reversed, + balance_transaction, + created, + currency, + description, + destination, + destination_payment, + id, + livemode, + metadata, + reversals, + reversed, + source_transaction, + source_type, + transfer_group, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for Transfer { + type Builder = TransferBuilder; + } + + impl FromValueOpt for Transfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "amount_reversed" => b.amount_reversed = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + "destination_payment" => b.destination_payment = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "reversals" => b.reversals = Some(FromValueOpt::from_value(v)?), + "reversed" => b.reversed = Some(FromValueOpt::from_value(v)?), + "source_transaction" => b.source_transaction = Some(FromValueOpt::from_value(v)?), + "source_type" => b.source_type = Some(FromValueOpt::from_value(v)?), + "transfer_group" => b.transfer_group = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for Transfer { type Id = stripe_shared::TransferId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/transfer_data.rs b/generated/stripe_shared/src/transfer_data.rs index 40749d57f..fde95a9af 100644 --- a/generated/stripe_shared/src/transfer_data.rs +++ b/generated/stripe_shared/src/transfer_data.rs @@ -1,13 +1,104 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TransferData { /// Amount intended to be collected by this PaymentIntent. /// A positive integer representing how much to charge in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). /// The minimum amount is $0.50 US or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts). /// The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99). - #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, /// The account (if any) that the payment is attributed to for tax /// reporting, and where funds from the payment are transferred to after /// payment success. pub destination: stripe_types::Expandable<stripe_shared::Account>, } +#[cfg(feature = "min-ser")] +pub struct TransferDataBuilder { + amount: Option<Option<i64>>, + destination: Option<stripe_types::Expandable<stripe_shared::Account>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TransferData { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TransferData>, + builder: TransferDataBuilder, + } + + impl Visitor for Place<TransferData> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TransferDataBuilder::deser_default() })) + } + } + + impl MapBuilder for TransferDataBuilder { + type Out = TransferData; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "destination" => Deserialize::begin(&mut self.destination), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let destination = self.destination.take()?; + + Some(Self::Out { amount, destination }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TransferData { + type Builder = TransferDataBuilder; + } + + impl FromValueOpt for TransferData { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TransferDataBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "destination" => b.destination = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/transfer_reversal.rs b/generated/stripe_shared/src/transfer_reversal.rs index 7c3f201f6..f689e90cd 100644 --- a/generated/stripe_shared/src/transfer_reversal.rs +++ b/generated/stripe_shared/src/transfer_reversal.rs @@ -13,7 +13,9 @@ /// Related guide: [Reversing transfers](https://stripe.com/docs/connect/separate-charges-and-transfers#reversing-transfers). /// /// For more details see <<https://stripe.com/docs/api/transfer_reversals/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TransferReversal { /// Amount, in cents (or local equivalent). pub amount: i64, @@ -36,6 +38,134 @@ pub struct TransferReversal { /// ID of the transfer that was reversed. pub transfer: stripe_types::Expandable<stripe_shared::Transfer>, } +#[cfg(feature = "min-ser")] +pub struct TransferReversalBuilder { + amount: Option<i64>, + balance_transaction: Option<Option<stripe_types::Expandable<stripe_shared::BalanceTransaction>>>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + destination_payment_refund: Option<Option<stripe_types::Expandable<stripe_shared::Refund>>>, + id: Option<stripe_shared::TransferReversalId>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + source_refund: Option<Option<stripe_types::Expandable<stripe_shared::Refund>>>, + transfer: Option<stripe_types::Expandable<stripe_shared::Transfer>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TransferReversal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TransferReversal>, + builder: TransferReversalBuilder, + } + + impl Visitor for Place<TransferReversal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TransferReversalBuilder::deser_default() })) + } + } + + impl MapBuilder for TransferReversalBuilder { + type Out = TransferReversal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "destination_payment_refund" => Deserialize::begin(&mut self.destination_payment_refund), + "id" => Deserialize::begin(&mut self.id), + "metadata" => Deserialize::begin(&mut self.metadata), + "source_refund" => Deserialize::begin(&mut self.source_refund), + "transfer" => Deserialize::begin(&mut self.transfer), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + balance_transaction: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + destination_payment_refund: Deserialize::default(), + id: Deserialize::default(), + metadata: Deserialize::default(), + source_refund: Deserialize::default(), + transfer: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let balance_transaction = self.balance_transaction.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let destination_payment_refund = self.destination_payment_refund.take()?; + let id = self.id.take()?; + let metadata = self.metadata.take()?; + let source_refund = self.source_refund.take()?; + let transfer = self.transfer.take()?; + + Some(Self::Out { amount, balance_transaction, created, currency, destination_payment_refund, id, metadata, source_refund, transfer }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TransferReversal { + type Builder = TransferReversalBuilder; + } + + impl FromValueOpt for TransferReversal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TransferReversalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "balance_transaction" => b.balance_transaction = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "destination_payment_refund" => b.destination_payment_refund = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "source_refund" => b.source_refund = Some(FromValueOpt::from_value(v)?), + "transfer" => b.transfer = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TransferReversal { type Id = stripe_shared::TransferReversalId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_shared/src/transfer_schedule.rs b/generated/stripe_shared/src/transfer_schedule.rs index 9bb3a27a0..bd7ce3534 100644 --- a/generated/stripe_shared/src/transfer_schedule.rs +++ b/generated/stripe_shared/src/transfer_schedule.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TransferSchedule { /// The number of days charges for the account will be held before being paid out. pub delay_days: u32, @@ -8,10 +10,106 @@ pub struct TransferSchedule { /// The day of the month funds will be paid out. /// Only shown if `interval` is monthly. /// Payouts scheduled between the 29th and 31st of the month are sent on the last day of shorter months. - #[serde(skip_serializing_if = "Option::is_none")] pub monthly_anchor: Option<u8>, /// The day of the week funds will be paid out, of the style 'monday', 'tuesday', etc. /// Only shown if `interval` is weekly. - #[serde(skip_serializing_if = "Option::is_none")] pub weekly_anchor: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TransferScheduleBuilder { + delay_days: Option<u32>, + interval: Option<String>, + monthly_anchor: Option<Option<u8>>, + weekly_anchor: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TransferSchedule { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TransferSchedule>, + builder: TransferScheduleBuilder, + } + + impl Visitor for Place<TransferSchedule> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TransferScheduleBuilder::deser_default() })) + } + } + + impl MapBuilder for TransferScheduleBuilder { + type Out = TransferSchedule; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "delay_days" => Deserialize::begin(&mut self.delay_days), + "interval" => Deserialize::begin(&mut self.interval), + "monthly_anchor" => Deserialize::begin(&mut self.monthly_anchor), + "weekly_anchor" => Deserialize::begin(&mut self.weekly_anchor), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { delay_days: Deserialize::default(), interval: Deserialize::default(), monthly_anchor: Deserialize::default(), weekly_anchor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let delay_days = self.delay_days.take()?; + let interval = self.interval.take()?; + let monthly_anchor = self.monthly_anchor.take()?; + let weekly_anchor = self.weekly_anchor.take()?; + + Some(Self::Out { delay_days, interval, monthly_anchor, weekly_anchor }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TransferSchedule { + type Builder = TransferScheduleBuilder; + } + + impl FromValueOpt for TransferSchedule { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TransferScheduleBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "delay_days" => b.delay_days = Some(FromValueOpt::from_value(v)?), + "interval" => b.interval = Some(FromValueOpt::from_value(v)?), + "monthly_anchor" => b.monthly_anchor = Some(FromValueOpt::from_value(v)?), + "weekly_anchor" => b.weekly_anchor = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/transform_quantity.rs b/generated/stripe_shared/src/transform_quantity.rs index badb1f107..a4aaeb884 100644 --- a/generated/stripe_shared/src/transform_quantity.rs +++ b/generated/stripe_shared/src/transform_quantity.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TransformQuantity { /// Divide usage by this number. pub divide_by: i64, /// After division, either round the result `up` or `down`. pub round: TransformQuantityRound, } +#[cfg(feature = "min-ser")] +pub struct TransformQuantityBuilder { + divide_by: Option<i64>, + round: Option<TransformQuantityRound>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TransformQuantity { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TransformQuantity>, + builder: TransformQuantityBuilder, + } + + impl Visitor for Place<TransformQuantity> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TransformQuantityBuilder::deser_default() })) + } + } + + impl MapBuilder for TransformQuantityBuilder { + type Out = TransformQuantity; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "divide_by" => Deserialize::begin(&mut self.divide_by), + "round" => Deserialize::begin(&mut self.round), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { divide_by: Deserialize::default(), round: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let divide_by = self.divide_by.take()?; + let round = self.round.take()?; + + Some(Self::Out { divide_by, round }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TransformQuantity { + type Builder = TransformQuantityBuilder; + } + + impl FromValueOpt for TransformQuantity { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TransformQuantityBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "divide_by" => b.divide_by = Some(FromValueOpt::from_value(v)?), + "round" => b.round = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// After division, either round the result `up` or `down`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TransformQuantityRound { @@ -55,7 +147,24 @@ impl<'de> serde::Deserialize<'de> for TransformQuantityRound { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TransformQuantityRound")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TransformQuantityRound")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TransformQuantityRound { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TransformQuantityRound> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TransformQuantityRound::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TransformQuantityRound); diff --git a/generated/stripe_shared/src/transform_usage.rs b/generated/stripe_shared/src/transform_usage.rs index 4b27d3e7d..12bf71748 100644 --- a/generated/stripe_shared/src/transform_usage.rs +++ b/generated/stripe_shared/src/transform_usage.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TransformUsage { /// Divide usage by this number. pub divide_by: i64, /// After division, either round the result `up` or `down`. pub round: TransformUsageRound, } +#[cfg(feature = "min-ser")] +pub struct TransformUsageBuilder { + divide_by: Option<i64>, + round: Option<TransformUsageRound>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TransformUsage { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TransformUsage>, + builder: TransformUsageBuilder, + } + + impl Visitor for Place<TransformUsage> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TransformUsageBuilder::deser_default() })) + } + } + + impl MapBuilder for TransformUsageBuilder { + type Out = TransformUsage; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "divide_by" => Deserialize::begin(&mut self.divide_by), + "round" => Deserialize::begin(&mut self.round), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { divide_by: Deserialize::default(), round: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let divide_by = self.divide_by.take()?; + let round = self.round.take()?; + + Some(Self::Out { divide_by, round }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TransformUsage { + type Builder = TransformUsageBuilder; + } + + impl FromValueOpt for TransformUsage { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TransformUsageBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "divide_by" => b.divide_by = Some(FromValueOpt::from_value(v)?), + "round" => b.round = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// After division, either round the result `up` or `down`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TransformUsageRound { @@ -55,7 +147,24 @@ impl<'de> serde::Deserialize<'de> for TransformUsageRound { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TransformUsageRound")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TransformUsageRound")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TransformUsageRound { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TransformUsageRound> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TransformUsageRound::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TransformUsageRound); diff --git a/generated/stripe_shared/src/us_bank_account_networks.rs b/generated/stripe_shared/src/us_bank_account_networks.rs index 987f23aea..8b756d69b 100644 --- a/generated/stripe_shared/src/us_bank_account_networks.rs +++ b/generated/stripe_shared/src/us_bank_account_networks.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct UsBankAccountNetworks { /// The preferred network. pub preferred: Option<String>, /// All supported networks. pub supported: Vec<UsBankAccountNetworksSupported>, } +#[cfg(feature = "min-ser")] +pub struct UsBankAccountNetworksBuilder { + preferred: Option<Option<String>>, + supported: Option<Vec<UsBankAccountNetworksSupported>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for UsBankAccountNetworks { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<UsBankAccountNetworks>, + builder: UsBankAccountNetworksBuilder, + } + + impl Visitor for Place<UsBankAccountNetworks> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: UsBankAccountNetworksBuilder::deser_default() })) + } + } + + impl MapBuilder for UsBankAccountNetworksBuilder { + type Out = UsBankAccountNetworks; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "preferred" => Deserialize::begin(&mut self.preferred), + "supported" => Deserialize::begin(&mut self.supported), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { preferred: Deserialize::default(), supported: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let preferred = self.preferred.take()?; + let supported = self.supported.take()?; + + Some(Self::Out { preferred, supported }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for UsBankAccountNetworks { + type Builder = UsBankAccountNetworksBuilder; + } + + impl FromValueOpt for UsBankAccountNetworks { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = UsBankAccountNetworksBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "preferred" => b.preferred = Some(FromValueOpt::from_value(v)?), + "supported" => b.supported = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// All supported networks. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UsBankAccountNetworksSupported { @@ -55,8 +147,24 @@ impl<'de> serde::Deserialize<'de> for UsBankAccountNetworksSupported { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for UsBankAccountNetworksSupported") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for UsBankAccountNetworksSupported")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for UsBankAccountNetworksSupported { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<UsBankAccountNetworksSupported> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(UsBankAccountNetworksSupported::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(UsBankAccountNetworksSupported); diff --git a/generated/stripe_shared/src/usage_record_summary.rs b/generated/stripe_shared/src/usage_record_summary.rs index 2b9343648..424a40748 100644 --- a/generated/stripe_shared/src/usage_record_summary.rs +++ b/generated/stripe_shared/src/usage_record_summary.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct UsageRecordSummary { /// Unique identifier for the object. pub id: stripe_shared::UsageRecordSummaryId, @@ -12,6 +14,119 @@ pub struct UsageRecordSummary { /// The total usage within this usage period. pub total_usage: i64, } +#[cfg(feature = "min-ser")] +pub struct UsageRecordSummaryBuilder { + id: Option<stripe_shared::UsageRecordSummaryId>, + invoice: Option<Option<String>>, + livemode: Option<bool>, + period: Option<stripe_shared::Period>, + subscription_item: Option<String>, + total_usage: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for UsageRecordSummary { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<UsageRecordSummary>, + builder: UsageRecordSummaryBuilder, + } + + impl Visitor for Place<UsageRecordSummary> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: UsageRecordSummaryBuilder::deser_default() })) + } + } + + impl MapBuilder for UsageRecordSummaryBuilder { + type Out = UsageRecordSummary; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "invoice" => Deserialize::begin(&mut self.invoice), + "livemode" => Deserialize::begin(&mut self.livemode), + "period" => Deserialize::begin(&mut self.period), + "subscription_item" => Deserialize::begin(&mut self.subscription_item), + "total_usage" => Deserialize::begin(&mut self.total_usage), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + invoice: Deserialize::default(), + livemode: Deserialize::default(), + period: Deserialize::default(), + subscription_item: Deserialize::default(), + total_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let invoice = self.invoice.take()?; + let livemode = self.livemode.take()?; + let period = self.period.take()?; + let subscription_item = self.subscription_item.take()?; + let total_usage = self.total_usage.take()?; + + Some(Self::Out { id, invoice, livemode, period, subscription_item, total_usage }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for UsageRecordSummary { + type Builder = UsageRecordSummaryBuilder; + } + + impl FromValueOpt for UsageRecordSummary { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = UsageRecordSummaryBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "invoice" => b.invoice = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "period" => b.period = Some(FromValueOpt::from_value(v)?), + "subscription_item" => b.subscription_item = Some(FromValueOpt::from_value(v)?), + "total_usage" => b.total_usage = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for UsageRecordSummary { type Id = stripe_shared::UsageRecordSummaryId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_terminal/.rustfmt.toml b/generated/stripe_terminal/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_terminal/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_terminal/Cargo.toml b/generated/stripe_terminal/Cargo.toml index 04def9be3..5145e13c1 100644 --- a/generated/stripe_terminal/Cargo.toml +++ b/generated/stripe_terminal/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_terminal/src/deleted_terminal_configuration.rs b/generated/stripe_terminal/src/deleted_terminal_configuration.rs index 742ca8d5c..227c0b630 100644 --- a/generated/stripe_terminal/src/deleted_terminal_configuration.rs +++ b/generated/stripe_terminal/src/deleted_terminal_configuration.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedTerminalConfiguration { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_terminal::TerminalConfigurationId, } +#[cfg(feature = "min-ser")] +pub struct DeletedTerminalConfigurationBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_terminal::TerminalConfigurationId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedTerminalConfiguration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedTerminalConfiguration>, + builder: DeletedTerminalConfigurationBuilder, + } + + impl Visitor for Place<DeletedTerminalConfiguration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedTerminalConfigurationBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedTerminalConfigurationBuilder { + type Out = DeletedTerminalConfiguration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedTerminalConfiguration { + type Builder = DeletedTerminalConfigurationBuilder; + } + + impl FromValueOpt for DeletedTerminalConfiguration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedTerminalConfigurationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedTerminalConfiguration { type Id = stripe_terminal::TerminalConfigurationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_terminal/src/deleted_terminal_location.rs b/generated/stripe_terminal/src/deleted_terminal_location.rs index e60106201..3357b3952 100644 --- a/generated/stripe_terminal/src/deleted_terminal_location.rs +++ b/generated/stripe_terminal/src/deleted_terminal_location.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedTerminalLocation { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_terminal::TerminalLocationId, } +#[cfg(feature = "min-ser")] +pub struct DeletedTerminalLocationBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_terminal::TerminalLocationId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedTerminalLocation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedTerminalLocation>, + builder: DeletedTerminalLocationBuilder, + } + + impl Visitor for Place<DeletedTerminalLocation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedTerminalLocationBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedTerminalLocationBuilder { + type Out = DeletedTerminalLocation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedTerminalLocation { + type Builder = DeletedTerminalLocationBuilder; + } + + impl FromValueOpt for DeletedTerminalLocation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedTerminalLocationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedTerminalLocation { type Id = stripe_terminal::TerminalLocationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_terminal/src/deleted_terminal_reader.rs b/generated/stripe_terminal/src/deleted_terminal_reader.rs index 9143214e1..9bd00a2d7 100644 --- a/generated/stripe_terminal/src/deleted_terminal_reader.rs +++ b/generated/stripe_terminal/src/deleted_terminal_reader.rs @@ -1,10 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct DeletedTerminalReader { /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_terminal::TerminalReaderId, } +#[cfg(feature = "min-ser")] +pub struct DeletedTerminalReaderBuilder { + deleted: Option<stripe_types::AlwaysTrue>, + id: Option<stripe_terminal::TerminalReaderId>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DeletedTerminalReader { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<DeletedTerminalReader>, + builder: DeletedTerminalReaderBuilder, + } + + impl Visitor for Place<DeletedTerminalReader> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: DeletedTerminalReaderBuilder::deser_default() })) + } + } + + impl MapBuilder for DeletedTerminalReaderBuilder { + type Out = DeletedTerminalReader; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deleted" => Deserialize::begin(&mut self.deleted), + "id" => Deserialize::begin(&mut self.id), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deleted: Deserialize::default(), id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deleted = self.deleted.take()?; + let id = self.id.take()?; + + Some(Self::Out { deleted, id }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for DeletedTerminalReader { + type Builder = DeletedTerminalReaderBuilder; + } + + impl FromValueOpt for DeletedTerminalReader { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DeletedTerminalReaderBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deleted" => b.deleted = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for DeletedTerminalReader { type Id = stripe_terminal::TerminalReaderId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_terminal/src/mod.rs b/generated/stripe_terminal/src/mod.rs index 854cc8cf1..eaf439654 100644 --- a/generated/stripe_terminal/src/mod.rs +++ b/generated/stripe_terminal/src/mod.rs @@ -7,6 +7,9 @@ //! for requests mentioned in the `Terminal` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_terminal; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); #[doc(hidden)] pub mod deleted_terminal_configuration; #[doc(inline)] diff --git a/generated/stripe_terminal/src/terminal_configuration/requests.rs b/generated/stripe_terminal/src/terminal_configuration/requests.rs index 25cbf531c..6cfa7b3b5 100644 --- a/generated/stripe_terminal/src/terminal_configuration/requests.rs +++ b/generated/stripe_terminal/src/terminal_configuration/requests.rs @@ -1,22 +1,54 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteTerminalConfiguration {} -impl DeleteTerminalConfiguration { +pub struct CreateTerminalConfiguration<'a> { + /// An object containing device type specific settings for BBPOS WisePOS E readers + #[serde(skip_serializing_if = "Option::is_none")] + pub bbpos_wisepos_e: Option<CreateTerminalConfigurationBbposWiseposE<'a>>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Configurations for collecting transactions offline. + #[serde(skip_serializing_if = "Option::is_none")] + pub offline: Option<Offline>, + /// Tipping configurations for readers supporting on-reader tips + #[serde(skip_serializing_if = "Option::is_none")] + pub tipping: Option<Tipping<'a>>, + /// An object containing device type specific settings for Verifone P400 readers + #[serde(skip_serializing_if = "Option::is_none")] + pub verifone_p400: Option<CreateTerminalConfigurationVerifoneP400<'a>>, +} +impl<'a> CreateTerminalConfiguration<'a> { pub fn new() -> Self { Self::default() } } -impl DeleteTerminalConfiguration { - /// Deletes a `Configuration` object. - pub fn send( - &self, - client: &stripe::Client, - configuration: &stripe_terminal::TerminalConfigurationId, - ) -> stripe::Response<stripe_terminal::DeletedTerminalConfiguration> { - client.send_form( - &format!("/terminal/configurations/{configuration}"), - self, - http_types::Method::Delete, - ) +/// An object containing device type specific settings for BBPOS WisePOS E readers +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreateTerminalConfigurationBbposWiseposE<'a> { + /// A File ID representing an image you would like displayed on the reader. + #[serde(skip_serializing_if = "Option::is_none")] + pub splashscreen: Option<&'a str>, +} +impl<'a> CreateTerminalConfigurationBbposWiseposE<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// An object containing device type specific settings for Verifone P400 readers +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreateTerminalConfigurationVerifoneP400<'a> { + /// A File ID representing an image you would like displayed on the reader. + #[serde(skip_serializing_if = "Option::is_none")] + pub splashscreen: Option<&'a str>, +} +impl<'a> CreateTerminalConfigurationVerifoneP400<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> CreateTerminalConfiguration<'a> { + /// Creates a new `Configuration` object. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_terminal::TerminalConfiguration> { + client.send_form("/terminal/configurations", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -49,15 +81,10 @@ impl<'a> ListTerminalConfiguration<'a> { } impl<'a> ListTerminalConfiguration<'a> { /// Returns a list of `Configuration` objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_terminal::TerminalConfiguration>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_terminal::TerminalConfiguration>> { client.get_query("/terminal/configurations", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_terminal::TerminalConfiguration>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_terminal::TerminalConfiguration>> { stripe::ListPaginator::from_list_params("/terminal/configurations", self) } } @@ -74,76 +101,90 @@ impl<'a> RetrieveTerminalConfiguration<'a> { } impl<'a> RetrieveTerminalConfiguration<'a> { /// Retrieves a `Configuration` object. - pub fn send( - &self, - client: &stripe::Client, - configuration: &stripe_terminal::TerminalConfigurationId, - ) -> stripe::Response<RetrieveTerminalConfigurationReturned> { + pub fn send(&self, client: &stripe::Client, configuration: &stripe_terminal::TerminalConfigurationId) -> stripe::Response<RetrieveTerminalConfigurationReturned> { client.get_query(&format!("/terminal/configurations/{configuration}"), self) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum RetrieveTerminalConfigurationReturned { TerminalConfiguration(stripe_terminal::TerminalConfiguration), DeletedTerminalConfiguration(stripe_terminal::DeletedTerminalConfiguration), } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateTerminalConfiguration<'a> { - /// An object containing device type specific settings for BBPOS WisePOS E readers - #[serde(skip_serializing_if = "Option::is_none")] - pub bbpos_wisepos_e: Option<CreateTerminalConfigurationBbposWiseposE<'a>>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Configurations for collecting transactions offline. - #[serde(skip_serializing_if = "Option::is_none")] - pub offline: Option<Offline>, - /// Tipping configurations for readers supporting on-reader tips - #[serde(skip_serializing_if = "Option::is_none")] - pub tipping: Option<Tipping<'a>>, - /// An object containing device type specific settings for Verifone P400 readers - #[serde(skip_serializing_if = "Option::is_none")] - pub verifone_p400: Option<CreateTerminalConfigurationVerifoneP400<'a>>, + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct RetrieveTerminalConfigurationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, } -impl<'a> CreateTerminalConfiguration<'a> { - pub fn new() -> Self { - Self::default() + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<RetrieveTerminalConfigurationReturned>, + builder: RetrieveTerminalConfigurationReturnedBuilder, } -} -/// An object containing device type specific settings for BBPOS WisePOS E readers -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateTerminalConfigurationBbposWiseposE<'a> { - /// A File ID representing an image you would like displayed on the reader. - #[serde(skip_serializing_if = "Option::is_none")] - pub splashscreen: Option<&'a str>, -} -impl<'a> CreateTerminalConfigurationBbposWiseposE<'a> { - pub fn new() -> Self { - Self::default() + + impl Deserialize for RetrieveTerminalConfigurationReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } } -} -/// An object containing device type specific settings for Verifone P400 readers -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateTerminalConfigurationVerifoneP400<'a> { - /// A File ID representing an image you would like displayed on the reader. - #[serde(skip_serializing_if = "Option::is_none")] - pub splashscreen: Option<&'a str>, -} -impl<'a> CreateTerminalConfigurationVerifoneP400<'a> { - pub fn new() -> Self { - Self::default() + + impl Visitor for Place<RetrieveTerminalConfigurationReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } } -} -impl<'a> CreateTerminalConfiguration<'a> { - /// Creates a new `Configuration` object. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_terminal::TerminalConfiguration> { - client.send_form("/terminal/configurations", self, http_types::Method::Post) + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } } -} + + impl MapBuilder for RetrieveTerminalConfigurationReturnedBuilder { + type Out = RetrieveTerminalConfigurationReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + RetrieveTerminalConfigurationReturned::DeletedTerminalConfiguration(FromValueOpt::from_value(Value::Object(o))?) + } else { + RetrieveTerminalConfigurationReturned::TerminalConfiguration(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for RetrieveTerminalConfigurationReturned { + type Builder = RetrieveTerminalConfigurationReturnedBuilder; + } +}; + #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateTerminalConfiguration<'a> { /// An object containing device type specific settings for BBPOS WisePOS E readers @@ -193,24 +234,103 @@ impl<'a> UpdateTerminalConfigurationVerifoneP400<'a> { } impl<'a> UpdateTerminalConfiguration<'a> { /// Updates a new `Configuration` object. - pub fn send( - &self, - client: &stripe::Client, - configuration: &stripe_terminal::TerminalConfigurationId, - ) -> stripe::Response<UpdateTerminalConfigurationReturned> { - client.send_form( - &format!("/terminal/configurations/{configuration}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, configuration: &stripe_terminal::TerminalConfigurationId) -> stripe::Response<UpdateTerminalConfigurationReturned> { + client.send_form(&format!("/terminal/configurations/{configuration}"), self, http_types::Method::Post) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum UpdateTerminalConfigurationReturned { TerminalConfiguration(stripe_terminal::TerminalConfiguration), DeletedTerminalConfiguration(stripe_terminal::DeletedTerminalConfiguration), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct UpdateTerminalConfigurationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<UpdateTerminalConfigurationReturned>, + builder: UpdateTerminalConfigurationReturnedBuilder, + } + + impl Deserialize for UpdateTerminalConfigurationReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<UpdateTerminalConfigurationReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for UpdateTerminalConfigurationReturnedBuilder { + type Out = UpdateTerminalConfigurationReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + UpdateTerminalConfigurationReturned::DeletedTerminalConfiguration(FromValueOpt::from_value(Value::Object(o))?) + } else { + UpdateTerminalConfigurationReturned::TerminalConfiguration(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for UpdateTerminalConfigurationReturned { + type Builder = UpdateTerminalConfigurationReturnedBuilder; + } +}; + +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteTerminalConfiguration {} +impl DeleteTerminalConfiguration { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteTerminalConfiguration { + /// Deletes a `Configuration` object. + pub fn send(&self, client: &stripe::Client, configuration: &stripe_terminal::TerminalConfigurationId) -> stripe::Response<stripe_terminal::DeletedTerminalConfiguration> { + client.send_form(&format!("/terminal/configurations/{configuration}"), self, http_types::Method::Delete) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct Offline { /// Determines whether to allow transactions to be collected while reader is offline. diff --git a/generated/stripe_terminal/src/terminal_configuration/types.rs b/generated/stripe_terminal/src/terminal_configuration/types.rs index 4a3cf4abb..3bb313656 100644 --- a/generated/stripe_terminal/src/terminal_configuration/types.rs +++ b/generated/stripe_terminal/src/terminal_configuration/types.rs @@ -1,25 +1,139 @@ /// A Configurations object represents how features should be configured for terminal readers. /// /// For more details see <<https://stripe.com/docs/api/terminal/configuration/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalConfiguration { - #[serde(skip_serializing_if = "Option::is_none")] - pub bbpos_wisepos_e: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig>, + pub bbpos_wisepos_e: Option<stripe_terminal::TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig>, /// Unique identifier for the object. pub id: stripe_terminal::TerminalConfigurationId, /// Whether this Configuration is the default for your account pub is_account_default: Option<bool>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub offline: Option<stripe_terminal::TerminalConfigurationConfigurationResourceOfflineConfig>, - #[serde(skip_serializing_if = "Option::is_none")] pub tipping: Option<stripe_terminal::TerminalConfigurationConfigurationResourceTipping>, - #[serde(skip_serializing_if = "Option::is_none")] - pub verifone_p400: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig>, + pub verifone_p400: Option<stripe_terminal::TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig>, } +#[cfg(feature = "min-ser")] +pub struct TerminalConfigurationBuilder { + bbpos_wisepos_e: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig>>, + id: Option<stripe_terminal::TerminalConfigurationId>, + is_account_default: Option<Option<bool>>, + livemode: Option<bool>, + offline: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceOfflineConfig>>, + tipping: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceTipping>>, + verifone_p400: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalConfiguration { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalConfiguration>, + builder: TerminalConfigurationBuilder, + } + + impl Visitor for Place<TerminalConfiguration> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalConfigurationBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalConfigurationBuilder { + type Out = TerminalConfiguration; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bbpos_wisepos_e" => Deserialize::begin(&mut self.bbpos_wisepos_e), + "id" => Deserialize::begin(&mut self.id), + "is_account_default" => Deserialize::begin(&mut self.is_account_default), + "livemode" => Deserialize::begin(&mut self.livemode), + "offline" => Deserialize::begin(&mut self.offline), + "tipping" => Deserialize::begin(&mut self.tipping), + "verifone_p400" => Deserialize::begin(&mut self.verifone_p400), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bbpos_wisepos_e: Deserialize::default(), + id: Deserialize::default(), + is_account_default: Deserialize::default(), + livemode: Deserialize::default(), + offline: Deserialize::default(), + tipping: Deserialize::default(), + verifone_p400: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bbpos_wisepos_e = self.bbpos_wisepos_e.take()?; + let id = self.id.take()?; + let is_account_default = self.is_account_default.take()?; + let livemode = self.livemode.take()?; + let offline = self.offline.take()?; + let tipping = self.tipping.take()?; + let verifone_p400 = self.verifone_p400.take()?; + + Some(Self::Out { bbpos_wisepos_e, id, is_account_default, livemode, offline, tipping, verifone_p400 }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalConfiguration { + type Builder = TerminalConfigurationBuilder; + } + + impl FromValueOpt for TerminalConfiguration { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalConfigurationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bbpos_wisepos_e" => b.bbpos_wisepos_e = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "is_account_default" => b.is_account_default = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "offline" => b.offline = Some(FromValueOpt::from_value(v)?), + "tipping" => b.tipping = Some(FromValueOpt::from_value(v)?), + "verifone_p400" => b.verifone_p400 = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TerminalConfiguration { type Id = stripe_terminal::TerminalConfigurationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_currency_specific_config.rs b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_currency_specific_config.rs index 8b850cb67..6a9c3b2dc 100644 --- a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_currency_specific_config.rs +++ b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_currency_specific_config.rs @@ -1,12 +1,105 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalConfigurationConfigurationResourceCurrencySpecificConfig { /// Fixed amounts displayed when collecting a tip - #[serde(skip_serializing_if = "Option::is_none")] pub fixed_amounts: Option<Vec<i64>>, /// Percentages displayed when collecting a tip - #[serde(skip_serializing_if = "Option::is_none")] pub percentages: Option<Vec<i64>>, /// Below this amount, fixed amounts will be displayed; above it, percentages will be displayed - #[serde(skip_serializing_if = "Option::is_none")] pub smart_tip_threshold: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder { + fixed_amounts: Option<Option<Vec<i64>>>, + percentages: Option<Option<Vec<i64>>>, + smart_tip_threshold: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalConfigurationConfigurationResourceCurrencySpecificConfig { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + builder: TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder, + } + + impl Visitor for Place<TerminalConfigurationConfigurationResourceCurrencySpecificConfig> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder { + type Out = TerminalConfigurationConfigurationResourceCurrencySpecificConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "fixed_amounts" => Deserialize::begin(&mut self.fixed_amounts), + "percentages" => Deserialize::begin(&mut self.percentages), + "smart_tip_threshold" => Deserialize::begin(&mut self.smart_tip_threshold), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { fixed_amounts: Deserialize::default(), percentages: Deserialize::default(), smart_tip_threshold: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let fixed_amounts = self.fixed_amounts.take()?; + let percentages = self.percentages.take()?; + let smart_tip_threshold = self.smart_tip_threshold.take()?; + + Some(Self::Out { fixed_amounts, percentages, smart_tip_threshold }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalConfigurationConfigurationResourceCurrencySpecificConfig { + type Builder = TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder; + } + + impl FromValueOpt for TerminalConfigurationConfigurationResourceCurrencySpecificConfig { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "fixed_amounts" => b.fixed_amounts = Some(FromValueOpt::from_value(v)?), + "percentages" => b.percentages = Some(FromValueOpt::from_value(v)?), + "smart_tip_threshold" => b.smart_tip_threshold = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_device_type_specific_config.rs b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_device_type_specific_config.rs index 7ac2f16cd..aaf1aa427 100644 --- a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_device_type_specific_config.rs +++ b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_device_type_specific_config.rs @@ -1,6 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig { /// A File ID representing an image you would like displayed on the reader. - #[serde(skip_serializing_if = "Option::is_none")] pub splashscreen: Option<stripe_types::Expandable<stripe_shared::File>>, } +#[cfg(feature = "min-ser")] +pub struct TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder { + splashscreen: Option<Option<stripe_types::Expandable<stripe_shared::File>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig>, + builder: TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder, + } + + impl Visitor for Place<TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder { + type Out = TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "splashscreen" => Deserialize::begin(&mut self.splashscreen), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { splashscreen: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let splashscreen = self.splashscreen.take()?; + + Some(Self::Out { splashscreen }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig { + type Builder = TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder; + } + + impl FromValueOpt for TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfig { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "splashscreen" => b.splashscreen = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_offline_config.rs b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_offline_config.rs index 3f97bc4f6..fb6e760f1 100644 --- a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_offline_config.rs +++ b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_offline_config.rs @@ -1,6 +1,94 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalConfigurationConfigurationResourceOfflineConfig { /// Determines whether to allow transactions to be collected while reader is offline. /// Defaults to false. pub enabled: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct TerminalConfigurationConfigurationResourceOfflineConfigBuilder { + enabled: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalConfigurationConfigurationResourceOfflineConfig { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalConfigurationConfigurationResourceOfflineConfig>, + builder: TerminalConfigurationConfigurationResourceOfflineConfigBuilder, + } + + impl Visitor for Place<TerminalConfigurationConfigurationResourceOfflineConfig> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalConfigurationConfigurationResourceOfflineConfigBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalConfigurationConfigurationResourceOfflineConfigBuilder { + type Out = TerminalConfigurationConfigurationResourceOfflineConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let enabled = self.enabled.take()?; + + Some(Self::Out { enabled }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalConfigurationConfigurationResourceOfflineConfig { + type Builder = TerminalConfigurationConfigurationResourceOfflineConfigBuilder; + } + + impl FromValueOpt for TerminalConfigurationConfigurationResourceOfflineConfig { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalConfigurationConfigurationResourceOfflineConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_tipping.rs b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_tipping.rs index 92a96136f..f2b91035c 100644 --- a/generated/stripe_terminal/src/terminal_configuration_configuration_resource_tipping.rs +++ b/generated/stripe_terminal/src/terminal_configuration_configuration_resource_tipping.rs @@ -1,45 +1,172 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalConfigurationConfigurationResourceTipping { - #[serde(skip_serializing_if = "Option::is_none")] - pub aud: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub cad: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub chf: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub czk: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub dkk: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub eur: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub gbp: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub hkd: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub myr: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub nok: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub nzd: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub sek: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub sgd: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, - #[serde(skip_serializing_if = "Option::is_none")] - pub usd: - Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub aud: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub cad: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub chf: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub czk: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub dkk: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub eur: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub gbp: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub hkd: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub myr: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub nok: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub nzd: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub sek: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub sgd: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, + pub usd: Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>, } +#[cfg(feature = "min-ser")] +pub struct TerminalConfigurationConfigurationResourceTippingBuilder { + aud: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + cad: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + chf: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + czk: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + dkk: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + eur: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + gbp: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + hkd: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + myr: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + nok: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + nzd: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + sek: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + sgd: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, + usd: Option<Option<stripe_terminal::TerminalConfigurationConfigurationResourceCurrencySpecificConfig>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalConfigurationConfigurationResourceTipping { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalConfigurationConfigurationResourceTipping>, + builder: TerminalConfigurationConfigurationResourceTippingBuilder, + } + + impl Visitor for Place<TerminalConfigurationConfigurationResourceTipping> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalConfigurationConfigurationResourceTippingBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalConfigurationConfigurationResourceTippingBuilder { + type Out = TerminalConfigurationConfigurationResourceTipping; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "aud" => Deserialize::begin(&mut self.aud), + "cad" => Deserialize::begin(&mut self.cad), + "chf" => Deserialize::begin(&mut self.chf), + "czk" => Deserialize::begin(&mut self.czk), + "dkk" => Deserialize::begin(&mut self.dkk), + "eur" => Deserialize::begin(&mut self.eur), + "gbp" => Deserialize::begin(&mut self.gbp), + "hkd" => Deserialize::begin(&mut self.hkd), + "myr" => Deserialize::begin(&mut self.myr), + "nok" => Deserialize::begin(&mut self.nok), + "nzd" => Deserialize::begin(&mut self.nzd), + "sek" => Deserialize::begin(&mut self.sek), + "sgd" => Deserialize::begin(&mut self.sgd), + "usd" => Deserialize::begin(&mut self.usd), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + aud: Deserialize::default(), + cad: Deserialize::default(), + chf: Deserialize::default(), + czk: Deserialize::default(), + dkk: Deserialize::default(), + eur: Deserialize::default(), + gbp: Deserialize::default(), + hkd: Deserialize::default(), + myr: Deserialize::default(), + nok: Deserialize::default(), + nzd: Deserialize::default(), + sek: Deserialize::default(), + sgd: Deserialize::default(), + usd: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let aud = self.aud.take()?; + let cad = self.cad.take()?; + let chf = self.chf.take()?; + let czk = self.czk.take()?; + let dkk = self.dkk.take()?; + let eur = self.eur.take()?; + let gbp = self.gbp.take()?; + let hkd = self.hkd.take()?; + let myr = self.myr.take()?; + let nok = self.nok.take()?; + let nzd = self.nzd.take()?; + let sek = self.sek.take()?; + let sgd = self.sgd.take()?; + let usd = self.usd.take()?; + + Some(Self::Out { aud, cad, chf, czk, dkk, eur, gbp, hkd, myr, nok, nzd, sek, sgd, usd }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalConfigurationConfigurationResourceTipping { + type Builder = TerminalConfigurationConfigurationResourceTippingBuilder; + } + + impl FromValueOpt for TerminalConfigurationConfigurationResourceTipping { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalConfigurationConfigurationResourceTippingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "aud" => b.aud = Some(FromValueOpt::from_value(v)?), + "cad" => b.cad = Some(FromValueOpt::from_value(v)?), + "chf" => b.chf = Some(FromValueOpt::from_value(v)?), + "czk" => b.czk = Some(FromValueOpt::from_value(v)?), + "dkk" => b.dkk = Some(FromValueOpt::from_value(v)?), + "eur" => b.eur = Some(FromValueOpt::from_value(v)?), + "gbp" => b.gbp = Some(FromValueOpt::from_value(v)?), + "hkd" => b.hkd = Some(FromValueOpt::from_value(v)?), + "myr" => b.myr = Some(FromValueOpt::from_value(v)?), + "nok" => b.nok = Some(FromValueOpt::from_value(v)?), + "nzd" => b.nzd = Some(FromValueOpt::from_value(v)?), + "sek" => b.sek = Some(FromValueOpt::from_value(v)?), + "sgd" => b.sgd = Some(FromValueOpt::from_value(v)?), + "usd" => b.usd = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_connection_token/requests.rs b/generated/stripe_terminal/src/terminal_connection_token/requests.rs index f3e002140..e1ed810ae 100644 --- a/generated/stripe_terminal/src/terminal_connection_token/requests.rs +++ b/generated/stripe_terminal/src/terminal_connection_token/requests.rs @@ -18,10 +18,7 @@ impl<'a> CreateTerminalConnectionToken<'a> { impl<'a> CreateTerminalConnectionToken<'a> { /// To connect to a reader the Stripe Terminal SDK needs to retrieve a short-lived connection token from Stripe, proxied through your server. /// On your backend, add an endpoint that creates and returns a connection token. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_terminal::TerminalConnectionToken> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_terminal::TerminalConnectionToken> { client.send_form("/terminal/connection_tokens", self, http_types::Method::Post) } } diff --git a/generated/stripe_terminal/src/terminal_connection_token/types.rs b/generated/stripe_terminal/src/terminal_connection_token/types.rs index 4b10b55db..325851a46 100644 --- a/generated/stripe_terminal/src/terminal_connection_token/types.rs +++ b/generated/stripe_terminal/src/terminal_connection_token/types.rs @@ -3,13 +3,104 @@ /// Related guide: [Fleet management](https://stripe.com/docs/terminal/fleet/locations) /// /// For more details see <<https://stripe.com/docs/api/terminal/connection_tokens/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalConnectionToken { /// The id of the location that this connection token is scoped to. /// Note that location scoping only applies to internet-connected readers. /// For more details, see [the docs on scoping connection tokens](https://stripe.com/docs/terminal/fleet/locations#connection-tokens). - #[serde(skip_serializing_if = "Option::is_none")] pub location: Option<String>, /// Your application should pass this token to the Stripe Terminal SDK. pub secret: String, } +#[cfg(feature = "min-ser")] +pub struct TerminalConnectionTokenBuilder { + location: Option<Option<String>>, + secret: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalConnectionToken { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalConnectionToken>, + builder: TerminalConnectionTokenBuilder, + } + + impl Visitor for Place<TerminalConnectionToken> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalConnectionTokenBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalConnectionTokenBuilder { + type Out = TerminalConnectionToken; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "location" => Deserialize::begin(&mut self.location), + "secret" => Deserialize::begin(&mut self.secret), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { location: Deserialize::default(), secret: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let location = self.location.take()?; + let secret = self.secret.take()?; + + Some(Self::Out { location, secret }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalConnectionToken { + type Builder = TerminalConnectionTokenBuilder; + } + + impl FromValueOpt for TerminalConnectionToken { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalConnectionTokenBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "location" => b.location = Some(FromValueOpt::from_value(v)?), + "secret" => b.secret = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_location/requests.rs b/generated/stripe_terminal/src/terminal_location/requests.rs index 137fb10ce..8acbc4cbb 100644 --- a/generated/stripe_terminal/src/terminal_location/requests.rs +++ b/generated/stripe_terminal/src/terminal_location/requests.rs @@ -1,64 +1,4 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteTerminalLocation {} -impl DeleteTerminalLocation { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteTerminalLocation { - /// Deletes a `Location` object. - pub fn send( - &self, - client: &stripe::Client, - location: &stripe_terminal::TerminalLocationId, - ) -> stripe::Response<stripe_terminal::DeletedTerminalLocation> { - client.send_form( - &format!("/terminal/locations/{location}"), - self, - http_types::Method::Delete, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListTerminalLocation<'a> { - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListTerminalLocation<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListTerminalLocation<'a> { - /// Returns a list of `Location` objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_terminal::TerminalLocation>> { - client.get_query("/terminal/locations", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_terminal::TerminalLocation>> { - stripe::ListPaginator::from_list_params("/terminal/locations", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveTerminalLocation<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -71,20 +11,90 @@ impl<'a> RetrieveTerminalLocation<'a> { } impl<'a> RetrieveTerminalLocation<'a> { /// Retrieves a `Location` object. - pub fn send( - &self, - client: &stripe::Client, - location: &stripe_terminal::TerminalLocationId, - ) -> stripe::Response<RetrieveTerminalLocationReturned> { + pub fn send(&self, client: &stripe::Client, location: &stripe_terminal::TerminalLocationId) -> stripe::Response<RetrieveTerminalLocationReturned> { client.get_query(&format!("/terminal/locations/{location}"), self) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum RetrieveTerminalLocationReturned { TerminalLocation(stripe_terminal::TerminalLocation), DeletedTerminalLocation(stripe_terminal::DeletedTerminalLocation), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct RetrieveTerminalLocationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<RetrieveTerminalLocationReturned>, + builder: RetrieveTerminalLocationReturnedBuilder, + } + + impl Deserialize for RetrieveTerminalLocationReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<RetrieveTerminalLocationReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for RetrieveTerminalLocationReturnedBuilder { + type Out = RetrieveTerminalLocationReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + RetrieveTerminalLocationReturned::DeletedTerminalLocation(FromValueOpt::from_value(Value::Object(o))?) + } else { + RetrieveTerminalLocationReturned::TerminalLocation(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for RetrieveTerminalLocationReturned { + type Builder = RetrieveTerminalLocationReturnedBuilder; + } +}; + #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTerminalLocation<'a> { /// The full address of the location. @@ -138,10 +148,7 @@ impl<'a> CreateTerminalLocationAddress<'a> { impl<'a> CreateTerminalLocation<'a> { /// Creates a new `Location` object. /// For further details, including which address fields are required in each country, see the [Manage locations](https://stripe.com/docs/terminal/fleet/locations) guide. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_terminal::TerminalLocation> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_terminal::TerminalLocation> { client.send_form("/terminal/locations", self, http_types::Method::Post) } } @@ -201,17 +208,134 @@ impl<'a> UpdateTerminalLocationAddress<'a> { impl<'a> UpdateTerminalLocation<'a> { /// Updates a `Location` object by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - location: &stripe_terminal::TerminalLocationId, - ) -> stripe::Response<UpdateTerminalLocationReturned> { + pub fn send(&self, client: &stripe::Client, location: &stripe_terminal::TerminalLocationId) -> stripe::Response<UpdateTerminalLocationReturned> { client.send_form(&format!("/terminal/locations/{location}"), self, http_types::Method::Post) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum UpdateTerminalLocationReturned { TerminalLocation(stripe_terminal::TerminalLocation), DeletedTerminalLocation(stripe_terminal::DeletedTerminalLocation), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct UpdateTerminalLocationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<UpdateTerminalLocationReturned>, + builder: UpdateTerminalLocationReturnedBuilder, + } + + impl Deserialize for UpdateTerminalLocationReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<UpdateTerminalLocationReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for UpdateTerminalLocationReturnedBuilder { + type Out = UpdateTerminalLocationReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + UpdateTerminalLocationReturned::DeletedTerminalLocation(FromValueOpt::from_value(Value::Object(o))?) + } else { + UpdateTerminalLocationReturned::TerminalLocation(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for UpdateTerminalLocationReturned { + type Builder = UpdateTerminalLocationReturnedBuilder; + } +}; + +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListTerminalLocation<'a> { + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListTerminalLocation<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListTerminalLocation<'a> { + /// Returns a list of `Location` objects. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_terminal::TerminalLocation>> { + client.get_query("/terminal/locations", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_terminal::TerminalLocation>> { + stripe::ListPaginator::from_list_params("/terminal/locations", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteTerminalLocation {} +impl DeleteTerminalLocation { + pub fn new() -> Self { + Self::default() + } +} +impl DeleteTerminalLocation { + /// Deletes a `Location` object. + pub fn send(&self, client: &stripe::Client, location: &stripe_terminal::TerminalLocationId) -> stripe::Response<stripe_terminal::DeletedTerminalLocation> { + client.send_form(&format!("/terminal/locations/{location}"), self, http_types::Method::Delete) + } +} diff --git a/generated/stripe_terminal/src/terminal_location/types.rs b/generated/stripe_terminal/src/terminal_location/types.rs index d7762ef3a..2afe0a40a 100644 --- a/generated/stripe_terminal/src/terminal_location/types.rs +++ b/generated/stripe_terminal/src/terminal_location/types.rs @@ -3,11 +3,12 @@ /// Related guide: [Fleet management](https://stripe.com/docs/terminal/fleet/locations) /// /// For more details see <<https://stripe.com/docs/api/terminal/locations/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalLocation { pub address: stripe_shared::Address, /// The ID of a configuration that will be used to customize all readers in this location. - #[serde(skip_serializing_if = "Option::is_none")] pub configuration_overrides: Option<String>, /// The display name of the location. pub display_name: String, @@ -19,6 +20,119 @@ pub struct TerminalLocation { /// This can be useful for storing additional information about the object in a structured format. pub metadata: std::collections::HashMap<String, String>, } +#[cfg(feature = "min-ser")] +pub struct TerminalLocationBuilder { + address: Option<stripe_shared::Address>, + configuration_overrides: Option<Option<String>>, + display_name: Option<String>, + id: Option<stripe_terminal::TerminalLocationId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalLocation { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalLocation>, + builder: TerminalLocationBuilder, + } + + impl Visitor for Place<TerminalLocation> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalLocationBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalLocationBuilder { + type Out = TerminalLocation; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "configuration_overrides" => Deserialize::begin(&mut self.configuration_overrides), + "display_name" => Deserialize::begin(&mut self.display_name), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + configuration_overrides: Deserialize::default(), + display_name: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let configuration_overrides = self.configuration_overrides.take()?; + let display_name = self.display_name.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + + Some(Self::Out { address, configuration_overrides, display_name, id, livemode, metadata }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalLocation { + type Builder = TerminalLocationBuilder; + } + + impl FromValueOpt for TerminalLocation { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalLocationBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "configuration_overrides" => b.configuration_overrides = Some(FromValueOpt::from_value(v)?), + "display_name" => b.display_name = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TerminalLocation { type Id = stripe_terminal::TerminalLocationId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_terminal/src/terminal_reader/requests.rs b/generated/stripe_terminal/src/terminal_reader/requests.rs index 97b961716..ef3b8b5da 100644 --- a/generated/stripe_terminal/src/terminal_reader/requests.rs +++ b/generated/stripe_terminal/src/terminal_reader/requests.rs @@ -1,71 +1,110 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteTerminalReader {} -impl DeleteTerminalReader { - pub fn new() -> Self { - Self::default() - } -} -impl DeleteTerminalReader { - /// Deletes a `Reader` object. - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<stripe_terminal::DeletedTerminalReader> { - client.send_form(&format!("/terminal/readers/{reader}"), self, http_types::Method::Delete) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListTerminalReader<'a> { - /// Filters readers by device type - #[serde(skip_serializing_if = "Option::is_none")] - pub device_type: Option<stripe_terminal::TerminalReaderDeviceType>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, +pub struct UpdateTerminalReader<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A location ID to filter the response list to only readers at the specific location - #[serde(skip_serializing_if = "Option::is_none")] - pub location: Option<&'a str>, - /// Filters readers by serial number - #[serde(skip_serializing_if = "Option::is_none")] - pub serial_number: Option<&'a str>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + /// The new label of the reader. #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// A status filter to filter readers to only offline or online readers + pub label: Option<&'a str>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. #[serde(skip_serializing_if = "Option::is_none")] - pub status: Option<stripe_terminal::TerminalReaderStatus>, + pub metadata: Option<&'a std::collections::HashMap<String, String>>, } -impl<'a> ListTerminalReader<'a> { +impl<'a> UpdateTerminalReader<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> ListTerminalReader<'a> { - /// Returns a list of `Reader` objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_terminal::TerminalReader>> { - client.get_query("/terminal/readers", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_terminal::TerminalReader>> { - stripe::ListPaginator::from_list_params("/terminal/readers", self) +impl<'a> UpdateTerminalReader<'a> { + /// Updates a `Reader` object by setting the values of the parameters passed. + /// Any parameters not provided will be left unchanged. + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<UpdateTerminalReaderReturned> { + client.send_form(&format!("/terminal/readers/{reader}"), self, http_types::Method::Post) } } +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] +pub enum UpdateTerminalReaderReturned { + TerminalReader(stripe_terminal::TerminalReader), + DeletedTerminalReader(stripe_terminal::DeletedTerminalReader), +} + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct UpdateTerminalReaderReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<UpdateTerminalReaderReturned>, + builder: UpdateTerminalReaderReturnedBuilder, + } + + impl Deserialize for UpdateTerminalReaderReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<UpdateTerminalReaderReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for UpdateTerminalReaderReturnedBuilder { + type Out = UpdateTerminalReaderReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + UpdateTerminalReaderReturned::DeletedTerminalReader(FromValueOpt::from_value(Value::Object(o))?) + } else { + UpdateTerminalReaderReturned::TerminalReader(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for UpdateTerminalReaderReturned { + type Builder = UpdateTerminalReaderReturnedBuilder; + } +}; + #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct RetrieveTerminalReader<'a> { /// Specifies which fields in the response should be expanded. @@ -79,20 +118,90 @@ impl<'a> RetrieveTerminalReader<'a> { } impl<'a> RetrieveTerminalReader<'a> { /// Retrieves a `Reader` object. - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<RetrieveTerminalReaderReturned> { + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<RetrieveTerminalReaderReturned> { client.get_query(&format!("/terminal/readers/{reader}"), self) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(untagged))] pub enum RetrieveTerminalReaderReturned { TerminalReader(stripe_terminal::TerminalReader), DeletedTerminalReader(stripe_terminal::DeletedTerminalReader), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct RetrieveTerminalReaderReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<RetrieveTerminalReaderReturned>, + builder: RetrieveTerminalReaderReturnedBuilder, + } + + impl Deserialize for RetrieveTerminalReaderReturned { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<RetrieveTerminalReaderReturned> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for RetrieveTerminalReaderReturnedBuilder { + type Out = RetrieveTerminalReaderReturned; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted { + RetrieveTerminalReaderReturned::DeletedTerminalReader(FromValueOpt::from_value(Value::Object(o))?) + } else { + RetrieveTerminalReaderReturned::TerminalReader(FromValueOpt::from_value(Value::Object(o))?) + }) + } + } + + impl stripe_types::ObjectDeser for RetrieveTerminalReaderReturned { + type Builder = RetrieveTerminalReaderReturnedBuilder; + } +}; + #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTerminalReader<'a> { /// Specifies which fields in the response should be expanded. @@ -121,73 +230,113 @@ impl<'a> CreateTerminalReader<'a> { } impl<'a> CreateTerminalReader<'a> { /// Creates a new `Reader` object. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_terminal::TerminalReader> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_terminal::TerminalReader> { client.send_form("/terminal/readers", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateTerminalReader<'a> { +pub struct ListTerminalReader<'a> { + /// Filters readers by device type + #[serde(skip_serializing_if = "Option::is_none")] + pub device_type: Option<stripe_terminal::TerminalReaderDeviceType>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// The new label of the reader. + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. #[serde(skip_serializing_if = "Option::is_none")] - pub label: Option<&'a str>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. + pub limit: Option<i64>, + /// A location ID to filter the response list to only readers at the specific location #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, + pub location: Option<&'a str>, + /// Filters readers by serial number + #[serde(skip_serializing_if = "Option::is_none")] + pub serial_number: Option<&'a str>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// A status filter to filter readers to only offline or online readers + #[serde(skip_serializing_if = "Option::is_none")] + pub status: Option<ListTerminalReaderStatus>, } -impl<'a> UpdateTerminalReader<'a> { +impl<'a> ListTerminalReader<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> UpdateTerminalReader<'a> { - /// Updates a `Reader` object by setting the values of the parameters passed. - /// Any parameters not provided will be left unchanged. - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<UpdateTerminalReaderReturned> { - client.send_form(&format!("/terminal/readers/{reader}"), self, http_types::Method::Post) +/// A status filter to filter readers to only offline or online readers +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ListTerminalReaderStatus { + Offline, + Online, +} +impl ListTerminalReaderStatus { + pub fn as_str(self) -> &'static str { + use ListTerminalReaderStatus::*; + match self { + Offline => "offline", + Online => "online", + } } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] -pub enum UpdateTerminalReaderReturned { - TerminalReader(stripe_terminal::TerminalReader), - DeletedTerminalReader(stripe_terminal::DeletedTerminalReader), + +impl std::str::FromStr for ListTerminalReaderStatus { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use ListTerminalReaderStatus::*; + match s { + "offline" => Ok(Offline), + "online" => Ok(Online), + _ => Err(()), + } + } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelActionTerminalReader<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, +impl std::fmt::Display for ListTerminalReaderStatus { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } } -impl<'a> CancelActionTerminalReader<'a> { + +impl std::fmt::Debug for ListTerminalReaderStatus { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for ListTerminalReaderStatus { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> ListTerminalReader<'a> { + /// Returns a list of `Reader` objects. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_terminal::TerminalReader>> { + client.get_query("/terminal/readers", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_terminal::TerminalReader>> { + stripe::ListPaginator::from_list_params("/terminal/readers", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct DeleteTerminalReader {} +impl DeleteTerminalReader { pub fn new() -> Self { Self::default() } } -impl<'a> CancelActionTerminalReader<'a> { - /// Cancels the current reader action. - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<stripe_terminal::TerminalReader> { - client.send_form( - &format!("/terminal/readers/{reader}/cancel_action"), - self, - http_types::Method::Post, - ) +impl DeleteTerminalReader { + /// Deletes a `Reader` object. + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<stripe_terminal::DeletedTerminalReader> { + client.send_form(&format!("/terminal/readers/{reader}"), self, http_types::Method::Delete) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -236,16 +385,8 @@ impl ProcessPaymentIntentTerminalReaderProcessConfigTipping { } impl<'a> ProcessPaymentIntentTerminalReader<'a> { /// Initiates a payment flow on a Reader. - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<stripe_terminal::TerminalReader> { - client.send_form( - &format!("/terminal/readers/{reader}/process_payment_intent"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<stripe_terminal::TerminalReader> { + client.send_form(&format!("/terminal/readers/{reader}/process_payment_intent"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -268,67 +409,25 @@ impl<'a> ProcessSetupIntentTerminalReader<'a> { } impl<'a> ProcessSetupIntentTerminalReader<'a> { /// Initiates a setup intent flow on a Reader. - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<stripe_terminal::TerminalReader> { - client.send_form( - &format!("/terminal/readers/{reader}/process_setup_intent"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<stripe_terminal::TerminalReader> { + client.send_form(&format!("/terminal/readers/{reader}/process_setup_intent"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RefundPaymentTerminalReader<'a> { - /// A positive integer in __cents__ representing how much of this charge to refund. - #[serde(skip_serializing_if = "Option::is_none")] - pub amount: Option<i64>, - /// ID of the Charge to refund. - #[serde(skip_serializing_if = "Option::is_none")] - pub charge: Option<&'a str>, +pub struct CancelActionTerminalReader<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// ID of the PaymentIntent to refund. - #[serde(skip_serializing_if = "Option::is_none")] - pub payment_intent: Option<&'a str>, - /// Boolean indicating whether the application fee should be refunded when refunding this charge. - /// If a full charge refund is given, the full application fee will be refunded. - /// Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. - /// An application fee can be refunded only by the application that created the charge. - #[serde(skip_serializing_if = "Option::is_none")] - pub refund_application_fee: Option<bool>, - /// Boolean indicating whether the transfer should be reversed when refunding this charge. - /// The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount). - /// A transfer can be reversed only by the application that created the charge. - #[serde(skip_serializing_if = "Option::is_none")] - pub reverse_transfer: Option<bool>, } -impl<'a> RefundPaymentTerminalReader<'a> { +impl<'a> CancelActionTerminalReader<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> RefundPaymentTerminalReader<'a> { - /// Initiates a refund on a Reader - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<stripe_terminal::TerminalReader> { - client.send_form( - &format!("/terminal/readers/{reader}/refund_payment"), - self, - http_types::Method::Post, - ) +impl<'a> CancelActionTerminalReader<'a> { + /// Cancels the current reader action. + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<stripe_terminal::TerminalReader> { + client.send_form(&format!("/terminal/readers/{reader}/cancel_action"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -340,7 +439,7 @@ pub struct SetReaderDisplayTerminalReader<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, /// Type - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: SetReaderDisplayTerminalReaderType, } impl<'a> SetReaderDisplayTerminalReader<'a> { @@ -363,11 +462,7 @@ pub struct SetReaderDisplayTerminalReaderCart<'a> { pub total: i64, } impl<'a> SetReaderDisplayTerminalReaderCart<'a> { - pub fn new( - currency: stripe_types::Currency, - line_items: &'a [SetReaderDisplayTerminalReaderCartLineItems<'a>], - total: i64, - ) -> Self { + pub fn new(currency: stripe_types::Currency, line_items: &'a [SetReaderDisplayTerminalReaderCartLineItems<'a>], total: i64) -> Self { Self { currency, line_items, tax: None, total } } } @@ -431,16 +526,51 @@ impl serde::Serialize for SetReaderDisplayTerminalReaderType { } impl<'a> SetReaderDisplayTerminalReader<'a> { /// Sets reader display to show cart details. - pub fn send( - &self, - client: &stripe::Client, - reader: &stripe_terminal::TerminalReaderId, - ) -> stripe::Response<stripe_terminal::TerminalReader> { - client.send_form( - &format!("/terminal/readers/{reader}/set_reader_display"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<stripe_terminal::TerminalReader> { + client.send_form(&format!("/terminal/readers/{reader}/set_reader_display"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RefundPaymentTerminalReader<'a> { + /// A positive integer in __cents__ representing how much of this charge to refund. + #[serde(skip_serializing_if = "Option::is_none")] + pub amount: Option<i64>, + /// ID of the Charge to refund. + #[serde(skip_serializing_if = "Option::is_none")] + pub charge: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// ID of the PaymentIntent to refund. + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_intent: Option<&'a str>, + /// Boolean indicating whether the application fee should be refunded when refunding this charge. + /// If a full charge refund is given, the full application fee will be refunded. + /// Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. + /// An application fee can be refunded only by the application that created the charge. + #[serde(skip_serializing_if = "Option::is_none")] + pub refund_application_fee: Option<bool>, + /// Boolean indicating whether the transfer should be reversed when refunding this charge. + /// The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount). + /// A transfer can be reversed only by the application that created the charge. + #[serde(skip_serializing_if = "Option::is_none")] + pub reverse_transfer: Option<bool>, +} +impl<'a> RefundPaymentTerminalReader<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RefundPaymentTerminalReader<'a> { + /// Initiates a refund on a Reader + pub fn send(&self, client: &stripe::Client, reader: &stripe_terminal::TerminalReaderId) -> stripe::Response<stripe_terminal::TerminalReader> { + client.send_form(&format!("/terminal/readers/{reader}/refund_payment"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -458,7 +588,7 @@ pub struct PresentPaymentMethodTerminalReader<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub interac_present: Option<PresentPaymentMethodTerminalReaderInteracPresent<'a>>, /// Simulated payment type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] #[serde(skip_serializing_if = "Option::is_none")] pub type_: Option<PresentPaymentMethodTerminalReaderType>, } @@ -540,15 +670,7 @@ impl serde::Serialize for PresentPaymentMethodTerminalReaderType { impl<'a> PresentPaymentMethodTerminalReader<'a> { /// Presents a payment method on a simulated reader. /// Can be used to simulate accepting a payment, saving a card or refunding a transaction. - pub fn send( - &self, - client: &stripe::Client, - reader: &str, - ) -> stripe::Response<stripe_terminal::TerminalReader> { - client.send_form( - &format!("/test_helpers/terminal/readers/{reader}/present_payment_method"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, reader: &str) -> stripe::Response<stripe_terminal::TerminalReader> { + client.send_form(&format!("/test_helpers/terminal/readers/{reader}/present_payment_method"), self, http_types::Method::Post) } } diff --git a/generated/stripe_terminal/src/terminal_reader/types.rs b/generated/stripe_terminal/src/terminal_reader/types.rs index 8f2edbcd7..8f266cfa9 100644 --- a/generated/stripe_terminal/src/terminal_reader/types.rs +++ b/generated/stripe_terminal/src/terminal_reader/types.rs @@ -3,7 +3,9 @@ /// Related guide: [Connecting to a reader](https://stripe.com/docs/terminal/payments/connect-reader) /// /// For more details see <<https://stripe.com/docs/api/terminal/readers/object>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReader { /// The most recent action performed by the reader. pub action: Option<stripe_terminal::TerminalReaderReaderResourceReaderAction>, @@ -27,8 +29,146 @@ pub struct TerminalReader { /// Serial number of the reader. pub serial_number: String, /// The networking status of the reader. - pub status: Option<stripe_terminal::TerminalReaderStatus>, + pub status: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderBuilder { + action: Option<Option<stripe_terminal::TerminalReaderReaderResourceReaderAction>>, + device_sw_version: Option<Option<String>>, + device_type: Option<stripe_terminal::TerminalReaderDeviceType>, + id: Option<stripe_terminal::TerminalReaderId>, + ip_address: Option<Option<String>>, + label: Option<String>, + livemode: Option<bool>, + location: Option<Option<stripe_types::Expandable<stripe_terminal::TerminalLocation>>>, + metadata: Option<std::collections::HashMap<String, String>>, + serial_number: Option<String>, + status: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReader { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReader>, + builder: TerminalReaderBuilder, + } + + impl Visitor for Place<TerminalReader> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderBuilder { + type Out = TerminalReader; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "action" => Deserialize::begin(&mut self.action), + "device_sw_version" => Deserialize::begin(&mut self.device_sw_version), + "device_type" => Deserialize::begin(&mut self.device_type), + "id" => Deserialize::begin(&mut self.id), + "ip_address" => Deserialize::begin(&mut self.ip_address), + "label" => Deserialize::begin(&mut self.label), + "livemode" => Deserialize::begin(&mut self.livemode), + "location" => Deserialize::begin(&mut self.location), + "metadata" => Deserialize::begin(&mut self.metadata), + "serial_number" => Deserialize::begin(&mut self.serial_number), + "status" => Deserialize::begin(&mut self.status), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + action: Deserialize::default(), + device_sw_version: Deserialize::default(), + device_type: Deserialize::default(), + id: Deserialize::default(), + ip_address: Deserialize::default(), + label: Deserialize::default(), + livemode: Deserialize::default(), + location: Deserialize::default(), + metadata: Deserialize::default(), + serial_number: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let action = self.action.take()?; + let device_sw_version = self.device_sw_version.take()?; + let device_type = self.device_type.take()?; + let id = self.id.take()?; + let ip_address = self.ip_address.take()?; + let label = self.label.take()?; + let livemode = self.livemode.take()?; + let location = self.location.take()?; + let metadata = self.metadata.take()?; + let serial_number = self.serial_number.take()?; + let status = self.status.take()?; + + Some(Self::Out { action, device_sw_version, device_type, id, ip_address, label, livemode, location, metadata, serial_number, status }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReader { + type Builder = TerminalReaderBuilder; + } + + impl FromValueOpt for TerminalReader { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "action" => b.action = Some(FromValueOpt::from_value(v)?), + "device_sw_version" => b.device_sw_version = Some(FromValueOpt::from_value(v)?), + "device_type" => b.device_type = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "ip_address" => b.ip_address = Some(FromValueOpt::from_value(v)?), + "label" => b.label = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "location" => b.location = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "serial_number" => b.serial_number = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TerminalReader { type Id = stripe_terminal::TerminalReaderId; fn id(&self) -> &Self::Id { @@ -97,60 +237,24 @@ impl<'de> serde::Deserialize<'de> for TerminalReaderDeviceType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TerminalReaderDeviceType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TerminalReaderDeviceType")) } } -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum TerminalReaderStatus { - Offline, - Online, -} -impl TerminalReaderStatus { - pub fn as_str(self) -> &'static str { - use TerminalReaderStatus::*; - match self { - Offline => "offline", - Online => "online", - } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TerminalReaderDeviceType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } -impl std::str::FromStr for TerminalReaderStatus { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use TerminalReaderStatus::*; - match s { - "offline" => Ok(Offline), - "online" => Ok(Online), - _ => Err(()), - } - } -} -impl std::fmt::Display for TerminalReaderStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for TerminalReaderStatus { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for TerminalReaderStatus { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'de> serde::Deserialize<'de> for TerminalReaderStatus { - fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TerminalReaderDeviceType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { use std::str::FromStr; - let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TerminalReaderStatus")) + self.out = Some(TerminalReaderDeviceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TerminalReaderDeviceType); diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_cart.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_cart.rs index 0ce7ac835..556d0c796 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_cart.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_cart.rs @@ -1,5 +1,7 @@ /// Represents a cart to be displayed on the reader -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceCart { /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// Must be a [supported currency](https://stripe.com/docs/currencies). @@ -13,3 +15,101 @@ pub struct TerminalReaderReaderResourceCart { /// A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub total: i64, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceCartBuilder { + currency: Option<stripe_types::Currency>, + line_items: Option<Vec<stripe_terminal::TerminalReaderReaderResourceLineItem>>, + tax: Option<Option<i64>>, + total: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceCart { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceCart>, + builder: TerminalReaderReaderResourceCartBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceCart> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceCartBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceCartBuilder { + type Out = TerminalReaderReaderResourceCart; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "currency" => Deserialize::begin(&mut self.currency), + "line_items" => Deserialize::begin(&mut self.line_items), + "tax" => Deserialize::begin(&mut self.tax), + "total" => Deserialize::begin(&mut self.total), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { currency: Deserialize::default(), line_items: Deserialize::default(), tax: Deserialize::default(), total: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let currency = self.currency.take()?; + let line_items = self.line_items.take()?; + let tax = self.tax.take()?; + let total = self.total.take()?; + + Some(Self::Out { currency, line_items, tax, total }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceCart { + type Builder = TerminalReaderReaderResourceCartBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceCart { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceCartBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "line_items" => b.line_items = Some(FromValueOpt::from_value(v)?), + "tax" => b.tax = Some(FromValueOpt::from_value(v)?), + "total" => b.total = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_line_item.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_line_item.rs index 82077341a..642b09b07 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_line_item.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_line_item.rs @@ -1,5 +1,7 @@ /// Represents a line item to be displayed on the reader -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceLineItem { /// The amount of the line item. /// A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). @@ -9,3 +11,97 @@ pub struct TerminalReaderReaderResourceLineItem { /// The quantity of the line item. pub quantity: u64, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceLineItemBuilder { + amount: Option<i64>, + description: Option<String>, + quantity: Option<u64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceLineItem { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceLineItem>, + builder: TerminalReaderReaderResourceLineItemBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceLineItem> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceLineItemBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceLineItemBuilder { + type Out = TerminalReaderReaderResourceLineItem; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "description" => Deserialize::begin(&mut self.description), + "quantity" => Deserialize::begin(&mut self.quantity), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), description: Deserialize::default(), quantity: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let description = self.description.take()?; + let quantity = self.quantity.take()?; + + Some(Self::Out { amount, description, quantity }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceLineItem { + type Builder = TerminalReaderReaderResourceLineItemBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceLineItem { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceLineItemBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "quantity" => b.quantity = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_config.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_config.rs index 000d3e32d..567ba01d9 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_config.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_config.rs @@ -1,9 +1,99 @@ /// Represents a per-transaction override of a reader configuration -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceProcessConfig { /// Override showing a tipping selection screen on this transaction. - #[serde(skip_serializing_if = "Option::is_none")] pub skip_tipping: Option<bool>, - #[serde(skip_serializing_if = "Option::is_none")] pub tipping: Option<stripe_terminal::TerminalReaderReaderResourceTippingConfig>, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceProcessConfigBuilder { + skip_tipping: Option<Option<bool>>, + tipping: Option<Option<stripe_terminal::TerminalReaderReaderResourceTippingConfig>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceProcessConfig { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceProcessConfig>, + builder: TerminalReaderReaderResourceProcessConfigBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceProcessConfig> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceProcessConfigBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceProcessConfigBuilder { + type Out = TerminalReaderReaderResourceProcessConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "skip_tipping" => Deserialize::begin(&mut self.skip_tipping), + "tipping" => Deserialize::begin(&mut self.tipping), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { skip_tipping: Deserialize::default(), tipping: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let skip_tipping = self.skip_tipping.take()?; + let tipping = self.tipping.take()?; + + Some(Self::Out { skip_tipping, tipping }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceProcessConfig { + type Builder = TerminalReaderReaderResourceProcessConfigBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceProcessConfig { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceProcessConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "skip_tipping" => b.skip_tipping = Some(FromValueOpt::from_value(v)?), + "tipping" => b.tipping = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_payment_intent_action.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_payment_intent_action.rs index 9c89f8a78..744595fbc 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_payment_intent_action.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_payment_intent_action.rs @@ -1,8 +1,99 @@ /// Represents a reader action to process a payment intent -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceProcessPaymentIntentAction { /// Most recent PaymentIntent processed by the reader. pub payment_intent: stripe_types::Expandable<stripe_shared::PaymentIntent>, - #[serde(skip_serializing_if = "Option::is_none")] pub process_config: Option<stripe_terminal::TerminalReaderReaderResourceProcessConfig>, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceProcessPaymentIntentActionBuilder { + payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, + process_config: Option<Option<stripe_terminal::TerminalReaderReaderResourceProcessConfig>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceProcessPaymentIntentAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceProcessPaymentIntentAction>, + builder: TerminalReaderReaderResourceProcessPaymentIntentActionBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceProcessPaymentIntentAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceProcessPaymentIntentActionBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceProcessPaymentIntentActionBuilder { + type Out = TerminalReaderReaderResourceProcessPaymentIntentAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "process_config" => Deserialize::begin(&mut self.process_config), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payment_intent: Deserialize::default(), process_config: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let payment_intent = self.payment_intent.take()?; + let process_config = self.process_config.take()?; + + Some(Self::Out { payment_intent, process_config }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceProcessPaymentIntentAction { + type Builder = TerminalReaderReaderResourceProcessPaymentIntentActionBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceProcessPaymentIntentAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceProcessPaymentIntentActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "process_config" => b.process_config = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_config.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_config.rs index 3fbdbe812..62405c14d 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_config.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_config.rs @@ -1,3 +1,83 @@ /// Represents a per-setup override of a reader configuration -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceProcessSetupConfig {} +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceProcessSetupConfigBuilder {} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceProcessSetupConfig { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceProcessSetupConfig>, + builder: TerminalReaderReaderResourceProcessSetupConfigBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceProcessSetupConfig> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceProcessSetupConfigBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceProcessSetupConfigBuilder { + type Out = TerminalReaderReaderResourceProcessSetupConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option<Self::Out> { + Some(Self::Out {}) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceProcessSetupConfig { + type Builder = TerminalReaderReaderResourceProcessSetupConfigBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceProcessSetupConfig { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceProcessSetupConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_intent_action.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_intent_action.rs index 75247c62c..0f84d44ef 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_intent_action.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_process_setup_intent_action.rs @@ -1,12 +1,106 @@ /// Represents a reader action to process a setup intent -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceProcessSetupIntentAction { /// ID of a card PaymentMethod generated from the card_present PaymentMethod that may be attached to a Customer for future transactions. /// Only present if it was possible to generate a card PaymentMethod. - #[serde(skip_serializing_if = "Option::is_none")] pub generated_card: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] pub process_config: Option<stripe_terminal::TerminalReaderReaderResourceProcessSetupConfig>, /// Most recent SetupIntent processed by the reader. pub setup_intent: stripe_types::Expandable<stripe_shared::SetupIntent>, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceProcessSetupIntentActionBuilder { + generated_card: Option<Option<String>>, + process_config: Option<Option<stripe_terminal::TerminalReaderReaderResourceProcessSetupConfig>>, + setup_intent: Option<stripe_types::Expandable<stripe_shared::SetupIntent>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceProcessSetupIntentAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceProcessSetupIntentAction>, + builder: TerminalReaderReaderResourceProcessSetupIntentActionBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceProcessSetupIntentAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceProcessSetupIntentActionBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceProcessSetupIntentActionBuilder { + type Out = TerminalReaderReaderResourceProcessSetupIntentAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "generated_card" => Deserialize::begin(&mut self.generated_card), + "process_config" => Deserialize::begin(&mut self.process_config), + "setup_intent" => Deserialize::begin(&mut self.setup_intent), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { generated_card: Deserialize::default(), process_config: Deserialize::default(), setup_intent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let generated_card = self.generated_card.take()?; + let process_config = self.process_config.take()?; + let setup_intent = self.setup_intent.take()?; + + Some(Self::Out { generated_card, process_config, setup_intent }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceProcessSetupIntentAction { + type Builder = TerminalReaderReaderResourceProcessSetupIntentActionBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceProcessSetupIntentAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceProcessSetupIntentActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "generated_card" => b.generated_card = Some(FromValueOpt::from_value(v)?), + "process_config" => b.process_config = Some(FromValueOpt::from_value(v)?), + "setup_intent" => b.setup_intent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_reader_action.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_reader_action.rs index 712d32a68..84d4f55ae 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_reader_action.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_reader_action.rs @@ -1,27 +1,145 @@ /// Represents an action performed by the reader -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceReaderAction { /// Failure code, only set if status is `failed`. pub failure_code: Option<String>, /// Detailed failure message, only set if status is `failed`. pub failure_message: Option<String>, - #[serde(skip_serializing_if = "Option::is_none")] - pub process_payment_intent: - Option<stripe_terminal::TerminalReaderReaderResourceProcessPaymentIntentAction>, - #[serde(skip_serializing_if = "Option::is_none")] - pub process_setup_intent: - Option<stripe_terminal::TerminalReaderReaderResourceProcessSetupIntentAction>, - #[serde(skip_serializing_if = "Option::is_none")] + pub process_payment_intent: Option<stripe_terminal::TerminalReaderReaderResourceProcessPaymentIntentAction>, + pub process_setup_intent: Option<stripe_terminal::TerminalReaderReaderResourceProcessSetupIntentAction>, pub refund_payment: Option<stripe_terminal::TerminalReaderReaderResourceRefundPaymentAction>, - #[serde(skip_serializing_if = "Option::is_none")] - pub set_reader_display: - Option<stripe_terminal::TerminalReaderReaderResourceSetReaderDisplayAction>, + pub set_reader_display: Option<stripe_terminal::TerminalReaderReaderResourceSetReaderDisplayAction>, /// Status of the action performed by the reader. pub status: TerminalReaderReaderResourceReaderActionStatus, /// Type of action performed by the reader. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TerminalReaderReaderResourceReaderActionType, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceReaderActionBuilder { + failure_code: Option<Option<String>>, + failure_message: Option<Option<String>>, + process_payment_intent: Option<Option<stripe_terminal::TerminalReaderReaderResourceProcessPaymentIntentAction>>, + process_setup_intent: Option<Option<stripe_terminal::TerminalReaderReaderResourceProcessSetupIntentAction>>, + refund_payment: Option<Option<stripe_terminal::TerminalReaderReaderResourceRefundPaymentAction>>, + set_reader_display: Option<Option<stripe_terminal::TerminalReaderReaderResourceSetReaderDisplayAction>>, + status: Option<TerminalReaderReaderResourceReaderActionStatus>, + type_: Option<TerminalReaderReaderResourceReaderActionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceReaderAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceReaderAction>, + builder: TerminalReaderReaderResourceReaderActionBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceReaderAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceReaderActionBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceReaderActionBuilder { + type Out = TerminalReaderReaderResourceReaderAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "failure_code" => Deserialize::begin(&mut self.failure_code), + "failure_message" => Deserialize::begin(&mut self.failure_message), + "process_payment_intent" => Deserialize::begin(&mut self.process_payment_intent), + "process_setup_intent" => Deserialize::begin(&mut self.process_setup_intent), + "refund_payment" => Deserialize::begin(&mut self.refund_payment), + "set_reader_display" => Deserialize::begin(&mut self.set_reader_display), + "status" => Deserialize::begin(&mut self.status), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + failure_code: Deserialize::default(), + failure_message: Deserialize::default(), + process_payment_intent: Deserialize::default(), + process_setup_intent: Deserialize::default(), + refund_payment: Deserialize::default(), + set_reader_display: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let failure_code = self.failure_code.take()?; + let failure_message = self.failure_message.take()?; + let process_payment_intent = self.process_payment_intent.take()?; + let process_setup_intent = self.process_setup_intent.take()?; + let refund_payment = self.refund_payment.take()?; + let set_reader_display = self.set_reader_display.take()?; + let status = self.status.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { failure_code, failure_message, process_payment_intent, process_setup_intent, refund_payment, set_reader_display, status, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceReaderAction { + type Builder = TerminalReaderReaderResourceReaderActionBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceReaderAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceReaderActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "failure_code" => b.failure_code = Some(FromValueOpt::from_value(v)?), + "failure_message" => b.failure_message = Some(FromValueOpt::from_value(v)?), + "process_payment_intent" => b.process_payment_intent = Some(FromValueOpt::from_value(v)?), + "process_setup_intent" => b.process_setup_intent = Some(FromValueOpt::from_value(v)?), + "refund_payment" => b.refund_payment = Some(FromValueOpt::from_value(v)?), + "set_reader_display" => b.set_reader_display = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Status of the action performed by the reader. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TerminalReaderReaderResourceReaderActionStatus { @@ -75,13 +193,27 @@ impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceReaderActionSt fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TerminalReaderReaderResourceReaderActionStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TerminalReaderReaderResourceReaderActionStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TerminalReaderReaderResourceReaderActionStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TerminalReaderReaderResourceReaderActionStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalReaderReaderResourceReaderActionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceReaderActionStatus); /// Type of action performed by the reader. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TerminalReaderReaderResourceReaderActionType { @@ -138,10 +270,24 @@ impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceReaderActionTy fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TerminalReaderReaderResourceReaderActionType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TerminalReaderReaderResourceReaderActionType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TerminalReaderReaderResourceReaderActionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TerminalReaderReaderResourceReaderActionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalReaderReaderResourceReaderActionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceReaderActionType); diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_refund_payment_action.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_refund_payment_action.rs index 73202eff9..a24191b00 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_refund_payment_action.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_refund_payment_action.rs @@ -1,37 +1,154 @@ /// Represents a reader action to refund a payment -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceRefundPaymentAction { /// The amount being refunded. - #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option<i64>, /// Charge that is being refunded. - #[serde(skip_serializing_if = "Option::is_none")] pub charge: Option<stripe_types::Expandable<stripe_shared::Charge>>, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. /// This can be useful for storing additional information about the object in a structured format. - #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<std::collections::HashMap<String, String>>, /// Payment intent that is being refunded. - #[serde(skip_serializing_if = "Option::is_none")] pub payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>, /// The reason for the refund. - #[serde(skip_serializing_if = "Option::is_none")] pub reason: Option<TerminalReaderReaderResourceRefundPaymentActionReason>, /// Unique identifier for the refund object. - #[serde(skip_serializing_if = "Option::is_none")] pub refund: Option<stripe_types::Expandable<stripe_shared::Refund>>, /// Boolean indicating whether the application fee should be refunded when refunding this charge. /// If a full charge refund is given, the full application fee will be refunded. /// Otherwise, the application fee will be refunded in an amount proportional to the amount of the charge refunded. /// An application fee can be refunded only by the application that created the charge. - #[serde(skip_serializing_if = "Option::is_none")] pub refund_application_fee: Option<bool>, /// Boolean indicating whether the transfer should be reversed when refunding this charge. /// The transfer will be reversed proportionally to the amount being refunded (either the entire or partial amount). /// A transfer can be reversed only by the application that created the charge. - #[serde(skip_serializing_if = "Option::is_none")] pub reverse_transfer: Option<bool>, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceRefundPaymentActionBuilder { + amount: Option<Option<i64>>, + charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>, + reason: Option<Option<TerminalReaderReaderResourceRefundPaymentActionReason>>, + refund: Option<Option<stripe_types::Expandable<stripe_shared::Refund>>>, + refund_application_fee: Option<Option<bool>>, + reverse_transfer: Option<Option<bool>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceRefundPaymentAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceRefundPaymentAction>, + builder: TerminalReaderReaderResourceRefundPaymentActionBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceRefundPaymentAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceRefundPaymentActionBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceRefundPaymentActionBuilder { + type Out = TerminalReaderReaderResourceRefundPaymentAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "charge" => Deserialize::begin(&mut self.charge), + "metadata" => Deserialize::begin(&mut self.metadata), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + "reason" => Deserialize::begin(&mut self.reason), + "refund" => Deserialize::begin(&mut self.refund), + "refund_application_fee" => Deserialize::begin(&mut self.refund_application_fee), + "reverse_transfer" => Deserialize::begin(&mut self.reverse_transfer), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + charge: Deserialize::default(), + metadata: Deserialize::default(), + payment_intent: Deserialize::default(), + reason: Deserialize::default(), + refund: Deserialize::default(), + refund_application_fee: Deserialize::default(), + reverse_transfer: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let charge = self.charge.take()?; + let metadata = self.metadata.take()?; + let payment_intent = self.payment_intent.take()?; + let reason = self.reason.take()?; + let refund = self.refund.take()?; + let refund_application_fee = self.refund_application_fee.take()?; + let reverse_transfer = self.reverse_transfer.take()?; + + Some(Self::Out { amount, charge, metadata, payment_intent, reason, refund, refund_application_fee, reverse_transfer }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceRefundPaymentAction { + type Builder = TerminalReaderReaderResourceRefundPaymentActionBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceRefundPaymentAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceRefundPaymentActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "charge" => b.charge = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + "reason" => b.reason = Some(FromValueOpt::from_value(v)?), + "refund" => b.refund = Some(FromValueOpt::from_value(v)?), + "refund_application_fee" => b.refund_application_fee = Some(FromValueOpt::from_value(v)?), + "reverse_transfer" => b.reverse_transfer = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The reason for the refund. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TerminalReaderReaderResourceRefundPaymentActionReason { @@ -85,10 +202,24 @@ impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceRefundPaymentA fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TerminalReaderReaderResourceRefundPaymentActionReason", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TerminalReaderReaderResourceRefundPaymentActionReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TerminalReaderReaderResourceRefundPaymentActionReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TerminalReaderReaderResourceRefundPaymentActionReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalReaderReaderResourceRefundPaymentActionReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceRefundPaymentActionReason); diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_set_reader_display_action.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_set_reader_display_action.rs index 622300a8d..ccffdf25f 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_set_reader_display_action.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_set_reader_display_action.rs @@ -1,12 +1,104 @@ /// Represents a reader action to set the reader display -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceSetReaderDisplayAction { /// Cart object to be displayed by the reader. pub cart: Option<stripe_terminal::TerminalReaderReaderResourceCart>, /// Type of information to be displayed by the reader. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TerminalReaderReaderResourceSetReaderDisplayActionType, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceSetReaderDisplayActionBuilder { + cart: Option<Option<stripe_terminal::TerminalReaderReaderResourceCart>>, + type_: Option<TerminalReaderReaderResourceSetReaderDisplayActionType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceSetReaderDisplayAction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceSetReaderDisplayAction>, + builder: TerminalReaderReaderResourceSetReaderDisplayActionBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceSetReaderDisplayAction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceSetReaderDisplayActionBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceSetReaderDisplayActionBuilder { + type Out = TerminalReaderReaderResourceSetReaderDisplayAction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "cart" => Deserialize::begin(&mut self.cart), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { cart: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let cart = self.cart.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { cart, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceSetReaderDisplayAction { + type Builder = TerminalReaderReaderResourceSetReaderDisplayActionBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceSetReaderDisplayAction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceSetReaderDisplayActionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "cart" => b.cart = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of information to be displayed by the reader. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TerminalReaderReaderResourceSetReaderDisplayActionType { @@ -54,10 +146,24 @@ impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceSetReaderDispl fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TerminalReaderReaderResourceSetReaderDisplayActionType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TerminalReaderReaderResourceSetReaderDisplayActionType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TerminalReaderReaderResourceSetReaderDisplayActionType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TerminalReaderReaderResourceSetReaderDisplayActionType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalReaderReaderResourceSetReaderDisplayActionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceSetReaderDisplayActionType); diff --git a/generated/stripe_terminal/src/terminal_reader_reader_resource_tipping_config.rs b/generated/stripe_terminal/src/terminal_reader_reader_resource_tipping_config.rs index 7c7199602..9c916c692 100644 --- a/generated/stripe_terminal/src/terminal_reader_reader_resource_tipping_config.rs +++ b/generated/stripe_terminal/src/terminal_reader_reader_resource_tipping_config.rs @@ -1,8 +1,95 @@ /// Represents a per-transaction tipping configuration -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TerminalReaderReaderResourceTippingConfig { /// Amount used to calculate tip suggestions on tipping selection screen for this transaction. /// Must be a positive integer in the smallest currency unit (e.g., 100 cents to represent $1.00 or 100 to represent ¥100, a zero-decimal currency). - #[serde(skip_serializing_if = "Option::is_none")] pub amount_eligible: Option<i64>, } +#[cfg(feature = "min-ser")] +pub struct TerminalReaderReaderResourceTippingConfigBuilder { + amount_eligible: Option<Option<i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TerminalReaderReaderResourceTippingConfig { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TerminalReaderReaderResourceTippingConfig>, + builder: TerminalReaderReaderResourceTippingConfigBuilder, + } + + impl Visitor for Place<TerminalReaderReaderResourceTippingConfig> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TerminalReaderReaderResourceTippingConfigBuilder::deser_default() })) + } + } + + impl MapBuilder for TerminalReaderReaderResourceTippingConfigBuilder { + type Out = TerminalReaderReaderResourceTippingConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_eligible" => Deserialize::begin(&mut self.amount_eligible), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_eligible: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount_eligible = self.amount_eligible.take()?; + + Some(Self::Out { amount_eligible }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TerminalReaderReaderResourceTippingConfig { + type Builder = TerminalReaderReaderResourceTippingConfigBuilder; + } + + impl FromValueOpt for TerminalReaderReaderResourceTippingConfig { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TerminalReaderReaderResourceTippingConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_eligible" => b.amount_eligible = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/.rustfmt.toml b/generated/stripe_treasury/.rustfmt.toml new file mode 100644 index 000000000..fae0b0f12 --- /dev/null +++ b/generated/stripe_treasury/.rustfmt.toml @@ -0,0 +1,7 @@ + +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + \ No newline at end of file diff --git a/generated/stripe_treasury/Cargo.toml b/generated/stripe_treasury/Cargo.toml index 7595a426f..92a43f585 100644 --- a/generated/stripe_treasury/Cargo.toml +++ b/generated/stripe_treasury/Cargo.toml @@ -18,6 +18,7 @@ path = "src/mod.rs" serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde = { workspace = true, optional = true } stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +min-ser = ["miniserde","stripe_types/min-ser","stripe_shared/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki"] diff --git a/generated/stripe_treasury/src/inbound_transfers.rs b/generated/stripe_treasury/src/inbound_transfers.rs index 252f6141d..ceb9b027c 100644 --- a/generated/stripe_treasury/src/inbound_transfers.rs +++ b/generated/stripe_treasury/src/inbound_transfers.rs @@ -1,13 +1,108 @@ /// For more details see <<https://stripe.com/docs/api/treasury/inbound_transfers>>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InboundTransfers { pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, /// The type of the payment method used in the InboundTransfer. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: InboundTransfersType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_treasury::InboundTransfersPaymentMethodDetailsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct InboundTransfersBuilder { + billing_details: Option<stripe_treasury::TreasurySharedResourceBillingDetails>, + type_: Option<InboundTransfersType>, + us_bank_account: Option<Option<stripe_treasury::InboundTransfersPaymentMethodDetailsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InboundTransfers { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InboundTransfers>, + builder: InboundTransfersBuilder, + } + + impl Visitor for Place<InboundTransfers> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InboundTransfersBuilder::deser_default() })) + } + } + + impl MapBuilder for InboundTransfersBuilder { + type Out = InboundTransfers; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_details" => Deserialize::begin(&mut self.billing_details), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_details: Deserialize::default(), type_: Deserialize::default(), us_bank_account: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_details = self.billing_details.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { billing_details, type_, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InboundTransfers { + type Builder = InboundTransfersBuilder; + } + + impl FromValueOpt for InboundTransfers { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InboundTransfersBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_details" => b.billing_details = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the payment method used in the InboundTransfer. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InboundTransfersType { @@ -55,7 +150,24 @@ impl<'de> serde::Deserialize<'de> for InboundTransfersType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for InboundTransfersType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InboundTransfersType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InboundTransfersType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InboundTransfersType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InboundTransfersType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InboundTransfersType); diff --git a/generated/stripe_treasury/src/inbound_transfers_payment_method_details_us_bank_account.rs b/generated/stripe_treasury/src/inbound_transfers_payment_method_details_us_bank_account.rs index 1dcbda518..069cfabeb 100644 --- a/generated/stripe_treasury/src/inbound_transfers_payment_method_details_us_bank_account.rs +++ b/generated/stripe_treasury/src/inbound_transfers_payment_method_details_us_bank_account.rs @@ -1,8 +1,9 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct InboundTransfersPaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. - pub account_holder_type: - Option<InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType>, + pub account_holder_type: Option<InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType>, /// Account type: checkings or savings. Defaults to checking if omitted. pub account_type: Option<InboundTransfersPaymentMethodDetailsUsBankAccountAccountType>, /// Name of the bank associated with the bank account. @@ -17,6 +18,124 @@ pub struct InboundTransfersPaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct InboundTransfersPaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: Option<Option<InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType>>, + account_type: Option<Option<InboundTransfersPaymentMethodDetailsUsBankAccountAccountType>>, + bank_name: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + network: Option<InboundTransfersPaymentMethodDetailsUsBankAccountNetwork>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for InboundTransfersPaymentMethodDetailsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<InboundTransfersPaymentMethodDetailsUsBankAccount>, + builder: InboundTransfersPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place<InboundTransfersPaymentMethodDetailsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: InboundTransfersPaymentMethodDetailsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for InboundTransfersPaymentMethodDetailsUsBankAccountBuilder { + type Out = InboundTransfersPaymentMethodDetailsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "account_type" => Deserialize::begin(&mut self.account_type), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "network" => Deserialize::begin(&mut self.network), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_type: Deserialize::default(), + account_type: Deserialize::default(), + bank_name: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + network: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let account_type = self.account_type.take()?; + let bank_name = self.bank_name.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let network = self.network.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { account_holder_type, account_type, bank_name, fingerprint, last4, network, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for InboundTransfersPaymentMethodDetailsUsBankAccount { + type Builder = InboundTransfersPaymentMethodDetailsUsBankAccountBuilder; + } + + impl FromValueOpt for InboundTransfersPaymentMethodDetailsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InboundTransfersPaymentMethodDetailsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Account holder type: individual or company. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { @@ -63,15 +182,31 @@ impl serde::Serialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccou serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType -{ +impl<'de> serde::Deserialize<'de> for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType); /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InboundTransfersPaymentMethodDetailsUsBankAccountAccountType { @@ -122,13 +257,27 @@ impl<'de> serde::Deserialize<'de> for InboundTransfersPaymentMethodDetailsUsBank fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InboundTransfersPaymentMethodDetailsUsBankAccountAccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InboundTransfersPaymentMethodDetailsUsBankAccountAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InboundTransfersPaymentMethodDetailsUsBankAccountAccountType); /// The US bank account network used to debit funds. #[derive(Copy, Clone, Eq, PartialEq)] pub enum InboundTransfersPaymentMethodDetailsUsBankAccountNetwork { @@ -176,10 +325,24 @@ impl<'de> serde::Deserialize<'de> for InboundTransfersPaymentMethodDetailsUsBank fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<InboundTransfersPaymentMethodDetailsUsBankAccountNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InboundTransfersPaymentMethodDetailsUsBankAccountNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(InboundTransfersPaymentMethodDetailsUsBankAccountNetwork); diff --git a/generated/stripe_treasury/src/mod.rs b/generated/stripe_treasury/src/mod.rs index e99ca40d7..16d958ec3 100644 --- a/generated/stripe_treasury/src/mod.rs +++ b/generated/stripe_treasury/src/mod.rs @@ -7,6 +7,9 @@ //! for requests mentioned in the `Treasury` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_treasury; + +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); #[doc(hidden)] pub mod inbound_transfers; #[doc(inline)] diff --git a/generated/stripe_treasury/src/outbound_payments_payment_method_details.rs b/generated/stripe_treasury/src/outbound_payments_payment_method_details.rs index 6ef35c314..ecb584214 100644 --- a/generated/stripe_treasury/src/outbound_payments_payment_method_details.rs +++ b/generated/stripe_treasury/src/outbound_payments_payment_method_details.rs @@ -1,15 +1,112 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct OutboundPaymentsPaymentMethodDetails { pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, - #[serde(skip_serializing_if = "Option::is_none")] - pub financial_account: - Option<stripe_treasury::OutboundPaymentsPaymentMethodDetailsFinancialAccount>, + pub financial_account: Option<stripe_treasury::OutboundPaymentsPaymentMethodDetailsFinancialAccount>, /// The type of the payment method used in the OutboundPayment. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: OutboundPaymentsPaymentMethodDetailsType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option<stripe_treasury::OutboundPaymentsPaymentMethodDetailsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct OutboundPaymentsPaymentMethodDetailsBuilder { + billing_details: Option<stripe_treasury::TreasurySharedResourceBillingDetails>, + financial_account: Option<Option<stripe_treasury::OutboundPaymentsPaymentMethodDetailsFinancialAccount>>, + type_: Option<OutboundPaymentsPaymentMethodDetailsType>, + us_bank_account: Option<Option<stripe_treasury::OutboundPaymentsPaymentMethodDetailsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for OutboundPaymentsPaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<OutboundPaymentsPaymentMethodDetails>, + builder: OutboundPaymentsPaymentMethodDetailsBuilder, + } + + impl Visitor for Place<OutboundPaymentsPaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: OutboundPaymentsPaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for OutboundPaymentsPaymentMethodDetailsBuilder { + type Out = OutboundPaymentsPaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_details" => Deserialize::begin(&mut self.billing_details), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_details: Deserialize::default(), financial_account: Deserialize::default(), type_: Deserialize::default(), us_bank_account: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_details = self.billing_details.take()?; + let financial_account = self.financial_account.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { billing_details, financial_account, type_, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for OutboundPaymentsPaymentMethodDetails { + type Builder = OutboundPaymentsPaymentMethodDetailsBuilder; + } + + impl FromValueOpt for OutboundPaymentsPaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = OutboundPaymentsPaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_details" => b.billing_details = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the payment method used in the OutboundPayment. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundPaymentsPaymentMethodDetailsType { @@ -60,8 +157,24 @@ impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for OutboundPaymentsPaymentMethodDetailsType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundPaymentsPaymentMethodDetailsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundPaymentsPaymentMethodDetailsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundPaymentsPaymentMethodDetailsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundPaymentsPaymentMethodDetailsType); diff --git a/generated/stripe_treasury/src/outbound_payments_payment_method_details_financial_account.rs b/generated/stripe_treasury/src/outbound_payments_payment_method_details_financial_account.rs index 56312bfab..228607f71 100644 --- a/generated/stripe_treasury/src/outbound_payments_payment_method_details_financial_account.rs +++ b/generated/stripe_treasury/src/outbound_payments_payment_method_details_financial_account.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct OutboundPaymentsPaymentMethodDetailsFinancialAccount { /// Token of the FinancialAccount. pub id: String, /// The rails used to send funds. pub network: OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork, } +#[cfg(feature = "min-ser")] +pub struct OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder { + id: Option<String>, + network: Option<OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for OutboundPaymentsPaymentMethodDetailsFinancialAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<OutboundPaymentsPaymentMethodDetailsFinancialAccount>, + builder: OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder, + } + + impl Visitor for Place<OutboundPaymentsPaymentMethodDetailsFinancialAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder { + type Out = OutboundPaymentsPaymentMethodDetailsFinancialAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "network" => Deserialize::begin(&mut self.network), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), network: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let network = self.network.take()?; + + Some(Self::Out { id, network }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for OutboundPaymentsPaymentMethodDetailsFinancialAccount { + type Builder = OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder; + } + + impl FromValueOpt for OutboundPaymentsPaymentMethodDetailsFinancialAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The rails used to send funds. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork { @@ -52,10 +144,24 @@ impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsFinanc fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork); diff --git a/generated/stripe_treasury/src/outbound_payments_payment_method_details_us_bank_account.rs b/generated/stripe_treasury/src/outbound_payments_payment_method_details_us_bank_account.rs index fd4fc2fb3..89d40dffb 100644 --- a/generated/stripe_treasury/src/outbound_payments_payment_method_details_us_bank_account.rs +++ b/generated/stripe_treasury/src/outbound_payments_payment_method_details_us_bank_account.rs @@ -1,8 +1,9 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct OutboundPaymentsPaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. - pub account_holder_type: - Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType>, + pub account_holder_type: Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType>, /// Account type: checkings or savings. Defaults to checking if omitted. pub account_type: Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType>, /// Name of the bank associated with the bank account. @@ -17,6 +18,124 @@ pub struct OutboundPaymentsPaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: Option<Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType>>, + account_type: Option<Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType>>, + bank_name: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + network: Option<OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for OutboundPaymentsPaymentMethodDetailsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<OutboundPaymentsPaymentMethodDetailsUsBankAccount>, + builder: OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place<OutboundPaymentsPaymentMethodDetailsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder { + type Out = OutboundPaymentsPaymentMethodDetailsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "account_type" => Deserialize::begin(&mut self.account_type), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "network" => Deserialize::begin(&mut self.network), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_type: Deserialize::default(), + account_type: Deserialize::default(), + bank_name: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + network: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let account_type = self.account_type.take()?; + let bank_name = self.bank_name.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let network = self.network.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { account_holder_type, account_type, bank_name, fingerprint, last4, network, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for OutboundPaymentsPaymentMethodDetailsUsBankAccount { + type Builder = OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder; + } + + impl FromValueOpt for OutboundPaymentsPaymentMethodDetailsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Account holder type: individual or company. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType { @@ -63,15 +182,31 @@ impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccou serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType -{ +impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType); /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType { @@ -122,13 +257,27 @@ impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsUsBank fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType); /// The US bank account network used to send funds. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork { @@ -179,10 +328,24 @@ impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsUsBank fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork); diff --git a/generated/stripe_treasury/src/outbound_transfers_payment_method_details.rs b/generated/stripe_treasury/src/outbound_transfers_payment_method_details.rs index caa995e3c..590b880b5 100644 --- a/generated/stripe_treasury/src/outbound_transfers_payment_method_details.rs +++ b/generated/stripe_treasury/src/outbound_transfers_payment_method_details.rs @@ -1,13 +1,107 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct OutboundTransfersPaymentMethodDetails { pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, /// The type of the payment method used in the OutboundTransfer. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: OutboundTransfersPaymentMethodDetailsType, - #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<stripe_treasury::OutboundTransfersPaymentMethodDetailsUsBankAccount>, + pub us_bank_account: Option<stripe_treasury::OutboundTransfersPaymentMethodDetailsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct OutboundTransfersPaymentMethodDetailsBuilder { + billing_details: Option<stripe_treasury::TreasurySharedResourceBillingDetails>, + type_: Option<OutboundTransfersPaymentMethodDetailsType>, + us_bank_account: Option<Option<stripe_treasury::OutboundTransfersPaymentMethodDetailsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for OutboundTransfersPaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<OutboundTransfersPaymentMethodDetails>, + builder: OutboundTransfersPaymentMethodDetailsBuilder, + } + + impl Visitor for Place<OutboundTransfersPaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: OutboundTransfersPaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for OutboundTransfersPaymentMethodDetailsBuilder { + type Out = OutboundTransfersPaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "billing_details" => Deserialize::begin(&mut self.billing_details), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_details: Deserialize::default(), type_: Deserialize::default(), us_bank_account: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let billing_details = self.billing_details.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { billing_details, type_, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for OutboundTransfersPaymentMethodDetails { + type Builder = OutboundTransfersPaymentMethodDetailsBuilder; + } + + impl FromValueOpt for OutboundTransfersPaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = OutboundTransfersPaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "billing_details" => b.billing_details = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the payment method used in the OutboundTransfer. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundTransfersPaymentMethodDetailsType { @@ -55,8 +149,24 @@ impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsType fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for OutboundTransfersPaymentMethodDetailsType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundTransfersPaymentMethodDetailsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundTransfersPaymentMethodDetailsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundTransfersPaymentMethodDetailsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundTransfersPaymentMethodDetailsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundTransfersPaymentMethodDetailsType); diff --git a/generated/stripe_treasury/src/outbound_transfers_payment_method_details_us_bank_account.rs b/generated/stripe_treasury/src/outbound_transfers_payment_method_details_us_bank_account.rs index 4e2f90566..ce8b065dd 100644 --- a/generated/stripe_treasury/src/outbound_transfers_payment_method_details_us_bank_account.rs +++ b/generated/stripe_treasury/src/outbound_transfers_payment_method_details_us_bank_account.rs @@ -1,8 +1,9 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct OutboundTransfersPaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. - pub account_holder_type: - Option<OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType>, + pub account_holder_type: Option<OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType>, /// Account type: checkings or savings. Defaults to checking if omitted. pub account_type: Option<OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType>, /// Name of the bank associated with the bank account. @@ -17,6 +18,124 @@ pub struct OutboundTransfersPaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: Option<Option<OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType>>, + account_type: Option<Option<OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType>>, + bank_name: Option<Option<String>>, + fingerprint: Option<Option<String>>, + last4: Option<Option<String>>, + network: Option<OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for OutboundTransfersPaymentMethodDetailsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<OutboundTransfersPaymentMethodDetailsUsBankAccount>, + builder: OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place<OutboundTransfersPaymentMethodDetailsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder { + type Out = OutboundTransfersPaymentMethodDetailsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_type" => Deserialize::begin(&mut self.account_holder_type), + "account_type" => Deserialize::begin(&mut self.account_type), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "last4" => Deserialize::begin(&mut self.last4), + "network" => Deserialize::begin(&mut self.network), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_type: Deserialize::default(), + account_type: Deserialize::default(), + bank_name: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + network: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_type = self.account_holder_type.take()?; + let account_type = self.account_type.take()?; + let bank_name = self.bank_name.take()?; + let fingerprint = self.fingerprint.take()?; + let last4 = self.last4.take()?; + let network = self.network.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { account_holder_type, account_type, bank_name, fingerprint, last4, network, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for OutboundTransfersPaymentMethodDetailsUsBankAccount { + type Builder = OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder; + } + + impl FromValueOpt for OutboundTransfersPaymentMethodDetailsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_type" => b.account_holder_type = Some(FromValueOpt::from_value(v)?), + "account_type" => b.account_type = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Account holder type: individual or company. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { @@ -63,15 +182,31 @@ impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAcco serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType -{ +impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType); /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType { @@ -118,19 +253,31 @@ impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAcco serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType -{ +impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType); /// The US bank account network used to send funds. #[derive(Copy, Clone, Eq, PartialEq)] pub enum OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork { @@ -181,10 +328,24 @@ impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsUsBan fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork); diff --git a/generated/stripe_treasury/src/received_payment_method_details_financial_account.rs b/generated/stripe_treasury/src/received_payment_method_details_financial_account.rs index 0adc990de..1338ea366 100644 --- a/generated/stripe_treasury/src/received_payment_method_details_financial_account.rs +++ b/generated/stripe_treasury/src/received_payment_method_details_financial_account.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct ReceivedPaymentMethodDetailsFinancialAccount { /// The FinancialAccount ID. pub id: String, /// The rails the ReceivedCredit was sent over. A FinancialAccount can only send funds over `stripe`. pub network: ReceivedPaymentMethodDetailsFinancialAccountNetwork, } +#[cfg(feature = "min-ser")] +pub struct ReceivedPaymentMethodDetailsFinancialAccountBuilder { + id: Option<String>, + network: Option<ReceivedPaymentMethodDetailsFinancialAccountNetwork>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ReceivedPaymentMethodDetailsFinancialAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<ReceivedPaymentMethodDetailsFinancialAccount>, + builder: ReceivedPaymentMethodDetailsFinancialAccountBuilder, + } + + impl Visitor for Place<ReceivedPaymentMethodDetailsFinancialAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: ReceivedPaymentMethodDetailsFinancialAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for ReceivedPaymentMethodDetailsFinancialAccountBuilder { + type Out = ReceivedPaymentMethodDetailsFinancialAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "network" => Deserialize::begin(&mut self.network), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), network: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let id = self.id.take()?; + let network = self.network.take()?; + + Some(Self::Out { id, network }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ReceivedPaymentMethodDetailsFinancialAccount { + type Builder = ReceivedPaymentMethodDetailsFinancialAccountBuilder; + } + + impl FromValueOpt for ReceivedPaymentMethodDetailsFinancialAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ReceivedPaymentMethodDetailsFinancialAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The rails the ReceivedCredit was sent over. A FinancialAccount can only send funds over `stripe`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ReceivedPaymentMethodDetailsFinancialAccountNetwork { @@ -52,10 +144,24 @@ impl<'de> serde::Deserialize<'de> for ReceivedPaymentMethodDetailsFinancialAccou fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for ReceivedPaymentMethodDetailsFinancialAccountNetwork", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for ReceivedPaymentMethodDetailsFinancialAccountNetwork")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for ReceivedPaymentMethodDetailsFinancialAccountNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<ReceivedPaymentMethodDetailsFinancialAccountNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReceivedPaymentMethodDetailsFinancialAccountNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(ReceivedPaymentMethodDetailsFinancialAccountNetwork); diff --git a/generated/stripe_treasury/src/treasury_credit_reversal/requests.rs b/generated/stripe_treasury/src/treasury_credit_reversal/requests.rs index dd64da691..5af48bbc6 100644 --- a/generated/stripe_treasury/src/treasury_credit_reversal/requests.rs +++ b/generated/stripe_treasury/src/treasury_credit_reversal/requests.rs @@ -28,28 +28,15 @@ pub struct ListTreasuryCreditReversal<'a> { } impl<'a> ListTreasuryCreditReversal<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - ending_before: None, - expand: None, - financial_account, - limit: None, - received_credit: None, - starting_after: None, - status: None, - } + Self { ending_before: None, expand: None, financial_account, limit: None, received_credit: None, starting_after: None, status: None } } } impl<'a> ListTreasuryCreditReversal<'a> { /// Returns a list of CreditReversals. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryCreditReversal>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryCreditReversal>> { client.get_query("/treasury/credit_reversals", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryCreditReversal>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryCreditReversal>> { stripe::ListPaginator::from_list_params("/treasury/credit_reversals", self) } } @@ -66,11 +53,7 @@ impl<'a> RetrieveTreasuryCreditReversal<'a> { } impl<'a> RetrieveTreasuryCreditReversal<'a> { /// Retrieves the details of an existing CreditReversal by passing the unique CreditReversal ID from either the CreditReversal creation request or CreditReversal list. - pub fn send( - &self, - client: &stripe::Client, - credit_reversal: &stripe_treasury::TreasuryCreditReversalId, - ) -> stripe::Response<stripe_treasury::TreasuryCreditReversal> { + pub fn send(&self, client: &stripe::Client, credit_reversal: &stripe_treasury::TreasuryCreditReversalId) -> stripe::Response<stripe_treasury::TreasuryCreditReversal> { client.get_query(&format!("/treasury/credit_reversals/{credit_reversal}"), self) } } @@ -95,10 +78,7 @@ impl<'a> CreateTreasuryCreditReversal<'a> { } impl<'a> CreateTreasuryCreditReversal<'a> { /// Reverses a ReceivedCredit and creates a CreditReversal object. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryCreditReversal> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryCreditReversal> { client.send_form("/treasury/credit_reversals", self, http_types::Method::Post) } } diff --git a/generated/stripe_treasury/src/treasury_credit_reversal/types.rs b/generated/stripe_treasury/src/treasury_credit_reversal/types.rs index 21eff098f..8f8afdf8b 100644 --- a/generated/stripe_treasury/src/treasury_credit_reversal/types.rs +++ b/generated/stripe_treasury/src/treasury_credit_reversal/types.rs @@ -1,6 +1,8 @@ /// You can reverse some [ReceivedCredits](https://stripe.com/docs/api#received_credits) depending on their network and source flow. /// Reversing a ReceivedCredit leads to the creation of a new object known as a CreditReversal. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryCreditReversal { /// Amount (in cents) transferred. pub amount: i64, @@ -30,6 +32,154 @@ pub struct TreasuryCreditReversal { /// The Transaction associated with this object. pub transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryCreditReversalBuilder { + amount: Option<i64>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + financial_account: Option<String>, + hosted_regulatory_receipt_url: Option<Option<String>>, + id: Option<stripe_treasury::TreasuryCreditReversalId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + network: Option<TreasuryCreditReversalNetwork>, + received_credit: Option<String>, + status: Option<stripe_treasury::TreasuryCreditReversalStatus>, + status_transitions: Option<stripe_treasury::TreasuryReceivedCreditsResourceStatusTransitions>, + transaction: Option<Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryCreditReversal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryCreditReversal>, + builder: TreasuryCreditReversalBuilder, + } + + impl Visitor for Place<TreasuryCreditReversal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryCreditReversalBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryCreditReversalBuilder { + type Out = TreasuryCreditReversal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "hosted_regulatory_receipt_url" => Deserialize::begin(&mut self.hosted_regulatory_receipt_url), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "network" => Deserialize::begin(&mut self.network), + "received_credit" => Deserialize::begin(&mut self.received_credit), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + financial_account: Deserialize::default(), + hosted_regulatory_receipt_url: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + network: Deserialize::default(), + received_credit: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let financial_account = self.financial_account.take()?; + let hosted_regulatory_receipt_url = self.hosted_regulatory_receipt_url.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let network = self.network.take()?; + let received_credit = self.received_credit.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { amount, created, currency, financial_account, hosted_regulatory_receipt_url, id, livemode, metadata, network, received_credit, status, status_transitions, transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryCreditReversal { + type Builder = TreasuryCreditReversalBuilder; + } + + impl FromValueOpt for TreasuryCreditReversal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryCreditReversalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "hosted_regulatory_receipt_url" => b.hosted_regulatory_receipt_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "received_credit" => b.received_credit = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The rails used to reverse the funds. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryCreditReversalNetwork { @@ -80,11 +230,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryCreditReversalNetwork { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryCreditReversalNetwork") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryCreditReversalNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryCreditReversalNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryCreditReversalNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryCreditReversalNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryCreditReversalNetwork); impl stripe_types::Object for TreasuryCreditReversal { type Id = stripe_treasury::TreasuryCreditReversalId; fn id(&self) -> &Self::Id { @@ -144,7 +310,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryCreditReversalStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryCreditReversalStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryCreditReversalStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryCreditReversalStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryCreditReversalStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryCreditReversalStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryCreditReversalStatus); diff --git a/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs b/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs index a02d734dd..c49621df5 100644 --- a/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs +++ b/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs @@ -1,4 +1,46 @@ #[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct CreateTreasuryDebitReversal<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// The ReceivedDebit to reverse. + pub received_debit: &'a str, +} +impl<'a> CreateTreasuryDebitReversal<'a> { + pub fn new(received_debit: &'a str) -> Self { + Self { expand: None, metadata: None, received_debit } + } +} +impl<'a> CreateTreasuryDebitReversal<'a> { + /// Reverses a ReceivedDebit and creates a DebitReversal object. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryDebitReversal> { + client.send_form("/treasury/debit_reversals", self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTreasuryDebitReversal<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTreasuryDebitReversal<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTreasuryDebitReversal<'a> { + /// Retrieves a DebitReversal object. + pub fn send(&self, client: &stripe::Client, debit_reversal: &stripe_treasury::TreasuryDebitReversalId) -> stripe::Response<stripe_treasury::TreasuryDebitReversal> { + client.get_query(&format!("/treasury/debit_reversals/{debit_reversal}"), self) + } +} +#[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ListTreasuryDebitReversal<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -31,16 +73,7 @@ pub struct ListTreasuryDebitReversal<'a> { } impl<'a> ListTreasuryDebitReversal<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - ending_before: None, - expand: None, - financial_account, - limit: None, - received_debit: None, - resolution: None, - starting_after: None, - status: None, - } + Self { ending_before: None, expand: None, financial_account, limit: None, received_debit: None, resolution: None, starting_after: None, status: None } } } /// Only return DebitReversals for a given resolution. @@ -140,64 +173,10 @@ impl serde::Serialize for ListTreasuryDebitReversalStatus { } impl<'a> ListTreasuryDebitReversal<'a> { /// Returns a list of DebitReversals. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryDebitReversal>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryDebitReversal>> { client.get_query("/treasury/debit_reversals", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryDebitReversal>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryDebitReversal>> { stripe::ListPaginator::from_list_params("/treasury/debit_reversals", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTreasuryDebitReversal<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveTreasuryDebitReversal<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveTreasuryDebitReversal<'a> { - /// Retrieves a DebitReversal object. - pub fn send( - &self, - client: &stripe::Client, - debit_reversal: &stripe_treasury::TreasuryDebitReversalId, - ) -> stripe::Response<stripe_treasury::TreasuryDebitReversal> { - client.get_query(&format!("/treasury/debit_reversals/{debit_reversal}"), self) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateTreasuryDebitReversal<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// The ReceivedDebit to reverse. - pub received_debit: &'a str, -} -impl<'a> CreateTreasuryDebitReversal<'a> { - pub fn new(received_debit: &'a str) -> Self { - Self { expand: None, metadata: None, received_debit } - } -} -impl<'a> CreateTreasuryDebitReversal<'a> { - /// Reverses a ReceivedDebit and creates a DebitReversal object. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryDebitReversal> { - client.send_form("/treasury/debit_reversals", self, http_types::Method::Post) - } -} diff --git a/generated/stripe_treasury/src/treasury_debit_reversal/types.rs b/generated/stripe_treasury/src/treasury_debit_reversal/types.rs index 62ec67342..e13a2ce84 100644 --- a/generated/stripe_treasury/src/treasury_debit_reversal/types.rs +++ b/generated/stripe_treasury/src/treasury_debit_reversal/types.rs @@ -1,6 +1,8 @@ /// You can reverse some [ReceivedDebits](https://stripe.com/docs/api#received_debits) depending on their network and source flow. /// Reversing a ReceivedDebit leads to the creation of a new object known as a DebitReversal. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryDebitReversal { /// Amount (in cents) transferred. pub amount: i64, @@ -16,8 +18,7 @@ pub struct TreasuryDebitReversal { /// Unique identifier for the object. pub id: stripe_treasury::TreasuryDebitReversalId, /// Other flows linked to a DebitReversal. - pub linked_flows: - Option<stripe_treasury::TreasuryReceivedDebitsResourceDebitReversalLinkedFlows>, + pub linked_flows: Option<stripe_treasury::TreasuryReceivedDebitsResourceDebitReversalLinkedFlows>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. @@ -33,6 +34,174 @@ pub struct TreasuryDebitReversal { /// The Transaction associated with this object. pub transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryDebitReversalBuilder { + amount: Option<i64>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + financial_account: Option<Option<String>>, + hosted_regulatory_receipt_url: Option<Option<String>>, + id: Option<stripe_treasury::TreasuryDebitReversalId>, + linked_flows: Option<Option<stripe_treasury::TreasuryReceivedDebitsResourceDebitReversalLinkedFlows>>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + network: Option<TreasuryDebitReversalNetwork>, + received_debit: Option<String>, + status: Option<TreasuryDebitReversalStatus>, + status_transitions: Option<stripe_treasury::TreasuryReceivedDebitsResourceStatusTransitions>, + transaction: Option<Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryDebitReversal { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryDebitReversal>, + builder: TreasuryDebitReversalBuilder, + } + + impl Visitor for Place<TreasuryDebitReversal> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryDebitReversalBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryDebitReversalBuilder { + type Out = TreasuryDebitReversal; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "hosted_regulatory_receipt_url" => Deserialize::begin(&mut self.hosted_regulatory_receipt_url), + "id" => Deserialize::begin(&mut self.id), + "linked_flows" => Deserialize::begin(&mut self.linked_flows), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "network" => Deserialize::begin(&mut self.network), + "received_debit" => Deserialize::begin(&mut self.received_debit), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + financial_account: Deserialize::default(), + hosted_regulatory_receipt_url: Deserialize::default(), + id: Deserialize::default(), + linked_flows: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + network: Deserialize::default(), + received_debit: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let financial_account = self.financial_account.take()?; + let hosted_regulatory_receipt_url = self.hosted_regulatory_receipt_url.take()?; + let id = self.id.take()?; + let linked_flows = self.linked_flows.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let network = self.network.take()?; + let received_debit = self.received_debit.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { + amount, + created, + currency, + financial_account, + hosted_regulatory_receipt_url, + id, + linked_flows, + livemode, + metadata, + network, + received_debit, + status, + status_transitions, + transaction, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryDebitReversal { + type Builder = TreasuryDebitReversalBuilder; + } + + impl FromValueOpt for TreasuryDebitReversal { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryDebitReversalBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "hosted_regulatory_receipt_url" => b.hosted_regulatory_receipt_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "linked_flows" => b.linked_flows = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "received_debit" => b.received_debit = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The rails used to reverse the funds. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryDebitReversalNetwork { @@ -83,10 +252,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryDebitReversalNetwork { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryDebitReversalNetwork")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryDebitReversalNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryDebitReversalNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryDebitReversalNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryDebitReversalNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryDebitReversalNetwork); /// Status of the DebitReversal #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryDebitReversalStatus { @@ -140,10 +326,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryDebitReversalStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryDebitReversalStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryDebitReversalStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryDebitReversalStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryDebitReversalStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryDebitReversalStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryDebitReversalStatus); impl stripe_types::Object for TreasuryDebitReversal { type Id = stripe_treasury::TreasuryDebitReversalId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_treasury/src/treasury_financial_account/requests.rs b/generated/stripe_treasury/src/treasury_financial_account/requests.rs index a30f0be40..41f6b1441 100644 --- a/generated/stripe_treasury/src/treasury_financial_account/requests.rs +++ b/generated/stripe_treasury/src/treasury_financial_account/requests.rs @@ -1,82 +1,3 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListTreasuryFinancialAccount<'a> { - #[serde(skip_serializing_if = "Option::is_none")] - pub created: Option<stripe_types::RangeQueryTs>, - /// An object ID cursor for use in pagination. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// A limit ranging from 1 to 100 (defaults to 10). - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// An object ID cursor for use in pagination. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, -} -impl<'a> ListTreasuryFinancialAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> ListTreasuryFinancialAccount<'a> { - /// Returns a list of FinancialAccounts. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryFinancialAccount>> { - client.get_query("/treasury/financial_accounts", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryFinancialAccount>> { - stripe::ListPaginator::from_list_params("/treasury/financial_accounts", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTreasuryFinancialAccount<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveTreasuryFinancialAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveTreasuryFinancialAccount<'a> { - /// Retrieves the details of a FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - financial_account: &stripe_treasury::TreasuryFinancialAccountId, - ) -> stripe::Response<stripe_treasury::TreasuryFinancialAccount> { - client.get_query(&format!("/treasury/financial_accounts/{financial_account}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveFeaturesTreasuryFinancialAccount<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveFeaturesTreasuryFinancialAccount<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveFeaturesTreasuryFinancialAccount<'a> { - /// Retrieves Features information associated with the FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - financial_account: &stripe_treasury::TreasuryFinancialAccountId, - ) -> stripe::Response<stripe_treasury::TreasuryFinancialAccountFeatures> { - client - .get_query(&format!("/treasury/financial_accounts/{financial_account}/features"), self) - } -} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTreasuryFinancialAccount<'a> { /// Specifies which fields in the response should be expanded. @@ -100,13 +21,7 @@ pub struct CreateTreasuryFinancialAccount<'a> { } impl<'a> CreateTreasuryFinancialAccount<'a> { pub fn new(supported_currencies: &'a [&'a str]) -> Self { - Self { - expand: None, - features: None, - metadata: None, - platform_restrictions: None, - supported_currencies, - } + Self { expand: None, features: None, metadata: None, platform_restrictions: None, supported_currencies } } } /// Encodes whether a FinancialAccount has access to a particular feature. @@ -229,8 +144,7 @@ pub struct CreateTreasuryFinancialAccountFeaturesOutboundPayments { pub ach: Option<CreateTreasuryFinancialAccountFeaturesOutboundPaymentsAch>, /// Enables US domestic wire transfers via the OutboundPayments API. #[serde(skip_serializing_if = "Option::is_none")] - pub us_domestic_wire: - Option<CreateTreasuryFinancialAccountFeaturesOutboundPaymentsUsDomesticWire>, + pub us_domestic_wire: Option<CreateTreasuryFinancialAccountFeaturesOutboundPaymentsUsDomesticWire>, } impl CreateTreasuryFinancialAccountFeaturesOutboundPayments { pub fn new() -> Self { @@ -267,8 +181,7 @@ pub struct CreateTreasuryFinancialAccountFeaturesOutboundTransfers { pub ach: Option<CreateTreasuryFinancialAccountFeaturesOutboundTransfersAch>, /// Enables US domestic wire transfers via the OutboundTransfers API. #[serde(skip_serializing_if = "Option::is_none")] - pub us_domestic_wire: - Option<CreateTreasuryFinancialAccountFeaturesOutboundTransfersUsDomesticWire>, + pub us_domestic_wire: Option<CreateTreasuryFinancialAccountFeaturesOutboundTransfersUsDomesticWire>, } impl CreateTreasuryFinancialAccountFeaturesOutboundTransfers { pub fn new() -> Self { @@ -406,10 +319,7 @@ impl serde::Serialize for CreateTreasuryFinancialAccountPlatformRestrictionsOutb } impl<'a> CreateTreasuryFinancialAccount<'a> { /// Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryFinancialAccount> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryFinancialAccount> { client.send_form("/treasury/financial_accounts", self, http_types::Method::Post) } } @@ -557,8 +467,7 @@ pub struct UpdateTreasuryFinancialAccountFeaturesOutboundPayments { pub ach: Option<UpdateTreasuryFinancialAccountFeaturesOutboundPaymentsAch>, /// Enables US domestic wire transfers via the OutboundPayments API. #[serde(skip_serializing_if = "Option::is_none")] - pub us_domestic_wire: - Option<UpdateTreasuryFinancialAccountFeaturesOutboundPaymentsUsDomesticWire>, + pub us_domestic_wire: Option<UpdateTreasuryFinancialAccountFeaturesOutboundPaymentsUsDomesticWire>, } impl UpdateTreasuryFinancialAccountFeaturesOutboundPayments { pub fn new() -> Self { @@ -595,8 +504,7 @@ pub struct UpdateTreasuryFinancialAccountFeaturesOutboundTransfers { pub ach: Option<UpdateTreasuryFinancialAccountFeaturesOutboundTransfersAch>, /// Enables US domestic wire transfers via the OutboundTransfers API. #[serde(skip_serializing_if = "Option::is_none")] - pub us_domestic_wire: - Option<UpdateTreasuryFinancialAccountFeaturesOutboundTransfersUsDomesticWire>, + pub us_domestic_wire: Option<UpdateTreasuryFinancialAccountFeaturesOutboundTransfersUsDomesticWire>, } impl UpdateTreasuryFinancialAccountFeaturesOutboundTransfers { pub fn new() -> Self { @@ -734,16 +642,8 @@ impl serde::Serialize for UpdateTreasuryFinancialAccountPlatformRestrictionsOutb } impl<'a> UpdateTreasuryFinancialAccount<'a> { /// Updates the details of a FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - financial_account: &stripe_treasury::TreasuryFinancialAccountId, - ) -> stripe::Response<stripe_treasury::TreasuryFinancialAccount> { - client.send_form( - &format!("/treasury/financial_accounts/{financial_account}"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, financial_account: &stripe_treasury::TreasuryFinancialAccountId) -> stripe::Response<stripe_treasury::TreasuryFinancialAccount> { + client.send_form(&format!("/treasury/financial_accounts/{financial_account}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -867,8 +767,7 @@ pub struct UpdateFeaturesTreasuryFinancialAccountOutboundPayments { pub ach: Option<UpdateFeaturesTreasuryFinancialAccountOutboundPaymentsAch>, /// Enables US domestic wire transfers via the OutboundPayments API. #[serde(skip_serializing_if = "Option::is_none")] - pub us_domestic_wire: - Option<UpdateFeaturesTreasuryFinancialAccountOutboundPaymentsUsDomesticWire>, + pub us_domestic_wire: Option<UpdateFeaturesTreasuryFinancialAccountOutboundPaymentsUsDomesticWire>, } impl UpdateFeaturesTreasuryFinancialAccountOutboundPayments { pub fn new() -> Self { @@ -905,8 +804,7 @@ pub struct UpdateFeaturesTreasuryFinancialAccountOutboundTransfers { pub ach: Option<UpdateFeaturesTreasuryFinancialAccountOutboundTransfersAch>, /// Enables US domestic wire transfers via the OutboundTransfers API. #[serde(skip_serializing_if = "Option::is_none")] - pub us_domestic_wire: - Option<UpdateFeaturesTreasuryFinancialAccountOutboundTransfersUsDomesticWire>, + pub us_domestic_wire: Option<UpdateFeaturesTreasuryFinancialAccountOutboundTransfersUsDomesticWire>, } impl UpdateFeaturesTreasuryFinancialAccountOutboundTransfers { pub fn new() -> Self { @@ -937,15 +835,72 @@ impl UpdateFeaturesTreasuryFinancialAccountOutboundTransfersUsDomesticWire { } impl<'a> UpdateFeaturesTreasuryFinancialAccount<'a> { /// Updates the Features associated with a FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - financial_account: &stripe_treasury::TreasuryFinancialAccountId, - ) -> stripe::Response<stripe_treasury::TreasuryFinancialAccountFeatures> { - client.send_form( - &format!("/treasury/financial_accounts/{financial_account}/features"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, financial_account: &stripe_treasury::TreasuryFinancialAccountId) -> stripe::Response<stripe_treasury::TreasuryFinancialAccountFeatures> { + client.send_form(&format!("/treasury/financial_accounts/{financial_account}/features"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ListTreasuryFinancialAccount<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + pub created: Option<stripe_types::RangeQueryTs>, + /// An object ID cursor for use in pagination. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// A limit ranging from 1 to 100 (defaults to 10). + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// An object ID cursor for use in pagination. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, +} +impl<'a> ListTreasuryFinancialAccount<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> ListTreasuryFinancialAccount<'a> { + /// Returns a list of FinancialAccounts. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryFinancialAccount>> { + client.get_query("/treasury/financial_accounts", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryFinancialAccount>> { + stripe::ListPaginator::from_list_params("/treasury/financial_accounts", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTreasuryFinancialAccount<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTreasuryFinancialAccount<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTreasuryFinancialAccount<'a> { + /// Retrieves the details of a FinancialAccount. + pub fn send(&self, client: &stripe::Client, financial_account: &stripe_treasury::TreasuryFinancialAccountId) -> stripe::Response<stripe_treasury::TreasuryFinancialAccount> { + client.get_query(&format!("/treasury/financial_accounts/{financial_account}"), self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveFeaturesTreasuryFinancialAccount<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveFeaturesTreasuryFinancialAccount<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveFeaturesTreasuryFinancialAccount<'a> { + /// Retrieves Features information associated with the FinancialAccount. + pub fn send(&self, client: &stripe::Client, financial_account: &stripe_treasury::TreasuryFinancialAccountId) -> stripe::Response<stripe_treasury::TreasuryFinancialAccountFeatures> { + client.get_query(&format!("/treasury/financial_accounts/{financial_account}/features"), self) } } diff --git a/generated/stripe_treasury/src/treasury_financial_account/types.rs b/generated/stripe_treasury/src/treasury_financial_account/types.rs index 0bbcf92ad..12255d499 100644 --- a/generated/stripe_treasury/src/treasury_financial_account/types.rs +++ b/generated/stripe_treasury/src/treasury_financial_account/types.rs @@ -1,20 +1,19 @@ /// Stripe Treasury provides users with a container for money called a FinancialAccount that is separate from their Payments balance. /// FinancialAccounts serve as the source and destination of Treasury’s money movement APIs. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccount { /// The array of paths to active Features in the Features hash. - #[serde(skip_serializing_if = "Option::is_none")] pub active_features: Option<Vec<stripe_treasury::TreasuryFinancialAccountArray>>, pub balance: stripe_treasury::TreasuryFinancialAccountsResourceBalance, /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). pub country: String, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, - #[serde(skip_serializing_if = "Option::is_none")] pub features: Option<stripe_treasury::TreasuryFinancialAccountFeatures>, /// The set of credentials that resolve to a FinancialAccount. - pub financial_addresses: - Vec<stripe_treasury::TreasuryFinancialAccountsResourceFinancialAddress>, + pub financial_addresses: Vec<stripe_treasury::TreasuryFinancialAccountsResourceFinancialAddress>, /// Unique identifier for the object. pub id: stripe_treasury::TreasuryFinancialAccountId, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. @@ -23,14 +22,10 @@ pub struct TreasuryFinancialAccount { /// This can be useful for storing additional information about the object in a structured format. pub metadata: Option<std::collections::HashMap<String, String>>, /// The array of paths to pending Features in the Features hash. - #[serde(skip_serializing_if = "Option::is_none")] pub pending_features: Option<Vec<stripe_treasury::TreasuryFinancialAccountArray>>, /// The set of functionalities that the platform can restrict on the FinancialAccount. - #[serde(skip_serializing_if = "Option::is_none")] - pub platform_restrictions: - Option<stripe_treasury::TreasuryFinancialAccountsResourcePlatformRestrictions>, + pub platform_restrictions: Option<stripe_treasury::TreasuryFinancialAccountsResourcePlatformRestrictions>, /// The array of paths to restricted Features in the Features hash. - #[serde(skip_serializing_if = "Option::is_none")] pub restricted_features: Option<Vec<stripe_treasury::TreasuryFinancialAccountArray>>, /// The enum specifying what state the account is in. pub status: TreasuryFinancialAccountStatus, @@ -39,6 +34,180 @@ pub struct TreasuryFinancialAccount { /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. pub supported_currencies: Vec<String>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountBuilder { + active_features: Option<Option<Vec<stripe_treasury::TreasuryFinancialAccountArray>>>, + balance: Option<stripe_treasury::TreasuryFinancialAccountsResourceBalance>, + country: Option<String>, + created: Option<stripe_types::Timestamp>, + features: Option<Option<stripe_treasury::TreasuryFinancialAccountFeatures>>, + financial_addresses: Option<Vec<stripe_treasury::TreasuryFinancialAccountsResourceFinancialAddress>>, + id: Option<stripe_treasury::TreasuryFinancialAccountId>, + livemode: Option<bool>, + metadata: Option<Option<std::collections::HashMap<String, String>>>, + pending_features: Option<Option<Vec<stripe_treasury::TreasuryFinancialAccountArray>>>, + platform_restrictions: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourcePlatformRestrictions>>, + restricted_features: Option<Option<Vec<stripe_treasury::TreasuryFinancialAccountArray>>>, + status: Option<TreasuryFinancialAccountStatus>, + status_details: Option<stripe_treasury::TreasuryFinancialAccountsResourceStatusDetails>, + supported_currencies: Option<Vec<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccount>, + builder: TreasuryFinancialAccountBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountBuilder { + type Out = TreasuryFinancialAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "active_features" => Deserialize::begin(&mut self.active_features), + "balance" => Deserialize::begin(&mut self.balance), + "country" => Deserialize::begin(&mut self.country), + "created" => Deserialize::begin(&mut self.created), + "features" => Deserialize::begin(&mut self.features), + "financial_addresses" => Deserialize::begin(&mut self.financial_addresses), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "pending_features" => Deserialize::begin(&mut self.pending_features), + "platform_restrictions" => Deserialize::begin(&mut self.platform_restrictions), + "restricted_features" => Deserialize::begin(&mut self.restricted_features), + "status" => Deserialize::begin(&mut self.status), + "status_details" => Deserialize::begin(&mut self.status_details), + "supported_currencies" => Deserialize::begin(&mut self.supported_currencies), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + active_features: Deserialize::default(), + balance: Deserialize::default(), + country: Deserialize::default(), + created: Deserialize::default(), + features: Deserialize::default(), + financial_addresses: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + pending_features: Deserialize::default(), + platform_restrictions: Deserialize::default(), + restricted_features: Deserialize::default(), + status: Deserialize::default(), + status_details: Deserialize::default(), + supported_currencies: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let active_features = self.active_features.take()?; + let balance = self.balance.take()?; + let country = self.country.take()?; + let created = self.created.take()?; + let features = self.features.take()?; + let financial_addresses = self.financial_addresses.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let pending_features = self.pending_features.take()?; + let platform_restrictions = self.platform_restrictions.take()?; + let restricted_features = self.restricted_features.take()?; + let status = self.status.take()?; + let status_details = self.status_details.take()?; + let supported_currencies = self.supported_currencies.take()?; + + Some(Self::Out { + active_features, + balance, + country, + created, + features, + financial_addresses, + id, + livemode, + metadata, + pending_features, + platform_restrictions, + restricted_features, + status, + status_details, + supported_currencies, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccount { + type Builder = TreasuryFinancialAccountBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "active_features" => b.active_features = Some(FromValueOpt::from_value(v)?), + "balance" => b.balance = Some(FromValueOpt::from_value(v)?), + "country" => b.country = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "features" => b.features = Some(FromValueOpt::from_value(v)?), + "financial_addresses" => b.financial_addresses = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "pending_features" => b.pending_features = Some(FromValueOpt::from_value(v)?), + "platform_restrictions" => b.platform_restrictions = Some(FromValueOpt::from_value(v)?), + "restricted_features" => b.restricted_features = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_details" => b.status_details = Some(FromValueOpt::from_value(v)?), + "supported_currencies" => b.supported_currencies = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The enum specifying what state the account is in. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountStatus { @@ -89,11 +258,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryFinancialAccountStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountStatus); impl stripe_types::Object for TreasuryFinancialAccount { type Id = stripe_treasury::TreasuryFinancialAccountId; fn id(&self) -> &Self::Id { @@ -174,8 +359,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountArray { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryFinancialAccountArray") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountArray")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountArray { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountArray> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountArray::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountArray); diff --git a/generated/stripe_treasury/src/treasury_financial_account_features.rs b/generated/stripe_treasury/src/treasury_financial_account_features.rs index 3a461ef13..8ede7bfc6 100644 --- a/generated/stripe_treasury/src/treasury_financial_account_features.rs +++ b/generated/stripe_treasury/src/treasury_financial_account_features.rs @@ -1,24 +1,132 @@ /// Encodes whether a FinancialAccount has access to a particular Feature, with a `status` enum and associated `status_details`. /// Stripe or the platform can control Features via the requested field. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountFeatures { - #[serde(skip_serializing_if = "Option::is_none")] pub card_issuing: Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>, - #[serde(skip_serializing_if = "Option::is_none")] pub deposit_insurance: Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>, - #[serde(skip_serializing_if = "Option::is_none")] - pub financial_addresses: - Option<stripe_treasury::TreasuryFinancialAccountsResourceFinancialAddressesFeatures>, - #[serde(skip_serializing_if = "Option::is_none")] - pub inbound_transfers: - Option<stripe_treasury::TreasuryFinancialAccountsResourceInboundTransfers>, - #[serde(skip_serializing_if = "Option::is_none")] - pub intra_stripe_flows: - Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>, - #[serde(skip_serializing_if = "Option::is_none")] - pub outbound_payments: - Option<stripe_treasury::TreasuryFinancialAccountsResourceOutboundPayments>, - #[serde(skip_serializing_if = "Option::is_none")] - pub outbound_transfers: - Option<stripe_treasury::TreasuryFinancialAccountsResourceOutboundTransfers>, + pub financial_addresses: Option<stripe_treasury::TreasuryFinancialAccountsResourceFinancialAddressesFeatures>, + pub inbound_transfers: Option<stripe_treasury::TreasuryFinancialAccountsResourceInboundTransfers>, + pub intra_stripe_flows: Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>, + pub outbound_payments: Option<stripe_treasury::TreasuryFinancialAccountsResourceOutboundPayments>, + pub outbound_transfers: Option<stripe_treasury::TreasuryFinancialAccountsResourceOutboundTransfers>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountFeaturesBuilder { + card_issuing: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>>, + deposit_insurance: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>>, + financial_addresses: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceFinancialAddressesFeatures>>, + inbound_transfers: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceInboundTransfers>>, + intra_stripe_flows: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>>, + outbound_payments: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceOutboundPayments>>, + outbound_transfers: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceOutboundTransfers>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountFeatures { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountFeatures>, + builder: TreasuryFinancialAccountFeaturesBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountFeatures> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountFeaturesBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountFeaturesBuilder { + type Out = TreasuryFinancialAccountFeatures; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "card_issuing" => Deserialize::begin(&mut self.card_issuing), + "deposit_insurance" => Deserialize::begin(&mut self.deposit_insurance), + "financial_addresses" => Deserialize::begin(&mut self.financial_addresses), + "inbound_transfers" => Deserialize::begin(&mut self.inbound_transfers), + "intra_stripe_flows" => Deserialize::begin(&mut self.intra_stripe_flows), + "outbound_payments" => Deserialize::begin(&mut self.outbound_payments), + "outbound_transfers" => Deserialize::begin(&mut self.outbound_transfers), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + card_issuing: Deserialize::default(), + deposit_insurance: Deserialize::default(), + financial_addresses: Deserialize::default(), + inbound_transfers: Deserialize::default(), + intra_stripe_flows: Deserialize::default(), + outbound_payments: Deserialize::default(), + outbound_transfers: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let card_issuing = self.card_issuing.take()?; + let deposit_insurance = self.deposit_insurance.take()?; + let financial_addresses = self.financial_addresses.take()?; + let inbound_transfers = self.inbound_transfers.take()?; + let intra_stripe_flows = self.intra_stripe_flows.take()?; + let outbound_payments = self.outbound_payments.take()?; + let outbound_transfers = self.outbound_transfers.take()?; + + Some(Self::Out { card_issuing, deposit_insurance, financial_addresses, inbound_transfers, intra_stripe_flows, outbound_payments, outbound_transfers }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountFeatures { + type Builder = TreasuryFinancialAccountFeaturesBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountFeatures { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountFeaturesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "card_issuing" => b.card_issuing = Some(FromValueOpt::from_value(v)?), + "deposit_insurance" => b.deposit_insurance = Some(FromValueOpt::from_value(v)?), + "financial_addresses" => b.financial_addresses = Some(FromValueOpt::from_value(v)?), + "inbound_transfers" => b.inbound_transfers = Some(FromValueOpt::from_value(v)?), + "intra_stripe_flows" => b.intra_stripe_flows = Some(FromValueOpt::from_value(v)?), + "outbound_payments" => b.outbound_payments = Some(FromValueOpt::from_value(v)?), + "outbound_transfers" => b.outbound_transfers = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_record.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_record.rs index 8cb667094..1afa64830 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_record.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_record.rs @@ -1,5 +1,7 @@ /// ABA Records contain U.S. bank account details per the ABA format. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceAbaRecord { /// The name of the person or business that owns the bank account. pub account_holder_name: String, @@ -12,3 +14,111 @@ pub struct TreasuryFinancialAccountsResourceAbaRecord { /// Routing number for the account. pub routing_number: String, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceAbaRecordBuilder { + account_holder_name: Option<String>, + account_number: Option<Option<String>>, + account_number_last4: Option<String>, + bank_name: Option<String>, + routing_number: Option<String>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceAbaRecord { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceAbaRecord>, + builder: TreasuryFinancialAccountsResourceAbaRecordBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceAbaRecord> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceAbaRecordBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceAbaRecordBuilder { + type Out = TreasuryFinancialAccountsResourceAbaRecord; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account_holder_name" => Deserialize::begin(&mut self.account_holder_name), + "account_number" => Deserialize::begin(&mut self.account_number), + "account_number_last4" => Deserialize::begin(&mut self.account_number_last4), + "bank_name" => Deserialize::begin(&mut self.bank_name), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_name: Deserialize::default(), + account_number: Deserialize::default(), + account_number_last4: Deserialize::default(), + bank_name: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let account_holder_name = self.account_holder_name.take()?; + let account_number = self.account_number.take()?; + let account_number_last4 = self.account_number_last4.take()?; + let bank_name = self.bank_name.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { account_holder_name, account_number, account_number_last4, bank_name, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceAbaRecord { + type Builder = TreasuryFinancialAccountsResourceAbaRecordBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceAbaRecord { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceAbaRecordBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_holder_name" => b.account_holder_name = Some(FromValueOpt::from_value(v)?), + "account_number" => b.account_number = Some(FromValueOpt::from_value(v)?), + "account_number_last4" => b.account_number_last4 = Some(FromValueOpt::from_value(v)?), + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_toggle_settings.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_toggle_settings.rs index 5d62705e9..5d4898fb0 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_toggle_settings.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_aba_toggle_settings.rs @@ -1,14 +1,109 @@ /// Toggle settings for enabling/disabling the ABA address feature -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceAbaToggleSettings { /// Whether the FinancialAccount should have the Feature. pub requested: bool, /// Whether the Feature is operational. pub status: TreasuryFinancialAccountsResourceAbaToggleSettingsStatus, /// Additional details; includes at least one entry when the status is not `active`. - pub status_details: - Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>, + pub status_details: Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder { + requested: Option<bool>, + status: Option<TreasuryFinancialAccountsResourceAbaToggleSettingsStatus>, + status_details: Option<Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceAbaToggleSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceAbaToggleSettings>, + builder: TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceAbaToggleSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder { + type Out = TreasuryFinancialAccountsResourceAbaToggleSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "requested" => Deserialize::begin(&mut self.requested), + "status" => Deserialize::begin(&mut self.status), + "status_details" => Deserialize::begin(&mut self.status_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { requested: Deserialize::default(), status: Deserialize::default(), status_details: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let requested = self.requested.take()?; + let status = self.status.take()?; + let status_details = self.status_details.take()?; + + Some(Self::Out { requested, status, status_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceAbaToggleSettings { + type Builder = TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceAbaToggleSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "requested" => b.requested = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_details" => b.status_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether the Feature is operational. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceAbaToggleSettingsStatus { @@ -62,10 +157,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceAbaToggle fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryFinancialAccountsResourceAbaToggleSettingsStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceAbaToggleSettingsStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceAbaToggleSettingsStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceAbaToggleSettingsStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceAbaToggleSettingsStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceAbaToggleSettingsStatus); diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_ach_toggle_settings.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_ach_toggle_settings.rs index 7200910eb..b29f1f594 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_ach_toggle_settings.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_ach_toggle_settings.rs @@ -1,14 +1,109 @@ /// Toggle settings for enabling/disabling an ACH specific feature -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceAchToggleSettings { /// Whether the FinancialAccount should have the Feature. pub requested: bool, /// Whether the Feature is operational. pub status: TreasuryFinancialAccountsResourceAchToggleSettingsStatus, /// Additional details; includes at least one entry when the status is not `active`. - pub status_details: - Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>, + pub status_details: Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceAchToggleSettingsBuilder { + requested: Option<bool>, + status: Option<TreasuryFinancialAccountsResourceAchToggleSettingsStatus>, + status_details: Option<Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceAchToggleSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceAchToggleSettings>, + builder: TreasuryFinancialAccountsResourceAchToggleSettingsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceAchToggleSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceAchToggleSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceAchToggleSettingsBuilder { + type Out = TreasuryFinancialAccountsResourceAchToggleSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "requested" => Deserialize::begin(&mut self.requested), + "status" => Deserialize::begin(&mut self.status), + "status_details" => Deserialize::begin(&mut self.status_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { requested: Deserialize::default(), status: Deserialize::default(), status_details: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let requested = self.requested.take()?; + let status = self.status.take()?; + let status_details = self.status_details.take()?; + + Some(Self::Out { requested, status, status_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceAchToggleSettings { + type Builder = TreasuryFinancialAccountsResourceAchToggleSettingsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceAchToggleSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceAchToggleSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "requested" => b.requested = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_details" => b.status_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether the Feature is operational. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceAchToggleSettingsStatus { @@ -62,10 +157,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceAchToggle fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryFinancialAccountsResourceAchToggleSettingsStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceAchToggleSettingsStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceAchToggleSettingsStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceAchToggleSettingsStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceAchToggleSettingsStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceAchToggleSettingsStatus); diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_balance.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_balance.rs index e24b30e80..dc211f2ac 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_balance.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_balance.rs @@ -1,5 +1,7 @@ /// Balance information for the FinancialAccount -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceBalance { /// Funds the user can spend right now. pub cash: std::collections::HashMap<String, i64>, @@ -8,3 +10,97 @@ pub struct TreasuryFinancialAccountsResourceBalance { /// Funds in the account, but not spendable because they are being held for pending outbound flows. pub outbound_pending: std::collections::HashMap<String, i64>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceBalanceBuilder { + cash: Option<std::collections::HashMap<String, i64>>, + inbound_pending: Option<std::collections::HashMap<String, i64>>, + outbound_pending: Option<std::collections::HashMap<String, i64>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceBalance>, + builder: TreasuryFinancialAccountsResourceBalanceBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceBalance> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceBalanceBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceBalanceBuilder { + type Out = TreasuryFinancialAccountsResourceBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "cash" => Deserialize::begin(&mut self.cash), + "inbound_pending" => Deserialize::begin(&mut self.inbound_pending), + "outbound_pending" => Deserialize::begin(&mut self.outbound_pending), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { cash: Deserialize::default(), inbound_pending: Deserialize::default(), outbound_pending: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let cash = self.cash.take()?; + let inbound_pending = self.inbound_pending.take()?; + let outbound_pending = self.outbound_pending.take()?; + + Some(Self::Out { cash, inbound_pending, outbound_pending }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceBalance { + type Builder = TreasuryFinancialAccountsResourceBalanceBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceBalance { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "cash" => b.cash = Some(FromValueOpt::from_value(v)?), + "inbound_pending" => b.inbound_pending = Some(FromValueOpt::from_value(v)?), + "outbound_pending" => b.outbound_pending = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_closed_status_details.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_closed_status_details.rs index 29cd3d10e..eb2b395fe 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_closed_status_details.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_closed_status_details.rs @@ -1,8 +1,96 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceClosedStatusDetails { /// The array that contains reasons for a FinancialAccount closure. pub reasons: Vec<TreasuryFinancialAccountsResourceClosedStatusDetailsReasons>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder { + reasons: Option<Vec<TreasuryFinancialAccountsResourceClosedStatusDetailsReasons>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceClosedStatusDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceClosedStatusDetails>, + builder: TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceClosedStatusDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder { + type Out = TreasuryFinancialAccountsResourceClosedStatusDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reasons" => Deserialize::begin(&mut self.reasons), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reasons: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let reasons = self.reasons.take()?; + + Some(Self::Out { reasons }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceClosedStatusDetails { + type Builder = TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceClosedStatusDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reasons" => b.reasons = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The array that contains reasons for a FinancialAccount closure. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceClosedStatusDetailsReasons { @@ -56,10 +144,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceClosedSta fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryFinancialAccountsResourceClosedStatusDetailsReasons", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceClosedStatusDetailsReasons")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceClosedStatusDetailsReasons { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceClosedStatusDetailsReasons> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceClosedStatusDetailsReasons::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceClosedStatusDetailsReasons); diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_address.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_address.rs index 1ee47e7cf..746462d60 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_address.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_address.rs @@ -1,16 +1,109 @@ /// FinancialAddresses contain identifying information that resolves to a FinancialAccount. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceFinancialAddress { - #[serde(skip_serializing_if = "Option::is_none")] pub aba: Option<stripe_treasury::TreasuryFinancialAccountsResourceAbaRecord>, /// The list of networks that the address supports - #[serde(skip_serializing_if = "Option::is_none")] - pub supported_networks: - Option<Vec<TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks>>, + pub supported_networks: Option<Vec<TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks>>, /// The type of financial address - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TreasuryFinancialAccountsResourceFinancialAddressType, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceFinancialAddressBuilder { + aba: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceAbaRecord>>, + supported_networks: Option<Option<Vec<TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks>>>, + type_: Option<TreasuryFinancialAccountsResourceFinancialAddressType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceFinancialAddress { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceFinancialAddress>, + builder: TreasuryFinancialAccountsResourceFinancialAddressBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceFinancialAddress> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceFinancialAddressBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceFinancialAddressBuilder { + type Out = TreasuryFinancialAccountsResourceFinancialAddress; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "aba" => Deserialize::begin(&mut self.aba), + "supported_networks" => Deserialize::begin(&mut self.supported_networks), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { aba: Deserialize::default(), supported_networks: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let aba = self.aba.take()?; + let supported_networks = self.supported_networks.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { aba, supported_networks, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceFinancialAddress { + type Builder = TreasuryFinancialAccountsResourceFinancialAddressBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceFinancialAddress { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceFinancialAddressBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "aba" => b.aba = Some(FromValueOpt::from_value(v)?), + "supported_networks" => b.supported_networks = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The list of networks that the address supports #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks { @@ -57,15 +150,31 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceFinancialAddressSuppo serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks -{ +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks); /// The type of financial address #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceFinancialAddressType { @@ -113,10 +222,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceFinancial fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryFinancialAccountsResourceFinancialAddressType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceFinancialAddressType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceFinancialAddressType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceFinancialAddressType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceFinancialAddressType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceFinancialAddressType); diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_addresses_features.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_addresses_features.rs index 20f75b4de..144005ec3 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_addresses_features.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_financial_addresses_features.rs @@ -1,6 +1,93 @@ /// Settings related to Financial Addresses features on a Financial Account -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceFinancialAddressesFeatures { - #[serde(skip_serializing_if = "Option::is_none")] pub aba: Option<stripe_treasury::TreasuryFinancialAccountsResourceAbaToggleSettings>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder { + aba: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceAbaToggleSettings>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceFinancialAddressesFeatures { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceFinancialAddressesFeatures>, + builder: TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceFinancialAddressesFeatures> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder { + type Out = TreasuryFinancialAccountsResourceFinancialAddressesFeatures; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "aba" => Deserialize::begin(&mut self.aba), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { aba: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let aba = self.aba.take()?; + + Some(Self::Out { aba }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceFinancialAddressesFeatures { + type Builder = TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceFinancialAddressesFeatures { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "aba" => b.aba = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_inbound_transfers.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_inbound_transfers.rs index 666a4f695..2ed39bf3a 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_inbound_transfers.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_inbound_transfers.rs @@ -1,6 +1,93 @@ /// InboundTransfers contains inbound transfers features for a FinancialAccount. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceInboundTransfers { - #[serde(skip_serializing_if = "Option::is_none")] pub ach: Option<stripe_treasury::TreasuryFinancialAccountsResourceAchToggleSettings>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceInboundTransfersBuilder { + ach: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceAchToggleSettings>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceInboundTransfers { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceInboundTransfers>, + builder: TreasuryFinancialAccountsResourceInboundTransfersBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceInboundTransfers> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceInboundTransfersBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceInboundTransfersBuilder { + type Out = TreasuryFinancialAccountsResourceInboundTransfers; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ach" => Deserialize::begin(&mut self.ach), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ach: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ach = self.ach.take()?; + + Some(Self::Out { ach }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceInboundTransfers { + type Builder = TreasuryFinancialAccountsResourceInboundTransfersBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceInboundTransfers { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceInboundTransfersBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ach" => b.ach = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_payments.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_payments.rs index 9deb349ad..3451609f0 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_payments.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_payments.rs @@ -1,8 +1,98 @@ /// Settings related to Outbound Payments features on a Financial Account -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceOutboundPayments { - #[serde(skip_serializing_if = "Option::is_none")] pub ach: Option<stripe_treasury::TreasuryFinancialAccountsResourceAchToggleSettings>, - #[serde(skip_serializing_if = "Option::is_none")] pub us_domestic_wire: Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceOutboundPaymentsBuilder { + ach: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceAchToggleSettings>>, + us_domestic_wire: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceOutboundPayments { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceOutboundPayments>, + builder: TreasuryFinancialAccountsResourceOutboundPaymentsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceOutboundPayments> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceOutboundPaymentsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceOutboundPaymentsBuilder { + type Out = TreasuryFinancialAccountsResourceOutboundPayments; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ach" => Deserialize::begin(&mut self.ach), + "us_domestic_wire" => Deserialize::begin(&mut self.us_domestic_wire), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ach: Deserialize::default(), us_domestic_wire: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ach = self.ach.take()?; + let us_domestic_wire = self.us_domestic_wire.take()?; + + Some(Self::Out { ach, us_domestic_wire }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceOutboundPayments { + type Builder = TreasuryFinancialAccountsResourceOutboundPaymentsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceOutboundPayments { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceOutboundPaymentsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ach" => b.ach = Some(FromValueOpt::from_value(v)?), + "us_domestic_wire" => b.us_domestic_wire = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_transfers.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_transfers.rs index c9a0abe03..3a40cdc29 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_transfers.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_outbound_transfers.rs @@ -1,8 +1,98 @@ /// OutboundTransfers contains outbound transfers features for a FinancialAccount. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceOutboundTransfers { - #[serde(skip_serializing_if = "Option::is_none")] pub ach: Option<stripe_treasury::TreasuryFinancialAccountsResourceAchToggleSettings>, - #[serde(skip_serializing_if = "Option::is_none")] pub us_domestic_wire: Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceOutboundTransfersBuilder { + ach: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceAchToggleSettings>>, + us_domestic_wire: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceToggleSettings>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceOutboundTransfers { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceOutboundTransfers>, + builder: TreasuryFinancialAccountsResourceOutboundTransfersBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceOutboundTransfers> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceOutboundTransfersBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceOutboundTransfersBuilder { + type Out = TreasuryFinancialAccountsResourceOutboundTransfers; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ach" => Deserialize::begin(&mut self.ach), + "us_domestic_wire" => Deserialize::begin(&mut self.us_domestic_wire), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ach: Deserialize::default(), us_domestic_wire: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ach = self.ach.take()?; + let us_domestic_wire = self.us_domestic_wire.take()?; + + Some(Self::Out { ach, us_domestic_wire }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceOutboundTransfers { + type Builder = TreasuryFinancialAccountsResourceOutboundTransfersBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceOutboundTransfers { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceOutboundTransfersBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ach" => b.ach = Some(FromValueOpt::from_value(v)?), + "us_domestic_wire" => b.us_domestic_wire = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_platform_restrictions.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_platform_restrictions.rs index 469e247d9..f38fcc51e 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_platform_restrictions.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_platform_restrictions.rs @@ -1,11 +1,103 @@ /// Restrictions that a Connect Platform has placed on this FinancialAccount. -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourcePlatformRestrictions { /// Restricts all inbound money movement. pub inbound_flows: Option<TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows>, /// Restricts all outbound money movement. pub outbound_flows: Option<TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder { + inbound_flows: Option<Option<TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows>>, + outbound_flows: Option<Option<TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourcePlatformRestrictions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourcePlatformRestrictions>, + builder: TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourcePlatformRestrictions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder { + type Out = TreasuryFinancialAccountsResourcePlatformRestrictions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "inbound_flows" => Deserialize::begin(&mut self.inbound_flows), + "outbound_flows" => Deserialize::begin(&mut self.outbound_flows), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { inbound_flows: Deserialize::default(), outbound_flows: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let inbound_flows = self.inbound_flows.take()?; + let outbound_flows = self.outbound_flows.take()?; + + Some(Self::Out { inbound_flows, outbound_flows }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourcePlatformRestrictions { + type Builder = TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourcePlatformRestrictions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "inbound_flows" => b.inbound_flows = Some(FromValueOpt::from_value(v)?), + "outbound_flows" => b.outbound_flows = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Restricts all inbound money movement. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows { @@ -52,15 +144,31 @@ impl serde::Serialize for TreasuryFinancialAccountsResourcePlatformRestrictionsI serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows -{ +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows); /// Restricts all outbound money movement. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows { @@ -107,12 +215,28 @@ impl serde::Serialize for TreasuryFinancialAccountsResourcePlatformRestrictionsO serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows -{ +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows); diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_status_details.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_status_details.rs index 9af0ca396..8e364ca22 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_status_details.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_status_details.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceStatusDetails { /// Details related to the closure of this FinancialAccount pub closed: Option<stripe_treasury::TreasuryFinancialAccountsResourceClosedStatusDetails>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceStatusDetailsBuilder { + closed: Option<Option<stripe_treasury::TreasuryFinancialAccountsResourceClosedStatusDetails>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceStatusDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceStatusDetails>, + builder: TreasuryFinancialAccountsResourceStatusDetailsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceStatusDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceStatusDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceStatusDetailsBuilder { + type Out = TreasuryFinancialAccountsResourceStatusDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "closed" => Deserialize::begin(&mut self.closed), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { closed: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let closed = self.closed.take()?; + + Some(Self::Out { closed }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceStatusDetails { + type Builder = TreasuryFinancialAccountsResourceStatusDetailsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceStatusDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceStatusDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "closed" => b.closed = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggle_settings.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggle_settings.rs index c36be9c5d..133bac584 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggle_settings.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggle_settings.rs @@ -1,14 +1,109 @@ /// Toggle settings for enabling/disabling a feature -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceToggleSettings { /// Whether the FinancialAccount should have the Feature. pub requested: bool, /// Whether the Feature is operational. pub status: TreasuryFinancialAccountsResourceToggleSettingsStatus, /// Additional details; includes at least one entry when the status is not `active`. - pub status_details: - Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>, + pub status_details: Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceToggleSettingsBuilder { + requested: Option<bool>, + status: Option<TreasuryFinancialAccountsResourceToggleSettingsStatus>, + status_details: Option<Vec<stripe_treasury::TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceToggleSettings { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceToggleSettings>, + builder: TreasuryFinancialAccountsResourceToggleSettingsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceToggleSettings> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceToggleSettingsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceToggleSettingsBuilder { + type Out = TreasuryFinancialAccountsResourceToggleSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "requested" => Deserialize::begin(&mut self.requested), + "status" => Deserialize::begin(&mut self.status), + "status_details" => Deserialize::begin(&mut self.status_details), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { requested: Deserialize::default(), status: Deserialize::default(), status_details: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let requested = self.requested.take()?; + let status = self.status.take()?; + let status_details = self.status_details.take()?; + + Some(Self::Out { requested, status, status_details }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceToggleSettings { + type Builder = TreasuryFinancialAccountsResourceToggleSettingsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceToggleSettings { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceToggleSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "requested" => b.requested = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_details" => b.status_details = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Whether the Feature is operational. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceToggleSettingsStatus { @@ -62,10 +157,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceToggleSet fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryFinancialAccountsResourceToggleSettingsStatus", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceToggleSettingsStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceToggleSettingsStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceToggleSettingsStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceToggleSettingsStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceToggleSettingsStatus); diff --git a/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggles_setting_status_details.rs b/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggles_setting_status_details.rs index a9730ced8..c9da00174 100644 --- a/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggles_setting_status_details.rs +++ b/generated/stripe_treasury/src/treasury_financial_accounts_resource_toggles_setting_status_details.rs @@ -1,15 +1,109 @@ /// Additional details on the FinancialAccount Features information. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryFinancialAccountsResourceTogglesSettingStatusDetails { /// Represents the reason why the status is `pending` or `restricted`. pub code: TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode, /// Represents what the user should do, if anything, to activate the Feature. pub resolution: Option<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution>, /// The `platform_restrictions` that are restricting this Feature. - #[serde(skip_serializing_if = "Option::is_none")] - pub restriction: - Option<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction>, + pub restriction: Option<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder { + code: Option<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode>, + resolution: Option<Option<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution>>, + restriction: Option<Option<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryFinancialAccountsResourceTogglesSettingStatusDetails>, + builder: TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder, + } + + impl Visitor for Place<TreasuryFinancialAccountsResourceTogglesSettingStatusDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder { + type Out = TreasuryFinancialAccountsResourceTogglesSettingStatusDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "resolution" => Deserialize::begin(&mut self.resolution), + "restriction" => Deserialize::begin(&mut self.restriction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), resolution: Deserialize::default(), restriction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let resolution = self.resolution.take()?; + let restriction = self.restriction.take()?; + + Some(Self::Out { code, resolution, restriction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryFinancialAccountsResourceTogglesSettingStatusDetails { + type Builder = TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder; + } + + impl FromValueOpt for TreasuryFinancialAccountsResourceTogglesSettingStatusDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "resolution" => b.resolution = Some(FromValueOpt::from_value(v)?), + "restriction" => b.restriction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Represents the reason why the status is `pending` or `restricted`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode { @@ -77,15 +171,31 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusD serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode -{ +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode); /// Represents what the user should do, if anything, to activate the Feature. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution { @@ -135,15 +245,31 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusD serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution -{ +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution); /// The `platform_restrictions` that are restricting this Feature. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction { @@ -190,12 +316,28 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusD serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction -{ +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction); diff --git a/generated/stripe_treasury/src/treasury_inbound_transfer/requests.rs b/generated/stripe_treasury/src/treasury_inbound_transfer/requests.rs index 827f865be..6e80d6981 100644 --- a/generated/stripe_treasury/src/treasury_inbound_transfer/requests.rs +++ b/generated/stripe_treasury/src/treasury_inbound_transfer/requests.rs @@ -1,3 +1,75 @@ +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CancelTreasuryInboundTransfer<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> CancelTreasuryInboundTransfer<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> CancelTreasuryInboundTransfer<'a> { + /// Cancels an InboundTransfer. + pub fn send(&self, client: &stripe::Client, inbound_transfer: &stripe_treasury::TreasuryInboundTransferId) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { + client.send_form(&format!("/treasury/inbound_transfers/{inbound_transfer}/cancel"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct CreateTreasuryInboundTransfer<'a> { + /// Amount (in cents) to be transferred. + pub amount: i64, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + pub currency: stripe_types::Currency, + /// An arbitrary string attached to the object. Often useful for displaying to users. + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// The FinancialAccount to send funds to. + pub financial_account: &'a str, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// The origin payment method to be debited for the InboundTransfer. + pub origin_payment_method: &'a str, + /// The complete description that appears on your customers' statements. Maximum 10 characters. + #[serde(skip_serializing_if = "Option::is_none")] + pub statement_descriptor: Option<&'a str>, +} +impl<'a> CreateTreasuryInboundTransfer<'a> { + pub fn new(amount: i64, currency: stripe_types::Currency, financial_account: &'a str, origin_payment_method: &'a str) -> Self { + Self { amount, currency, description: None, expand: None, financial_account, metadata: None, origin_payment_method, statement_descriptor: None } + } +} +impl<'a> CreateTreasuryInboundTransfer<'a> { + /// Creates an InboundTransfer. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { + client.send_form("/treasury/inbound_transfers", self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTreasuryInboundTransfer<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTreasuryInboundTransfer<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTreasuryInboundTransfer<'a> { + /// Retrieves the details of an existing InboundTransfer. + pub fn send(&self, client: &stripe::Client, id: &stripe_treasury::TreasuryInboundTransferId) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { + client.get_query(&format!("/treasury/inbound_transfers/{id}"), self) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ListTreasuryInboundTransfer<'a> { /// A cursor for use in pagination. @@ -25,49 +97,34 @@ pub struct ListTreasuryInboundTransfer<'a> { } impl<'a> ListTreasuryInboundTransfer<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - ending_before: None, - expand: None, - financial_account, - limit: None, - starting_after: None, - status: None, - } + Self { ending_before: None, expand: None, financial_account, limit: None, starting_after: None, status: None } } } impl<'a> ListTreasuryInboundTransfer<'a> { /// Returns a list of InboundTransfers sent from the specified FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryInboundTransfer>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryInboundTransfer>> { client.get_query("/treasury/inbound_transfers", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryInboundTransfer>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryInboundTransfer>> { stripe::ListPaginator::from_list_params("/treasury/inbound_transfers", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTreasuryInboundTransfer<'a> { +pub struct SucceedTreasuryInboundTransfer<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> RetrieveTreasuryInboundTransfer<'a> { +impl<'a> SucceedTreasuryInboundTransfer<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> RetrieveTreasuryInboundTransfer<'a> { - /// Retrieves the details of an existing InboundTransfer. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_treasury::TreasuryInboundTransferId, - ) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { - client.get_query(&format!("/treasury/inbound_transfers/{id}"), self) +impl<'a> SucceedTreasuryInboundTransfer<'a> { + /// Transitions a test mode created InboundTransfer to the `succeeded` status. + /// The InboundTransfer must already be in the `processing` state. + pub fn send(&self, client: &stripe::Client, id: &str) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { + client.send_form(&format!("/test_helpers/treasury/inbound_transfers/{id}/succeed"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -182,16 +239,8 @@ impl serde::Serialize for FailTreasuryInboundTransferFailureDetailsCode { impl<'a> FailTreasuryInboundTransfer<'a> { /// Transitions a test mode created InboundTransfer to the `failed` status. /// The InboundTransfer must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - ) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { - client.send_form( - &format!("/test_helpers/treasury/inbound_transfers/{id}/fail"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, id: &str) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { + client.send_form(&format!("/test_helpers/treasury/inbound_transfers/{id}/fail"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -208,121 +257,7 @@ impl<'a> ReturnInboundTransferTreasuryInboundTransfer<'a> { impl<'a> ReturnInboundTransferTreasuryInboundTransfer<'a> { /// Marks the test mode InboundTransfer object as returned and links the InboundTransfer to a ReceivedDebit. /// The InboundTransfer must already be in the `succeeded` state. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - ) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { - client.send_form( - &format!("/test_helpers/treasury/inbound_transfers/{id}/return"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct SucceedTreasuryInboundTransfer<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> SucceedTreasuryInboundTransfer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> SucceedTreasuryInboundTransfer<'a> { - /// Transitions a test mode created InboundTransfer to the `succeeded` status. - /// The InboundTransfer must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - ) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { - client.send_form( - &format!("/test_helpers/treasury/inbound_transfers/{id}/succeed"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateTreasuryInboundTransfer<'a> { - /// Amount (in cents) to be transferred. - pub amount: i64, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// An arbitrary string attached to the object. Often useful for displaying to users. - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// The FinancialAccount to send funds to. - pub financial_account: &'a str, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// The origin payment method to be debited for the InboundTransfer. - pub origin_payment_method: &'a str, - /// The complete description that appears on your customers' statements. Maximum 10 characters. - #[serde(skip_serializing_if = "Option::is_none")] - pub statement_descriptor: Option<&'a str>, -} -impl<'a> CreateTreasuryInboundTransfer<'a> { - pub fn new( - amount: i64, - currency: stripe_types::Currency, - financial_account: &'a str, - origin_payment_method: &'a str, - ) -> Self { - Self { - amount, - currency, - description: None, - expand: None, - financial_account, - metadata: None, - origin_payment_method, - statement_descriptor: None, - } - } -} -impl<'a> CreateTreasuryInboundTransfer<'a> { - /// Creates an InboundTransfer. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { - client.send_form("/treasury/inbound_transfers", self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelTreasuryInboundTransfer<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CancelTreasuryInboundTransfer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CancelTreasuryInboundTransfer<'a> { - /// Cancels an InboundTransfer. - pub fn send( - &self, - client: &stripe::Client, - inbound_transfer: &stripe_treasury::TreasuryInboundTransferId, - ) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { - client.send_form( - &format!("/treasury/inbound_transfers/{inbound_transfer}/cancel"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, id: &str) -> stripe::Response<stripe_treasury::TreasuryInboundTransfer> { + client.send_form(&format!("/test_helpers/treasury/inbound_transfers/{id}/return"), self, http_types::Method::Post) } } diff --git a/generated/stripe_treasury/src/treasury_inbound_transfer/types.rs b/generated/stripe_treasury/src/treasury_inbound_transfer/types.rs index 81965670f..e7e3222f2 100644 --- a/generated/stripe_treasury/src/treasury_inbound_transfer/types.rs +++ b/generated/stripe_treasury/src/treasury_inbound_transfer/types.rs @@ -1,6 +1,8 @@ /// Use [InboundTransfers](https://stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers) to add funds to your [FinancialAccount](https://stripe.com/docs/api#financial_accounts) via a PaymentMethod that is owned by you. /// The funds will be transferred via an ACH debit. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryInboundTransfer { /// Amount (in cents) transferred. pub amount: i64, @@ -21,8 +23,7 @@ pub struct TreasuryInboundTransfer { pub hosted_regulatory_receipt_url: Option<String>, /// Unique identifier for the object. pub id: stripe_treasury::TreasuryInboundTransferId, - pub linked_flows: - stripe_treasury::TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows, + pub linked_flows: stripe_treasury::TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. @@ -42,11 +43,208 @@ pub struct TreasuryInboundTransfer { /// The status changes to `succeeded` once the funds have been "confirmed" and a `transaction` is created and posted. /// The status changes to `failed` if the transfer fails. pub status: stripe_treasury::TreasuryInboundTransferStatus, - pub status_transitions: - stripe_treasury::TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions, + pub status_transitions: stripe_treasury::TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions, /// The Transaction associated with this object. pub transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryInboundTransferBuilder { + amount: Option<i64>, + cancelable: Option<bool>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + failure_details: Option<Option<stripe_treasury::TreasuryInboundTransfersResourceFailureDetails>>, + financial_account: Option<String>, + hosted_regulatory_receipt_url: Option<Option<String>>, + id: Option<stripe_treasury::TreasuryInboundTransferId>, + linked_flows: Option<stripe_treasury::TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + origin_payment_method: Option<String>, + origin_payment_method_details: Option<Option<stripe_treasury::InboundTransfers>>, + returned: Option<Option<bool>>, + statement_descriptor: Option<String>, + status: Option<stripe_treasury::TreasuryInboundTransferStatus>, + status_transitions: Option<stripe_treasury::TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions>, + transaction: Option<Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryInboundTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryInboundTransfer>, + builder: TreasuryInboundTransferBuilder, + } + + impl Visitor for Place<TreasuryInboundTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryInboundTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryInboundTransferBuilder { + type Out = TreasuryInboundTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "cancelable" => Deserialize::begin(&mut self.cancelable), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "failure_details" => Deserialize::begin(&mut self.failure_details), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "hosted_regulatory_receipt_url" => Deserialize::begin(&mut self.hosted_regulatory_receipt_url), + "id" => Deserialize::begin(&mut self.id), + "linked_flows" => Deserialize::begin(&mut self.linked_flows), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "origin_payment_method" => Deserialize::begin(&mut self.origin_payment_method), + "origin_payment_method_details" => Deserialize::begin(&mut self.origin_payment_method_details), + "returned" => Deserialize::begin(&mut self.returned), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + cancelable: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + failure_details: Deserialize::default(), + financial_account: Deserialize::default(), + hosted_regulatory_receipt_url: Deserialize::default(), + id: Deserialize::default(), + linked_flows: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + origin_payment_method: Deserialize::default(), + origin_payment_method_details: Deserialize::default(), + returned: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let cancelable = self.cancelable.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let failure_details = self.failure_details.take()?; + let financial_account = self.financial_account.take()?; + let hosted_regulatory_receipt_url = self.hosted_regulatory_receipt_url.take()?; + let id = self.id.take()?; + let linked_flows = self.linked_flows.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let origin_payment_method = self.origin_payment_method.take()?; + let origin_payment_method_details = self.origin_payment_method_details.take()?; + let returned = self.returned.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { + amount, + cancelable, + created, + currency, + description, + failure_details, + financial_account, + hosted_regulatory_receipt_url, + id, + linked_flows, + livemode, + metadata, + origin_payment_method, + origin_payment_method_details, + returned, + statement_descriptor, + status, + status_transitions, + transaction, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryInboundTransfer { + type Builder = TreasuryInboundTransferBuilder; + } + + impl FromValueOpt for TreasuryInboundTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryInboundTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "cancelable" => b.cancelable = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "failure_details" => b.failure_details = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "hosted_regulatory_receipt_url" => b.hosted_regulatory_receipt_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "linked_flows" => b.linked_flows = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "origin_payment_method" => b.origin_payment_method = Some(FromValueOpt::from_value(v)?), + "origin_payment_method_details" => b.origin_payment_method_details = Some(FromValueOpt::from_value(v)?), + "returned" => b.returned = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TreasuryInboundTransfer { type Id = stripe_treasury::TreasuryInboundTransferId; fn id(&self) -> &Self::Id { @@ -109,8 +307,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryInboundTransferStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryInboundTransferStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryInboundTransferStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryInboundTransferStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryInboundTransferStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryInboundTransferStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryInboundTransferStatus); diff --git a/generated/stripe_treasury/src/treasury_inbound_transfers_resource_failure_details.rs b/generated/stripe_treasury/src/treasury_inbound_transfers_resource_failure_details.rs index 8bd02e372..78a758aa8 100644 --- a/generated/stripe_treasury/src/treasury_inbound_transfers_resource_failure_details.rs +++ b/generated/stripe_treasury/src/treasury_inbound_transfers_resource_failure_details.rs @@ -1,8 +1,96 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryInboundTransfersResourceFailureDetails { /// Reason for the failure. pub code: TreasuryInboundTransfersResourceFailureDetailsCode, } +#[cfg(feature = "min-ser")] +pub struct TreasuryInboundTransfersResourceFailureDetailsBuilder { + code: Option<TreasuryInboundTransfersResourceFailureDetailsCode>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryInboundTransfersResourceFailureDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryInboundTransfersResourceFailureDetails>, + builder: TreasuryInboundTransfersResourceFailureDetailsBuilder, + } + + impl Visitor for Place<TreasuryInboundTransfersResourceFailureDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryInboundTransfersResourceFailureDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryInboundTransfersResourceFailureDetailsBuilder { + type Out = TreasuryInboundTransfersResourceFailureDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + + Some(Self::Out { code }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryInboundTransfersResourceFailureDetails { + type Builder = TreasuryInboundTransfersResourceFailureDetailsBuilder; + } + + impl FromValueOpt for TreasuryInboundTransfersResourceFailureDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryInboundTransfersResourceFailureDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for the failure. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -90,7 +178,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryInboundTransfersResourceFailureDet fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s) - .unwrap_or(TreasuryInboundTransfersResourceFailureDetailsCode::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryInboundTransfersResourceFailureDetailsCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryInboundTransfersResourceFailureDetailsCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryInboundTransfersResourceFailureDetailsCode::from_str(s).unwrap_or(TreasuryInboundTransfersResourceFailureDetailsCode::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryInboundTransfersResourceFailureDetailsCode); diff --git a/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_linked_flows.rs b/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_linked_flows.rs index cb81ee4fa..716ad06f7 100644 --- a/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_linked_flows.rs +++ b/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_linked_flows.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows { /// If funds for this flow were returned after the flow went to the `succeeded` state, this field contains a reference to the ReceivedDebit return. pub received_debit: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder { + received_debit: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows>, + builder: TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder, + } + + impl Visitor for Place<TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder { + type Out = TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "received_debit" => Deserialize::begin(&mut self.received_debit), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { received_debit: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let received_debit = self.received_debit.take()?; + + Some(Self::Out { received_debit }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows { + type Builder = TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder; + } + + impl FromValueOpt for TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlows { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "received_debit" => b.received_debit = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_status_transitions.rs b/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_status_transitions.rs index 2f044fd44..ede2a7b82 100644 --- a/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_status_transitions.rs +++ b/generated/stripe_treasury/src/treasury_inbound_transfers_resource_inbound_transfer_resource_status_transitions.rs @@ -1,10 +1,105 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions { /// Timestamp describing when an InboundTransfer changed status to `canceled`. - #[serde(skip_serializing_if = "Option::is_none")] pub canceled_at: Option<stripe_types::Timestamp>, /// Timestamp describing when an InboundTransfer changed status to `failed`. pub failed_at: Option<stripe_types::Timestamp>, /// Timestamp describing when an InboundTransfer changed status to `succeeded`. pub succeeded_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder { + canceled_at: Option<Option<stripe_types::Timestamp>>, + failed_at: Option<Option<stripe_types::Timestamp>>, + succeeded_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions>, + builder: TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder, + } + + impl Visitor for Place<TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder { + type Out = TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "failed_at" => Deserialize::begin(&mut self.failed_at), + "succeeded_at" => Deserialize::begin(&mut self.succeeded_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { canceled_at: Deserialize::default(), failed_at: Deserialize::default(), succeeded_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let canceled_at = self.canceled_at.take()?; + let failed_at = self.failed_at.take()?; + let succeeded_at = self.succeeded_at.take()?; + + Some(Self::Out { canceled_at, failed_at, succeeded_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions { + type Builder = TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "failed_at" => b.failed_at = Some(FromValueOpt::from_value(v)?), + "succeeded_at" => b.succeeded_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_outbound_payment/requests.rs b/generated/stripe_treasury/src/treasury_outbound_payment/requests.rs index f189e6490..cc7e3fcc4 100644 --- a/generated/stripe_treasury/src/treasury_outbound_payment/requests.rs +++ b/generated/stripe_treasury/src/treasury_outbound_payment/requests.rs @@ -1,243 +1,4 @@ #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct ListTreasuryOutboundPayment<'a> { - /// Only return OutboundPayments sent to this customer. - #[serde(skip_serializing_if = "Option::is_none")] - pub customer: Option<&'a str>, - /// A cursor for use in pagination. - /// `ending_before` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub ending_before: Option<&'a str>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Returns objects associated with this FinancialAccount. - pub financial_account: &'a str, - /// A limit on the number of objects to be returned. - /// Limit can range between 1 and 100, and the default is 10. - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option<i64>, - /// A cursor for use in pagination. - /// `starting_after` is an object ID that defines your place in the list. - /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. - #[serde(skip_serializing_if = "Option::is_none")] - pub starting_after: Option<&'a str>, - /// Only return OutboundPayments that have the given status: `processing`, `failed`, `posted`, `returned`, or `canceled`. - #[serde(skip_serializing_if = "Option::is_none")] - pub status: Option<stripe_treasury::TreasuryOutboundPaymentStatus>, -} -impl<'a> ListTreasuryOutboundPayment<'a> { - pub fn new(financial_account: &'a str) -> Self { - Self { - customer: None, - ending_before: None, - expand: None, - financial_account, - limit: None, - starting_after: None, - status: None, - } - } -} -impl<'a> ListTreasuryOutboundPayment<'a> { - /// Returns a list of OutboundPayments sent from the specified FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryOutboundPayment>> { - client.get_query("/treasury/outbound_payments", self) - } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryOutboundPayment>> { - stripe::ListPaginator::from_list_params("/treasury/outbound_payments", self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTreasuryOutboundPayment<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveTreasuryOutboundPayment<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveTreasuryOutboundPayment<'a> { - /// Retrieves the details of an existing OutboundPayment by passing the unique OutboundPayment ID from either the OutboundPayment creation request or OutboundPayment list. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_treasury::TreasuryOutboundPaymentId, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { - client.get_query(&format!("/treasury/outbound_payments/{id}"), self) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct FailTreasuryOutboundPayment<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> FailTreasuryOutboundPayment<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> FailTreasuryOutboundPayment<'a> { - /// Transitions a test mode created OutboundPayment to the `failed` status. - /// The OutboundPayment must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { - client.send_form( - &format!("/test_helpers/treasury/outbound_payments/{id}/fail"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct PostTreasuryOutboundPayment<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> PostTreasuryOutboundPayment<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> PostTreasuryOutboundPayment<'a> { - /// Transitions a test mode created OutboundPayment to the `posted` status. - /// The OutboundPayment must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { - client.send_form( - &format!("/test_helpers/treasury/outbound_payments/{id}/post"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ReturnOutboundPaymentTreasuryOutboundPayment<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// Optional hash to set the the return code. - #[serde(skip_serializing_if = "Option::is_none")] - pub returned_details: Option<ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetails>, -} -impl<'a> ReturnOutboundPaymentTreasuryOutboundPayment<'a> { - pub fn new() -> Self { - Self::default() - } -} -/// Optional hash to set the the return code. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetails { - /// The return code to be set on the OutboundPayment object. - #[serde(skip_serializing_if = "Option::is_none")] - pub code: Option<ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode>, -} -impl ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetails { - pub fn new() -> Self { - Self::default() - } -} -/// The return code to be set on the OutboundPayment object. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { - AccountClosed, - AccountFrozen, - BankAccountRestricted, - BankOwnershipChanged, - Declined, - IncorrectAccountHolderName, - InvalidAccountNumber, - InvalidCurrency, - NoAccount, - Other, -} -impl ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { - pub fn as_str(self) -> &'static str { - use ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode::*; - match self { - AccountClosed => "account_closed", - AccountFrozen => "account_frozen", - BankAccountRestricted => "bank_account_restricted", - BankOwnershipChanged => "bank_ownership_changed", - Declined => "declined", - IncorrectAccountHolderName => "incorrect_account_holder_name", - InvalidAccountNumber => "invalid_account_number", - InvalidCurrency => "invalid_currency", - NoAccount => "no_account", - Other => "other", - } - } -} - -impl std::str::FromStr for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode::*; - match s { - "account_closed" => Ok(AccountClosed), - "account_frozen" => Ok(AccountFrozen), - "bank_account_restricted" => Ok(BankAccountRestricted), - "bank_ownership_changed" => Ok(BankOwnershipChanged), - "declined" => Ok(Declined), - "incorrect_account_holder_name" => Ok(IncorrectAccountHolderName), - "invalid_account_number" => Ok(InvalidAccountNumber), - "invalid_currency" => Ok(InvalidCurrency), - "no_account" => Ok(NoAccount), - "other" => Ok(Other), - _ => Err(()), - } - } -} -impl std::fmt::Display for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> ReturnOutboundPaymentTreasuryOutboundPayment<'a> { - /// Transitions a test mode created OutboundPayment to the `returned` status. - /// The OutboundPayment must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - id: &str, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { - client.send_form( - &format!("/test_helpers/treasury/outbound_payments/{id}/return"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTreasuryOutboundPayment<'a> { /// Amount (in cents) to be transferred. pub amount: i64, @@ -258,12 +19,10 @@ pub struct CreateTreasuryOutboundPayment<'a> { /// Hash used to generate the PaymentMethod to be used for this OutboundPayment. /// Exclusive with `destination_payment_method`. #[serde(skip_serializing_if = "Option::is_none")] - pub destination_payment_method_data: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodData<'a>>, + pub destination_payment_method_data: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodData<'a>>, /// Payment method-specific configuration for this OutboundPayment. #[serde(skip_serializing_if = "Option::is_none")] - pub destination_payment_method_options: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodOptions>, + pub destination_payment_method_options: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodOptions>, /// End user details. #[serde(skip_serializing_if = "Option::is_none")] pub end_user_details: Option<CreateTreasuryOutboundPaymentEndUserDetails<'a>>, @@ -279,8 +38,8 @@ pub struct CreateTreasuryOutboundPayment<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap<String, String>>, /// The description that appears on the receiving end for this OutboundPayment (for example, bank statement for external bank transfer). - /// Maximum 10 characters for `ach` payments, 140 characters for `us_domestic_wire` payments, or 500 characters for `stripe` network transfers. - /// The default value is "payment". + /// Maximum 10 characters for `ach` payments, 140 characters for `wire` payments, or 500 characters for `stripe` network transfers. + /// The default value is `payment`. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, } @@ -308,8 +67,7 @@ impl<'a> CreateTreasuryOutboundPayment<'a> { pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodData<'a> { /// Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods. #[serde(skip_serializing_if = "Option::is_none")] - pub billing_details: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataBillingDetails<'a>>, + pub billing_details: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataBillingDetails<'a>>, /// Required if type is set to `financial_account`. The FinancialAccount ID to send funds to. #[serde(skip_serializing_if = "Option::is_none")] pub financial_account: Option<&'a str>, @@ -322,22 +80,15 @@ pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodData<'a> { /// The type of the PaymentMethod. /// An additional hash is included on the PaymentMethod with a name matching this value. /// It contains additional information specific to the PaymentMethod type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTreasuryOutboundPaymentDestinationPaymentMethodDataType, /// Required hash if type is set to `us_bank_account`. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccount<'a>>, + pub us_bank_account: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccount<'a>>, } impl<'a> CreateTreasuryOutboundPaymentDestinationPaymentMethodData<'a> { pub fn new(type_: CreateTreasuryOutboundPaymentDestinationPaymentMethodDataType) -> Self { - Self { - billing_details: None, - financial_account: None, - metadata: None, - type_, - us_bank_account: None, - } + Self { billing_details: None, financial_account: None, metadata: None, type_, us_bank_account: None } } } /// Billing information associated with the PaymentMethod that may be used or required by particular types of payment methods. @@ -345,8 +96,7 @@ impl<'a> CreateTreasuryOutboundPaymentDestinationPaymentMethodData<'a> { pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodDataBillingDetails<'a> { /// Billing address. #[serde(skip_serializing_if = "Option::is_none")] - pub address: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataBillingDetailsAddress<'a>>, + pub address: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataBillingDetailsAddress<'a>>, /// Email address. #[serde(skip_serializing_if = "Option::is_none")] pub email: Option<&'a str>, @@ -442,16 +192,13 @@ impl serde::Serialize for CreateTreasuryOutboundPaymentDestinationPaymentMethodD pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccount<'a> { /// Account holder type: individual or company. #[serde(skip_serializing_if = "Option::is_none")] - pub account_holder_type: Option< - CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType, - >, + pub account_holder_type: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType>, /// Account number of the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option<&'a str>, /// Account type: checkings or savings. Defaults to checking if omitted. #[serde(skip_serializing_if = "Option::is_none")] - pub account_type: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType>, + pub account_type: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType>, /// The ID of a Financial Connections Account to use as a payment method. #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections_account: Option<&'a str>, @@ -480,9 +227,7 @@ impl CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccou } } -impl std::str::FromStr - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType -{ +impl std::str::FromStr for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType::*; @@ -493,24 +238,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType -{ +impl std::fmt::Display for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType -{ +impl std::fmt::Debug for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType -{ +impl serde::Serialize for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -534,9 +273,7 @@ impl CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccou } } -impl std::str::FromStr - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType -{ +impl std::str::FromStr for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType::*; @@ -547,24 +284,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType -{ +impl std::fmt::Display for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType -{ +impl std::fmt::Debug for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType -{ +impl serde::Serialize for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -577,8 +308,7 @@ impl serde::Serialize pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodOptions { /// Optional fields for `us_bank_account`. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccount>, + pub us_bank_account: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccount>, } impl CreateTreasuryOutboundPaymentDestinationPaymentMethodOptions { pub fn new() -> Self { @@ -591,8 +321,7 @@ pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAcc /// The US bank account network that must be used for this OutboundPayment. /// If not set, we will default to the PaymentMethod's preferred network. #[serde(skip_serializing_if = "Option::is_none")] - pub network: - Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork>, + pub network: Option<CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork>, } impl CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccount { pub fn new() -> Self { @@ -616,9 +345,7 @@ impl CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNe } } -impl std::str::FromStr - for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork -{ +impl std::str::FromStr for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork::*; @@ -629,24 +356,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork -{ +impl std::fmt::Display for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork -{ +impl std::fmt::Debug for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork -{ +impl serde::Serialize for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -672,14 +393,70 @@ impl<'a> CreateTreasuryOutboundPaymentEndUserDetails<'a> { } impl<'a> CreateTreasuryOutboundPayment<'a> { /// Creates an OutboundPayment. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { client.send_form("/treasury/outbound_payments", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTreasuryOutboundPayment<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTreasuryOutboundPayment<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTreasuryOutboundPayment<'a> { + /// Retrieves the details of an existing OutboundPayment by passing the unique OutboundPayment ID from either the OutboundPayment creation request or OutboundPayment list. + pub fn send(&self, client: &stripe::Client, id: &stripe_treasury::TreasuryOutboundPaymentId) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { + client.get_query(&format!("/treasury/outbound_payments/{id}"), self) + } +} +#[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct ListTreasuryOutboundPayment<'a> { + /// Only return OutboundPayments sent to this customer. + #[serde(skip_serializing_if = "Option::is_none")] + pub customer: Option<&'a str>, + /// A cursor for use in pagination. + /// `ending_before` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub ending_before: Option<&'a str>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Returns objects associated with this FinancialAccount. + pub financial_account: &'a str, + /// A limit on the number of objects to be returned. + /// Limit can range between 1 and 100, and the default is 10. + #[serde(skip_serializing_if = "Option::is_none")] + pub limit: Option<i64>, + /// A cursor for use in pagination. + /// `starting_after` is an object ID that defines your place in the list. + /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. + #[serde(skip_serializing_if = "Option::is_none")] + pub starting_after: Option<&'a str>, + /// Only return OutboundPayments that have the given status: `processing`, `failed`, `posted`, `returned`, or `canceled`. + #[serde(skip_serializing_if = "Option::is_none")] + pub status: Option<stripe_treasury::TreasuryOutboundPaymentStatus>, +} +impl<'a> ListTreasuryOutboundPayment<'a> { + pub fn new(financial_account: &'a str) -> Self { + Self { customer: None, ending_before: None, expand: None, financial_account, limit: None, starting_after: None, status: None } + } +} +impl<'a> ListTreasuryOutboundPayment<'a> { + /// Returns a list of OutboundPayments sent from the specified FinancialAccount. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryOutboundPayment>> { + client.get_query("/treasury/outbound_payments", self) + } + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryOutboundPayment>> { + stripe::ListPaginator::from_list_params("/treasury/outbound_payments", self) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CancelTreasuryOutboundPayment<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] @@ -692,15 +469,146 @@ impl<'a> CancelTreasuryOutboundPayment<'a> { } impl<'a> CancelTreasuryOutboundPayment<'a> { /// Cancel an OutboundPayment. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_treasury::TreasuryOutboundPaymentId, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { - client.send_form( - &format!("/treasury/outbound_payments/{id}/cancel"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, id: &stripe_treasury::TreasuryOutboundPaymentId) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { + client.send_form(&format!("/treasury/outbound_payments/{id}/cancel"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct FailTreasuryOutboundPayment<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> FailTreasuryOutboundPayment<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> FailTreasuryOutboundPayment<'a> { + /// Transitions a test mode created OutboundPayment to the `failed` status. + /// The OutboundPayment must already be in the `processing` state. + pub fn send(&self, client: &stripe::Client, id: &str) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { + client.send_form(&format!("/test_helpers/treasury/outbound_payments/{id}/fail"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct PostTreasuryOutboundPayment<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> PostTreasuryOutboundPayment<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> PostTreasuryOutboundPayment<'a> { + /// Transitions a test mode created OutboundPayment to the `posted` status. + /// The OutboundPayment must already be in the `processing` state. + pub fn send(&self, client: &stripe::Client, id: &str) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { + client.send_form(&format!("/test_helpers/treasury/outbound_payments/{id}/post"), self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ReturnOutboundPaymentTreasuryOutboundPayment<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// Optional hash to set the the return code. + #[serde(skip_serializing_if = "Option::is_none")] + pub returned_details: Option<ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetails>, +} +impl<'a> ReturnOutboundPaymentTreasuryOutboundPayment<'a> { + pub fn new() -> Self { + Self::default() + } +} +/// Optional hash to set the the return code. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetails { + /// The return code to be set on the OutboundPayment object. + #[serde(skip_serializing_if = "Option::is_none")] + pub code: Option<ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode>, +} +impl ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetails { + pub fn new() -> Self { + Self::default() + } +} +/// The return code to be set on the OutboundPayment object. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { + AccountClosed, + AccountFrozen, + BankAccountRestricted, + BankOwnershipChanged, + Declined, + IncorrectAccountHolderName, + InvalidAccountNumber, + InvalidCurrency, + NoAccount, + Other, +} +impl ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { + pub fn as_str(self) -> &'static str { + use ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode::*; + match self { + AccountClosed => "account_closed", + AccountFrozen => "account_frozen", + BankAccountRestricted => "bank_account_restricted", + BankOwnershipChanged => "bank_ownership_changed", + Declined => "declined", + IncorrectAccountHolderName => "incorrect_account_holder_name", + InvalidAccountNumber => "invalid_account_number", + InvalidCurrency => "invalid_currency", + NoAccount => "no_account", + Other => "other", + } + } +} + +impl std::str::FromStr for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode::*; + match s { + "account_closed" => Ok(AccountClosed), + "account_frozen" => Ok(AccountFrozen), + "bank_account_restricted" => Ok(BankAccountRestricted), + "bank_ownership_changed" => Ok(BankOwnershipChanged), + "declined" => Ok(Declined), + "incorrect_account_holder_name" => Ok(IncorrectAccountHolderName), + "invalid_account_number" => Ok(InvalidAccountNumber), + "invalid_currency" => Ok(InvalidCurrency), + "no_account" => Ok(NoAccount), + "other" => Ok(Other), + _ => Err(()), + } + } +} +impl std::fmt::Display for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> ReturnOutboundPaymentTreasuryOutboundPayment<'a> { + /// Transitions a test mode created OutboundPayment to the `returned` status. + /// The OutboundPayment must already be in the `processing` state. + pub fn send(&self, client: &stripe::Client, id: &str) -> stripe::Response<stripe_treasury::TreasuryOutboundPayment> { + client.send_form(&format!("/test_helpers/treasury/outbound_payments/{id}/return"), self, http_types::Method::Post) } } diff --git a/generated/stripe_treasury/src/treasury_outbound_payment/types.rs b/generated/stripe_treasury/src/treasury_outbound_payment/types.rs index 4c59edc33..8597c6566 100644 --- a/generated/stripe_treasury/src/treasury_outbound_payment/types.rs +++ b/generated/stripe_treasury/src/treasury_outbound_payment/types.rs @@ -3,7 +3,9 @@ /// /// Simulate OutboundPayment state changes with the `/v1/test_helpers/treasury/outbound_payments` endpoints. /// These methods can only be called on test mode objects. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryOutboundPayment { /// Amount (in cents) transferred. pub amount: i64, @@ -22,12 +24,9 @@ pub struct TreasuryOutboundPayment { /// This field can be empty if the OutboundPayment was created using `destination_payment_method_data`. pub destination_payment_method: Option<String>, /// Details about the PaymentMethod for an OutboundPayment. - pub destination_payment_method_details: - Option<stripe_treasury::OutboundPaymentsPaymentMethodDetails>, + pub destination_payment_method_details: Option<stripe_treasury::OutboundPaymentsPaymentMethodDetails>, /// Details about the end user. - pub end_user_details: Option< - stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails, - >, + pub end_user_details: Option<stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails>, /// The date when funds are expected to arrive in the destination account. pub expected_arrival_date: stripe_types::Timestamp, /// The FinancialAccount that funds were pulled from. @@ -50,11 +49,214 @@ pub struct TreasuryOutboundPayment { /// The status changes to `posted` once the OutboundPayment has been "confirmed" and funds have left the account, or to `failed` or `canceled`. /// If an OutboundPayment fails to arrive at its destination, its status will change to `returned`. pub status: stripe_treasury::TreasuryOutboundPaymentStatus, - pub status_transitions: - stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions, + pub status_transitions: stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions, /// The Transaction associated with this object. pub transaction: stripe_types::Expandable<stripe_treasury::TreasuryTransaction>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryOutboundPaymentBuilder { + amount: Option<i64>, + cancelable: Option<bool>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + customer: Option<Option<String>>, + description: Option<Option<String>>, + destination_payment_method: Option<Option<String>>, + destination_payment_method_details: Option<Option<stripe_treasury::OutboundPaymentsPaymentMethodDetails>>, + end_user_details: Option<Option<stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails>>, + expected_arrival_date: Option<stripe_types::Timestamp>, + financial_account: Option<String>, + hosted_regulatory_receipt_url: Option<Option<String>>, + id: Option<stripe_treasury::TreasuryOutboundPaymentId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + returned_details: Option<Option<stripe_treasury::TreasuryOutboundPaymentsResourceReturnedStatus>>, + statement_descriptor: Option<String>, + status: Option<stripe_treasury::TreasuryOutboundPaymentStatus>, + status_transitions: Option<stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions>, + transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryOutboundPayment { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryOutboundPayment>, + builder: TreasuryOutboundPaymentBuilder, + } + + impl Visitor for Place<TreasuryOutboundPayment> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryOutboundPaymentBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryOutboundPaymentBuilder { + type Out = TreasuryOutboundPayment; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "cancelable" => Deserialize::begin(&mut self.cancelable), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "customer" => Deserialize::begin(&mut self.customer), + "description" => Deserialize::begin(&mut self.description), + "destination_payment_method" => Deserialize::begin(&mut self.destination_payment_method), + "destination_payment_method_details" => Deserialize::begin(&mut self.destination_payment_method_details), + "end_user_details" => Deserialize::begin(&mut self.end_user_details), + "expected_arrival_date" => Deserialize::begin(&mut self.expected_arrival_date), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "hosted_regulatory_receipt_url" => Deserialize::begin(&mut self.hosted_regulatory_receipt_url), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "returned_details" => Deserialize::begin(&mut self.returned_details), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + cancelable: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + customer: Deserialize::default(), + description: Deserialize::default(), + destination_payment_method: Deserialize::default(), + destination_payment_method_details: Deserialize::default(), + end_user_details: Deserialize::default(), + expected_arrival_date: Deserialize::default(), + financial_account: Deserialize::default(), + hosted_regulatory_receipt_url: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + returned_details: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let cancelable = self.cancelable.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let customer = self.customer.take()?; + let description = self.description.take()?; + let destination_payment_method = self.destination_payment_method.take()?; + let destination_payment_method_details = self.destination_payment_method_details.take()?; + let end_user_details = self.end_user_details.take()?; + let expected_arrival_date = self.expected_arrival_date.take()?; + let financial_account = self.financial_account.take()?; + let hosted_regulatory_receipt_url = self.hosted_regulatory_receipt_url.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let returned_details = self.returned_details.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { + amount, + cancelable, + created, + currency, + customer, + description, + destination_payment_method, + destination_payment_method_details, + end_user_details, + expected_arrival_date, + financial_account, + hosted_regulatory_receipt_url, + id, + livemode, + metadata, + returned_details, + statement_descriptor, + status, + status_transitions, + transaction, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryOutboundPayment { + type Builder = TreasuryOutboundPaymentBuilder; + } + + impl FromValueOpt for TreasuryOutboundPayment { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryOutboundPaymentBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "cancelable" => b.cancelable = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "customer" => b.customer = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "destination_payment_method" => b.destination_payment_method = Some(FromValueOpt::from_value(v)?), + "destination_payment_method_details" => b.destination_payment_method_details = Some(FromValueOpt::from_value(v)?), + "end_user_details" => b.end_user_details = Some(FromValueOpt::from_value(v)?), + "expected_arrival_date" => b.expected_arrival_date = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "hosted_regulatory_receipt_url" => b.hosted_regulatory_receipt_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "returned_details" => b.returned_details = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TreasuryOutboundPayment { type Id = stripe_treasury::TreasuryOutboundPaymentId; fn id(&self) -> &Self::Id { @@ -120,8 +322,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryOutboundPaymentStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryOutboundPaymentStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryOutboundPaymentStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryOutboundPaymentStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryOutboundPaymentStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundPaymentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundPaymentStatus); diff --git a/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_end_user_details.rs b/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_end_user_details.rs index 04d3734ef..3a6b9037d 100644 --- a/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_end_user_details.rs +++ b/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_end_user_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails { /// IP address of the user initiating the OutboundPayment. /// Set if `present` is set to `true`. @@ -9,3 +11,93 @@ pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails /// Otherwise, `false`. pub present: bool, } +#[cfg(feature = "min-ser")] +pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder { + ip_address: Option<Option<String>>, + present: Option<bool>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails>, + builder: TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder, + } + + impl Visitor for Place<TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder { + type Out = TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "ip_address" => Deserialize::begin(&mut self.ip_address), + "present" => Deserialize::begin(&mut self.present), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ip_address: Deserialize::default(), present: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let ip_address = self.ip_address.take()?; + let present = self.present.take()?; + + Some(Self::Out { ip_address, present }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails { + type Builder = TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder; + } + + impl FromValueOpt for TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "ip_address" => b.ip_address = Some(FromValueOpt::from_value(v)?), + "present" => b.present = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_status_transitions.rs b/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_status_transitions.rs index 7a1a3d797..abd40083d 100644 --- a/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_status_transitions.rs +++ b/generated/stripe_treasury/src/treasury_outbound_payments_resource_outbound_payment_resource_status_transitions.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions { /// Timestamp describing when an OutboundPayment changed status to `canceled`. pub canceled_at: Option<stripe_types::Timestamp>, @@ -9,3 +11,101 @@ pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransiti /// Timestamp describing when an OutboundPayment changed status to `returned`. pub returned_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder { + canceled_at: Option<Option<stripe_types::Timestamp>>, + failed_at: Option<Option<stripe_types::Timestamp>>, + posted_at: Option<Option<stripe_types::Timestamp>>, + returned_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions>, + builder: TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder, + } + + impl Visitor for Place<TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder { + type Out = TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "failed_at" => Deserialize::begin(&mut self.failed_at), + "posted_at" => Deserialize::begin(&mut self.posted_at), + "returned_at" => Deserialize::begin(&mut self.returned_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { canceled_at: Deserialize::default(), failed_at: Deserialize::default(), posted_at: Deserialize::default(), returned_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let canceled_at = self.canceled_at.take()?; + let failed_at = self.failed_at.take()?; + let posted_at = self.posted_at.take()?; + let returned_at = self.returned_at.take()?; + + Some(Self::Out { canceled_at, failed_at, posted_at, returned_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions { + type Builder = TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "failed_at" => b.failed_at = Some(FromValueOpt::from_value(v)?), + "posted_at" => b.posted_at = Some(FromValueOpt::from_value(v)?), + "returned_at" => b.returned_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_outbound_payments_resource_returned_status.rs b/generated/stripe_treasury/src/treasury_outbound_payments_resource_returned_status.rs index 1b9b481a4..e0da92223 100644 --- a/generated/stripe_treasury/src/treasury_outbound_payments_resource_returned_status.rs +++ b/generated/stripe_treasury/src/treasury_outbound_payments_resource_returned_status.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryOutboundPaymentsResourceReturnedStatus { /// Reason for the return. pub code: TreasuryOutboundPaymentsResourceReturnedStatusCode, /// The Transaction associated with this object. pub transaction: stripe_types::Expandable<stripe_treasury::TreasuryTransaction>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryOutboundPaymentsResourceReturnedStatusBuilder { + code: Option<TreasuryOutboundPaymentsResourceReturnedStatusCode>, + transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryOutboundPaymentsResourceReturnedStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryOutboundPaymentsResourceReturnedStatus>, + builder: TreasuryOutboundPaymentsResourceReturnedStatusBuilder, + } + + impl Visitor for Place<TreasuryOutboundPaymentsResourceReturnedStatus> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryOutboundPaymentsResourceReturnedStatusBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryOutboundPaymentsResourceReturnedStatusBuilder { + type Out = TreasuryOutboundPaymentsResourceReturnedStatus; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { code, transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryOutboundPaymentsResourceReturnedStatus { + type Builder = TreasuryOutboundPaymentsResourceReturnedStatusBuilder; + } + + impl FromValueOpt for TreasuryOutboundPaymentsResourceReturnedStatus { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryOutboundPaymentsResourceReturnedStatusBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for the return. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryOutboundPaymentsResourceReturnedStatusCode { @@ -79,10 +171,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryOutboundPaymentsResourceReturnedSt fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryOutboundPaymentsResourceReturnedStatusCode", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryOutboundPaymentsResourceReturnedStatusCode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryOutboundPaymentsResourceReturnedStatusCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryOutboundPaymentsResourceReturnedStatusCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundPaymentsResourceReturnedStatusCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundPaymentsResourceReturnedStatusCode); diff --git a/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs b/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs index a5f1ac540..4effbcaf3 100644 --- a/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs +++ b/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs @@ -1,4 +1,145 @@ #[derive(Copy, Clone, Debug, serde::Serialize)] +pub struct CreateTreasuryOutboundTransfer<'a> { + /// Amount (in cents) to be transferred. + pub amount: i64, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + /// Must be a [supported currency](https://stripe.com/docs/currencies). + pub currency: stripe_types::Currency, + /// An arbitrary string attached to the object. Often useful for displaying to users. + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option<&'a str>, + /// The PaymentMethod to use as the payment instrument for the OutboundTransfer. + #[serde(skip_serializing_if = "Option::is_none")] + pub destination_payment_method: Option<&'a str>, + /// Hash describing payment method configuration details. + #[serde(skip_serializing_if = "Option::is_none")] + pub destination_payment_method_options: Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptions>, + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, + /// The FinancialAccount to pull funds from. + pub financial_account: &'a str, + /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. + /// This can be useful for storing additional information about the object in a structured format. + /// Individual keys can be unset by posting an empty value to them. + /// All keys can be unset by posting an empty value to `metadata`. + #[serde(skip_serializing_if = "Option::is_none")] + pub metadata: Option<&'a std::collections::HashMap<String, String>>, + /// Statement descriptor to be shown on the receiving end of an OutboundTransfer. + /// Maximum 10 characters for `ach` transfers or 140 characters for `wire` transfers. + /// The default value is `transfer`. + #[serde(skip_serializing_if = "Option::is_none")] + pub statement_descriptor: Option<&'a str>, +} +impl<'a> CreateTreasuryOutboundTransfer<'a> { + pub fn new(amount: i64, currency: stripe_types::Currency, financial_account: &'a str) -> Self { + Self { + amount, + currency, + description: None, + destination_payment_method: None, + destination_payment_method_options: None, + expand: None, + financial_account, + metadata: None, + statement_descriptor: None, + } + } +} +/// Hash describing payment method configuration details. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreateTreasuryOutboundTransferDestinationPaymentMethodOptions { + /// Optional fields for `us_bank_account`. + #[serde(skip_serializing_if = "Option::is_none")] + pub us_bank_account: Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount>, +} +impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptions { + pub fn new() -> Self { + Self::default() + } +} +/// Optional fields for `us_bank_account`. +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount { + /// Designate the OutboundTransfer as using a US bank account network configuration. + #[serde(skip_serializing_if = "Option::is_none")] + pub network: Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork>, +} +impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount { + pub fn new() -> Self { + Self::default() + } +} +/// Designate the OutboundTransfer as using a US bank account network configuration. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { + Ach, + UsDomesticWire, +} +impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { + pub fn as_str(self) -> &'static str { + use CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork::*; + match self { + Ach => "ach", + UsDomesticWire => "us_domestic_wire", + } + } +} + +impl std::str::FromStr for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { + type Err = (); + fn from_str(s: &str) -> Result<Self, Self::Err> { + use CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork::*; + match s { + "ach" => Ok(Ach), + "us_domestic_wire" => Ok(UsDomesticWire), + _ => Err(()), + } + } +} +impl std::fmt::Display for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +impl serde::Serialize for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl<'a> CreateTreasuryOutboundTransfer<'a> { + /// Creates an OutboundTransfer. + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { + client.send_form("/treasury/outbound_transfers", self, http_types::Method::Post) + } +} +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTreasuryOutboundTransfer<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTreasuryOutboundTransfer<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTreasuryOutboundTransfer<'a> { + /// Retrieves the details of an existing OutboundTransfer by passing the unique OutboundTransfer ID from either the OutboundTransfer creation request or OutboundTransfer list. + pub fn send(&self, client: &stripe::Client, outbound_transfer: &stripe_treasury::TreasuryOutboundTransferId) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { + client.get_query(&format!("/treasury/outbound_transfers/{outbound_transfer}"), self) + } +} +#[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ListTreasuryOutboundTransfer<'a> { /// A cursor for use in pagination. /// `ending_before` is an object ID that defines your place in the list. @@ -25,49 +166,33 @@ pub struct ListTreasuryOutboundTransfer<'a> { } impl<'a> ListTreasuryOutboundTransfer<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - ending_before: None, - expand: None, - financial_account, - limit: None, - starting_after: None, - status: None, - } + Self { ending_before: None, expand: None, financial_account, limit: None, starting_after: None, status: None } } } impl<'a> ListTreasuryOutboundTransfer<'a> { /// Returns a list of OutboundTransfers sent from the specified FinancialAccount. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryOutboundTransfer>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryOutboundTransfer>> { client.get_query("/treasury/outbound_transfers", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryOutboundTransfer>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryOutboundTransfer>> { stripe::ListPaginator::from_list_params("/treasury/outbound_transfers", self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTreasuryOutboundTransfer<'a> { +pub struct CancelTreasuryOutboundTransfer<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> RetrieveTreasuryOutboundTransfer<'a> { +impl<'a> CancelTreasuryOutboundTransfer<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> RetrieveTreasuryOutboundTransfer<'a> { - /// Retrieves the details of an existing OutboundTransfer by passing the unique OutboundTransfer ID from either the OutboundTransfer creation request or OutboundTransfer list. - pub fn send( - &self, - client: &stripe::Client, - outbound_transfer: &stripe_treasury::TreasuryOutboundTransferId, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { - client.get_query(&format!("/treasury/outbound_transfers/{outbound_transfer}"), self) +impl<'a> CancelTreasuryOutboundTransfer<'a> { + /// An OutboundTransfer can be canceled if the funds have not yet been paid out. + pub fn send(&self, client: &stripe::Client, outbound_transfer: &stripe_treasury::TreasuryOutboundTransferId) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { + client.send_form(&format!("/treasury/outbound_transfers/{outbound_transfer}/cancel"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -84,16 +209,8 @@ impl<'a> FailTreasuryOutboundTransfer<'a> { impl<'a> FailTreasuryOutboundTransfer<'a> { /// Transitions a test mode created OutboundTransfer to the `failed` status. /// The OutboundTransfer must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - outbound_transfer: &str, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { - client.send_form( - &format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, outbound_transfer: &str) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { + client.send_form(&format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -110,16 +227,8 @@ impl<'a> PostTreasuryOutboundTransfer<'a> { impl<'a> PostTreasuryOutboundTransfer<'a> { /// Transitions a test mode created OutboundTransfer to the `posted` status. /// The OutboundTransfer must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - outbound_transfer: &str, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { - client.send_form( - &format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, outbound_transfer: &str) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { + client.send_form(&format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -221,178 +330,7 @@ impl serde::Serialize for ReturnOutboundTransferTreasuryOutboundTransferReturned impl<'a> ReturnOutboundTransferTreasuryOutboundTransfer<'a> { /// Transitions a test mode created OutboundTransfer to the `returned` status. /// The OutboundTransfer must already be in the `processing` state. - pub fn send( - &self, - client: &stripe::Client, - outbound_transfer: &str, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { - client.send_form( - &format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return"), - self, - http_types::Method::Post, - ) - } -} -#[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateTreasuryOutboundTransfer<'a> { - /// Amount (in cents) to be transferred. - pub amount: i64, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. - /// Must be a [supported currency](https://stripe.com/docs/currencies). - pub currency: stripe_types::Currency, - /// An arbitrary string attached to the object. Often useful for displaying to users. - #[serde(skip_serializing_if = "Option::is_none")] - pub description: Option<&'a str>, - /// The PaymentMethod to use as the payment instrument for the OutboundTransfer. - #[serde(skip_serializing_if = "Option::is_none")] - pub destination_payment_method: Option<&'a str>, - /// Hash describing payment method configuration details. - #[serde(skip_serializing_if = "Option::is_none")] - pub destination_payment_method_options: - Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptions>, - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, - /// The FinancialAccount to pull funds from. - pub financial_account: &'a str, - /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. - /// This can be useful for storing additional information about the object in a structured format. - /// Individual keys can be unset by posting an empty value to them. - /// All keys can be unset by posting an empty value to `metadata`. - #[serde(skip_serializing_if = "Option::is_none")] - pub metadata: Option<&'a std::collections::HashMap<String, String>>, - /// Statement descriptor to be shown on the receiving end of an OutboundTransfer. - /// Maximum 10 characters for `ach` transfers or 140 characters for `us_domestic_wire` transfers. - /// The default value is "transfer". - #[serde(skip_serializing_if = "Option::is_none")] - pub statement_descriptor: Option<&'a str>, -} -impl<'a> CreateTreasuryOutboundTransfer<'a> { - pub fn new(amount: i64, currency: stripe_types::Currency, financial_account: &'a str) -> Self { - Self { - amount, - currency, - description: None, - destination_payment_method: None, - destination_payment_method_options: None, - expand: None, - financial_account, - metadata: None, - statement_descriptor: None, - } - } -} -/// Hash describing payment method configuration details. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateTreasuryOutboundTransferDestinationPaymentMethodOptions { - /// Optional fields for `us_bank_account`. - #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount>, -} -impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptions { - pub fn new() -> Self { - Self::default() - } -} -/// Optional fields for `us_bank_account`. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount { - /// Designate the OutboundTransfer as using a US bank account network configuration. - #[serde(skip_serializing_if = "Option::is_none")] - pub network: - Option<CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork>, -} -impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccount { - pub fn new() -> Self { - Self::default() - } -} -/// Designate the OutboundTransfer as using a US bank account network configuration. -#[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { - Ach, - UsDomesticWire, -} -impl CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork { - pub fn as_str(self) -> &'static str { - use CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork::*; - match self { - Ach => "ach", - UsDomesticWire => "us_domestic_wire", - } - } -} - -impl std::str::FromStr - for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork -{ - type Err = (); - fn from_str(s: &str) -> Result<Self, Self::Err> { - use CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork::*; - match s { - "ach" => Ok(Ach), - "us_domestic_wire" => Ok(UsDomesticWire), - _ => Err(()), - } - } -} -impl std::fmt::Display - for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} - -impl std::fmt::Debug - for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork -{ - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.write_str(self.as_str()) - } -} -impl serde::Serialize - for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork -{ - fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> - where - S: serde::Serializer, - { - serializer.serialize_str(self.as_str()) - } -} -impl<'a> CreateTreasuryOutboundTransfer<'a> { - /// Creates an OutboundTransfer. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { - client.send_form("/treasury/outbound_transfers", self, http_types::Method::Post) - } -} -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CancelTreasuryOutboundTransfer<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> CancelTreasuryOutboundTransfer<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> CancelTreasuryOutboundTransfer<'a> { - /// An OutboundTransfer can be canceled if the funds have not yet been paid out. - pub fn send( - &self, - client: &stripe::Client, - outbound_transfer: &stripe_treasury::TreasuryOutboundTransferId, - ) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { - client.send_form( - &format!("/treasury/outbound_transfers/{outbound_transfer}/cancel"), - self, - http_types::Method::Post, - ) + pub fn send(&self, client: &stripe::Client, outbound_transfer: &str) -> stripe::Response<stripe_treasury::TreasuryOutboundTransfer> { + client.send_form(&format!("/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return"), self, http_types::Method::Post) } } diff --git a/generated/stripe_treasury/src/treasury_outbound_transfer/types.rs b/generated/stripe_treasury/src/treasury_outbound_transfer/types.rs index 08415c713..ba9ea56ff 100644 --- a/generated/stripe_treasury/src/treasury_outbound_transfer/types.rs +++ b/generated/stripe_treasury/src/treasury_outbound_transfer/types.rs @@ -4,7 +4,9 @@ /// /// Simulate OutboundTransfer state changes with the `/v1/test_helpers/treasury/outbound_transfers` endpoints. /// These methods can only be called on test mode objects. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryOutboundTransfer { /// Amount (in cents) transferred. pub amount: i64, @@ -46,6 +48,198 @@ pub struct TreasuryOutboundTransfer { /// The Transaction associated with this object. pub transaction: stripe_types::Expandable<stripe_treasury::TreasuryTransaction>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryOutboundTransferBuilder { + amount: Option<i64>, + cancelable: Option<bool>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<Option<String>>, + destination_payment_method: Option<Option<String>>, + destination_payment_method_details: Option<stripe_treasury::OutboundTransfersPaymentMethodDetails>, + expected_arrival_date: Option<stripe_types::Timestamp>, + financial_account: Option<String>, + hosted_regulatory_receipt_url: Option<Option<String>>, + id: Option<stripe_treasury::TreasuryOutboundTransferId>, + livemode: Option<bool>, + metadata: Option<std::collections::HashMap<String, String>>, + returned_details: Option<Option<stripe_treasury::TreasuryOutboundTransfersResourceReturnedDetails>>, + statement_descriptor: Option<String>, + status: Option<stripe_treasury::TreasuryOutboundTransferStatus>, + status_transitions: Option<stripe_treasury::TreasuryOutboundTransfersResourceStatusTransitions>, + transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryOutboundTransfer { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryOutboundTransfer>, + builder: TreasuryOutboundTransferBuilder, + } + + impl Visitor for Place<TreasuryOutboundTransfer> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryOutboundTransferBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryOutboundTransferBuilder { + type Out = TreasuryOutboundTransfer; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "cancelable" => Deserialize::begin(&mut self.cancelable), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "destination_payment_method" => Deserialize::begin(&mut self.destination_payment_method), + "destination_payment_method_details" => Deserialize::begin(&mut self.destination_payment_method_details), + "expected_arrival_date" => Deserialize::begin(&mut self.expected_arrival_date), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "hosted_regulatory_receipt_url" => Deserialize::begin(&mut self.hosted_regulatory_receipt_url), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "returned_details" => Deserialize::begin(&mut self.returned_details), + "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + cancelable: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + destination_payment_method: Deserialize::default(), + destination_payment_method_details: Deserialize::default(), + expected_arrival_date: Deserialize::default(), + financial_account: Deserialize::default(), + hosted_regulatory_receipt_url: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + returned_details: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let cancelable = self.cancelable.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let destination_payment_method = self.destination_payment_method.take()?; + let destination_payment_method_details = self.destination_payment_method_details.take()?; + let expected_arrival_date = self.expected_arrival_date.take()?; + let financial_account = self.financial_account.take()?; + let hosted_regulatory_receipt_url = self.hosted_regulatory_receipt_url.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let metadata = self.metadata.take()?; + let returned_details = self.returned_details.take()?; + let statement_descriptor = self.statement_descriptor.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { + amount, + cancelable, + created, + currency, + description, + destination_payment_method, + destination_payment_method_details, + expected_arrival_date, + financial_account, + hosted_regulatory_receipt_url, + id, + livemode, + metadata, + returned_details, + statement_descriptor, + status, + status_transitions, + transaction, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryOutboundTransfer { + type Builder = TreasuryOutboundTransferBuilder; + } + + impl FromValueOpt for TreasuryOutboundTransfer { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryOutboundTransferBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "cancelable" => b.cancelable = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "destination_payment_method" => b.destination_payment_method = Some(FromValueOpt::from_value(v)?), + "destination_payment_method_details" => b.destination_payment_method_details = Some(FromValueOpt::from_value(v)?), + "expected_arrival_date" => b.expected_arrival_date = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "hosted_regulatory_receipt_url" => b.hosted_regulatory_receipt_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "returned_details" => b.returned_details = Some(FromValueOpt::from_value(v)?), + "statement_descriptor" => b.statement_descriptor = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; impl stripe_types::Object for TreasuryOutboundTransfer { type Id = stripe_treasury::TreasuryOutboundTransferId; fn id(&self) -> &Self::Id { @@ -111,8 +305,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryOutboundTransferStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryOutboundTransferStatus") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryOutboundTransferStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryOutboundTransferStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryOutboundTransferStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundTransferStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundTransferStatus); diff --git a/generated/stripe_treasury/src/treasury_outbound_transfers_resource_returned_details.rs b/generated/stripe_treasury/src/treasury_outbound_transfers_resource_returned_details.rs index 3369e6b0f..a3240a77e 100644 --- a/generated/stripe_treasury/src/treasury_outbound_transfers_resource_returned_details.rs +++ b/generated/stripe_treasury/src/treasury_outbound_transfers_resource_returned_details.rs @@ -1,10 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryOutboundTransfersResourceReturnedDetails { /// Reason for the return. pub code: TreasuryOutboundTransfersResourceReturnedDetailsCode, /// The Transaction associated with this object. pub transaction: stripe_types::Expandable<stripe_treasury::TreasuryTransaction>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryOutboundTransfersResourceReturnedDetailsBuilder { + code: Option<TreasuryOutboundTransfersResourceReturnedDetailsCode>, + transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryOutboundTransfersResourceReturnedDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryOutboundTransfersResourceReturnedDetails>, + builder: TreasuryOutboundTransfersResourceReturnedDetailsBuilder, + } + + impl Visitor for Place<TreasuryOutboundTransfersResourceReturnedDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryOutboundTransfersResourceReturnedDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryOutboundTransfersResourceReturnedDetailsBuilder { + type Out = TreasuryOutboundTransfersResourceReturnedDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "code" => Deserialize::begin(&mut self.code), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let code = self.code.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { code, transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryOutboundTransfersResourceReturnedDetails { + type Builder = TreasuryOutboundTransfersResourceReturnedDetailsBuilder; + } + + impl FromValueOpt for TreasuryOutboundTransfersResourceReturnedDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryOutboundTransfersResourceReturnedDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "code" => b.code = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for the return. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryOutboundTransfersResourceReturnedDetailsCode { @@ -79,10 +171,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryOutboundTransfersResourceReturnedD fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryOutboundTransfersResourceReturnedDetailsCode", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryOutboundTransfersResourceReturnedDetailsCode")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryOutboundTransfersResourceReturnedDetailsCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryOutboundTransfersResourceReturnedDetailsCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundTransfersResourceReturnedDetailsCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundTransfersResourceReturnedDetailsCode); diff --git a/generated/stripe_treasury/src/treasury_outbound_transfers_resource_status_transitions.rs b/generated/stripe_treasury/src/treasury_outbound_transfers_resource_status_transitions.rs index 5c77bafdd..a7899faf0 100644 --- a/generated/stripe_treasury/src/treasury_outbound_transfers_resource_status_transitions.rs +++ b/generated/stripe_treasury/src/treasury_outbound_transfers_resource_status_transitions.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryOutboundTransfersResourceStatusTransitions { /// Timestamp describing when an OutboundTransfer changed status to `canceled` pub canceled_at: Option<stripe_types::Timestamp>, @@ -9,3 +11,101 @@ pub struct TreasuryOutboundTransfersResourceStatusTransitions { /// Timestamp describing when an OutboundTransfer changed status to `returned` pub returned_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryOutboundTransfersResourceStatusTransitionsBuilder { + canceled_at: Option<Option<stripe_types::Timestamp>>, + failed_at: Option<Option<stripe_types::Timestamp>>, + posted_at: Option<Option<stripe_types::Timestamp>>, + returned_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryOutboundTransfersResourceStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryOutboundTransfersResourceStatusTransitions>, + builder: TreasuryOutboundTransfersResourceStatusTransitionsBuilder, + } + + impl Visitor for Place<TreasuryOutboundTransfersResourceStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryOutboundTransfersResourceStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryOutboundTransfersResourceStatusTransitionsBuilder { + type Out = TreasuryOutboundTransfersResourceStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "failed_at" => Deserialize::begin(&mut self.failed_at), + "posted_at" => Deserialize::begin(&mut self.posted_at), + "returned_at" => Deserialize::begin(&mut self.returned_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { canceled_at: Deserialize::default(), failed_at: Deserialize::default(), posted_at: Deserialize::default(), returned_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let canceled_at = self.canceled_at.take()?; + let failed_at = self.failed_at.take()?; + let posted_at = self.posted_at.take()?; + let returned_at = self.returned_at.take()?; + + Some(Self::Out { canceled_at, failed_at, posted_at, returned_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryOutboundTransfersResourceStatusTransitions { + type Builder = TreasuryOutboundTransfersResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for TreasuryOutboundTransfersResourceStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryOutboundTransfersResourceStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "canceled_at" => b.canceled_at = Some(FromValueOpt::from_value(v)?), + "failed_at" => b.failed_at = Some(FromValueOpt::from_value(v)?), + "posted_at" => b.posted_at = Some(FromValueOpt::from_value(v)?), + "returned_at" => b.returned_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_received_credit/requests.rs b/generated/stripe_treasury/src/treasury_received_credit/requests.rs index fd87be55a..3294dec80 100644 --- a/generated/stripe_treasury/src/treasury_received_credit/requests.rs +++ b/generated/stripe_treasury/src/treasury_received_credit/requests.rs @@ -28,15 +28,7 @@ pub struct ListTreasuryReceivedCredit<'a> { } impl<'a> ListTreasuryReceivedCredit<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - ending_before: None, - expand: None, - financial_account, - limit: None, - linked_flows: None, - starting_after: None, - status: None, - } + Self { ending_before: None, expand: None, financial_account, limit: None, linked_flows: None, starting_after: None, status: None } } } /// Only return ReceivedCredits described by the flow. @@ -104,15 +96,10 @@ impl serde::Serialize for ListTreasuryReceivedCreditLinkedFlowsSourceFlowType { } impl<'a> ListTreasuryReceivedCredit<'a> { /// Returns a list of ReceivedCredits. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryReceivedCredit>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryReceivedCredit>> { client.get_query("/treasury/received_credits", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryReceivedCredit>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryReceivedCredit>> { stripe::ListPaginator::from_list_params("/treasury/received_credits", self) } } @@ -129,11 +116,7 @@ impl<'a> RetrieveTreasuryReceivedCredit<'a> { } impl<'a> RetrieveTreasuryReceivedCredit<'a> { /// Retrieves the details of an existing ReceivedCredit by passing the unique ReceivedCredit ID from the ReceivedCredit list. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_treasury::TreasuryReceivedCreditId, - ) -> stripe::Response<stripe_treasury::TreasuryReceivedCredit> { + pub fn send(&self, client: &stripe::Client, id: &stripe_treasury::TreasuryReceivedCreditId) -> stripe::Response<stripe_treasury::TreasuryReceivedCredit> { client.get_query(&format!("/treasury/received_credits/{id}"), self) } } @@ -154,39 +137,24 @@ pub struct CreateTreasuryReceivedCredit<'a> { pub financial_account: &'a str, /// Initiating payment method details for the object. #[serde(skip_serializing_if = "Option::is_none")] - pub initiating_payment_method_details: - Option<CreateTreasuryReceivedCreditInitiatingPaymentMethodDetails<'a>>, + pub initiating_payment_method_details: Option<CreateTreasuryReceivedCreditInitiatingPaymentMethodDetails<'a>>, /// The rails used for the object. pub network: CreateTreasuryReceivedCreditNetwork, } impl<'a> CreateTreasuryReceivedCredit<'a> { - pub fn new( - amount: i64, - currency: stripe_types::Currency, - financial_account: &'a str, - network: CreateTreasuryReceivedCreditNetwork, - ) -> Self { - Self { - amount, - currency, - description: None, - expand: None, - financial_account, - initiating_payment_method_details: None, - network, - } + pub fn new(amount: i64, currency: stripe_types::Currency, financial_account: &'a str, network: CreateTreasuryReceivedCreditNetwork) -> Self { + Self { amount, currency, description: None, expand: None, financial_account, initiating_payment_method_details: None, network } } } /// Initiating payment method details for the object. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTreasuryReceivedCreditInitiatingPaymentMethodDetails<'a> { /// The source type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTreasuryReceivedCreditInitiatingPaymentMethodDetailsType, /// Optional fields for `us_bank_account`. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<CreateTreasuryReceivedCreditInitiatingPaymentMethodDetailsUsBankAccount<'a>>, + pub us_bank_account: Option<CreateTreasuryReceivedCreditInitiatingPaymentMethodDetailsUsBankAccount<'a>>, } impl<'a> CreateTreasuryReceivedCreditInitiatingPaymentMethodDetails<'a> { pub fn new(type_: CreateTreasuryReceivedCreditInitiatingPaymentMethodDetailsType) -> Self { @@ -303,10 +271,7 @@ impl serde::Serialize for CreateTreasuryReceivedCreditNetwork { impl<'a> CreateTreasuryReceivedCredit<'a> { /// Use this endpoint to simulate a test mode ReceivedCredit initiated by a third party. /// In live mode, you can’t directly create ReceivedCredits initiated by third parties. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryReceivedCredit> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryReceivedCredit> { client.send_form("/test_helpers/treasury/received_credits", self, http_types::Method::Post) } } diff --git a/generated/stripe_treasury/src/treasury_received_credit/types.rs b/generated/stripe_treasury/src/treasury_received_credit/types.rs index c9cf74773..11eca843c 100644 --- a/generated/stripe_treasury/src/treasury_received_credit/types.rs +++ b/generated/stripe_treasury/src/treasury_received_credit/types.rs @@ -1,41 +1,216 @@ /// ReceivedCredits represent funds sent to a [FinancialAccount](https://stripe.com/docs/api#financial_accounts) (for example, via ACH or wire). /// These money movements are not initiated from the FinancialAccount. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedCredit { /// Amount (in cents) transferred. -pub amount: i64, + pub amount: i64, /// Time at which the object was created. Measured in seconds since the Unix epoch. -pub created: stripe_types::Timestamp, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + pub created: stripe_types::Timestamp, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// Must be a [supported currency](https://stripe.com/docs/currencies). -pub currency: stripe_types::Currency, + pub currency: stripe_types::Currency, /// An arbitrary string attached to the object. Often useful for displaying to users. -pub description: String, - /// Reason for the failure. + pub description: String, + /// Reason for the failure. /// A ReceivedCredit might fail because the receiving FinancialAccount is closed or frozen. -pub failure_code: Option<TreasuryReceivedCreditFailureCode>, + pub failure_code: Option<TreasuryReceivedCreditFailureCode>, /// The FinancialAccount that received the funds. -pub financial_account: Option<String>, - /// A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. -pub hosted_regulatory_receipt_url: Option<String>, + pub financial_account: Option<String>, + /// A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. + pub hosted_regulatory_receipt_url: Option<String>, /// Unique identifier for the object. -pub id: stripe_treasury::TreasuryReceivedCreditId, -pub initiating_payment_method_details: stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails, -pub linked_flows: stripe_treasury::TreasuryReceivedCreditsResourceLinkedFlows, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. -pub livemode: bool, + pub id: stripe_treasury::TreasuryReceivedCreditId, + pub initiating_payment_method_details: stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails, + pub linked_flows: stripe_treasury::TreasuryReceivedCreditsResourceLinkedFlows, + /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + pub livemode: bool, /// The rails used to send the funds. -pub network: TreasuryReceivedCreditNetwork, + pub network: TreasuryReceivedCreditNetwork, /// Details describing when a ReceivedCredit may be reversed. -pub reversal_details: Option<stripe_treasury::TreasuryReceivedCreditsResourceReversalDetails>, - /// Status of the ReceivedCredit. + pub reversal_details: Option<stripe_treasury::TreasuryReceivedCreditsResourceReversalDetails>, + /// Status of the ReceivedCredit. /// ReceivedCredits are created either `succeeded` (approved) or `failed` (declined). /// If a ReceivedCredit is declined, the failure reason can be found in the `failure_code` field. -pub status: stripe_treasury::TreasuryReceivedCreditStatus, + pub status: stripe_treasury::TreasuryReceivedCreditStatus, /// The Transaction associated with this object. -pub transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, - + pub transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, +} +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedCreditBuilder { + amount: Option<i64>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<String>, + failure_code: Option<Option<TreasuryReceivedCreditFailureCode>>, + financial_account: Option<Option<String>>, + hosted_regulatory_receipt_url: Option<Option<String>>, + id: Option<stripe_treasury::TreasuryReceivedCreditId>, + initiating_payment_method_details: Option<stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails>, + linked_flows: Option<stripe_treasury::TreasuryReceivedCreditsResourceLinkedFlows>, + livemode: Option<bool>, + network: Option<TreasuryReceivedCreditNetwork>, + reversal_details: Option<Option<stripe_treasury::TreasuryReceivedCreditsResourceReversalDetails>>, + status: Option<stripe_treasury::TreasuryReceivedCreditStatus>, + transaction: Option<Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedCredit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedCredit>, + builder: TreasuryReceivedCreditBuilder, + } + + impl Visitor for Place<TreasuryReceivedCredit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedCreditBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedCreditBuilder { + type Out = TreasuryReceivedCredit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "failure_code" => Deserialize::begin(&mut self.failure_code), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "hosted_regulatory_receipt_url" => Deserialize::begin(&mut self.hosted_regulatory_receipt_url), + "id" => Deserialize::begin(&mut self.id), + "initiating_payment_method_details" => Deserialize::begin(&mut self.initiating_payment_method_details), + "linked_flows" => Deserialize::begin(&mut self.linked_flows), + "livemode" => Deserialize::begin(&mut self.livemode), + "network" => Deserialize::begin(&mut self.network), + "reversal_details" => Deserialize::begin(&mut self.reversal_details), + "status" => Deserialize::begin(&mut self.status), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + failure_code: Deserialize::default(), + financial_account: Deserialize::default(), + hosted_regulatory_receipt_url: Deserialize::default(), + id: Deserialize::default(), + initiating_payment_method_details: Deserialize::default(), + linked_flows: Deserialize::default(), + livemode: Deserialize::default(), + network: Deserialize::default(), + reversal_details: Deserialize::default(), + status: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let failure_code = self.failure_code.take()?; + let financial_account = self.financial_account.take()?; + let hosted_regulatory_receipt_url = self.hosted_regulatory_receipt_url.take()?; + let id = self.id.take()?; + let initiating_payment_method_details = self.initiating_payment_method_details.take()?; + let linked_flows = self.linked_flows.take()?; + let livemode = self.livemode.take()?; + let network = self.network.take()?; + let reversal_details = self.reversal_details.take()?; + let status = self.status.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { + amount, + created, + currency, + description, + failure_code, + financial_account, + hosted_regulatory_receipt_url, + id, + initiating_payment_method_details, + linked_flows, + livemode, + network, + reversal_details, + status, + transaction, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedCredit { + type Builder = TreasuryReceivedCreditBuilder; + } + + impl FromValueOpt for TreasuryReceivedCredit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedCreditBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "failure_code" => b.failure_code = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "hosted_regulatory_receipt_url" => b.hosted_regulatory_receipt_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "initiating_payment_method_details" => b.initiating_payment_method_details = Some(FromValueOpt::from_value(v)?), + "linked_flows" => b.linked_flows = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "reversal_details" => b.reversal_details = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for the failure. /// A ReceivedCredit might fail because the receiving FinancialAccount is closed or frozen. #[derive(Copy, Clone, Eq, PartialEq)] @@ -90,11 +265,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditFailureCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryReceivedCreditFailureCode") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedCreditFailureCode")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedCreditFailureCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedCreditFailureCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditFailureCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditFailureCode); /// The rails used to send the funds. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryReceivedCreditNetwork { @@ -151,11 +342,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditNetwork { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryReceivedCreditNetwork") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedCreditNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedCreditNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedCreditNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditNetwork); impl stripe_types::Object for TreasuryReceivedCredit { type Id = stripe_treasury::TreasuryReceivedCreditId; fn id(&self) -> &Self::Id { @@ -212,7 +419,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedCreditStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedCreditStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedCreditStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedCreditStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditStatus); diff --git a/generated/stripe_treasury/src/treasury_received_credits_resource_linked_flows.rs b/generated/stripe_treasury/src/treasury_received_credits_resource_linked_flows.rs index db5527c60..1c9cf51df 100644 --- a/generated/stripe_treasury/src/treasury_received_credits_resource_linked_flows.rs +++ b/generated/stripe_treasury/src/treasury_received_credits_resource_linked_flows.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedCreditsResourceLinkedFlows { /// The CreditReversal created as a result of this ReceivedCredit being reversed. pub credit_reversal: Option<String>, @@ -11,8 +13,120 @@ pub struct TreasuryReceivedCreditsResourceLinkedFlows { /// Examples of source flows include OutboundPayments, payouts, or CreditReversals. pub source_flow: Option<String>, /// The expandable object of the source flow. - pub source_flow_details: - Option<stripe_treasury::TreasuryReceivedCreditsResourceSourceFlowsDetails>, + pub source_flow_details: Option<stripe_treasury::TreasuryReceivedCreditsResourceSourceFlowsDetails>, /// The type of flow that originated the ReceivedCredit (for example, `outbound_payment`). pub source_flow_type: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedCreditsResourceLinkedFlowsBuilder { + credit_reversal: Option<Option<String>>, + issuing_authorization: Option<Option<String>>, + issuing_transaction: Option<Option<String>>, + source_flow: Option<Option<String>>, + source_flow_details: Option<Option<stripe_treasury::TreasuryReceivedCreditsResourceSourceFlowsDetails>>, + source_flow_type: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedCreditsResourceLinkedFlows { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedCreditsResourceLinkedFlows>, + builder: TreasuryReceivedCreditsResourceLinkedFlowsBuilder, + } + + impl Visitor for Place<TreasuryReceivedCreditsResourceLinkedFlows> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedCreditsResourceLinkedFlowsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedCreditsResourceLinkedFlowsBuilder { + type Out = TreasuryReceivedCreditsResourceLinkedFlows; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "credit_reversal" => Deserialize::begin(&mut self.credit_reversal), + "issuing_authorization" => Deserialize::begin(&mut self.issuing_authorization), + "issuing_transaction" => Deserialize::begin(&mut self.issuing_transaction), + "source_flow" => Deserialize::begin(&mut self.source_flow), + "source_flow_details" => Deserialize::begin(&mut self.source_flow_details), + "source_flow_type" => Deserialize::begin(&mut self.source_flow_type), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + credit_reversal: Deserialize::default(), + issuing_authorization: Deserialize::default(), + issuing_transaction: Deserialize::default(), + source_flow: Deserialize::default(), + source_flow_details: Deserialize::default(), + source_flow_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let credit_reversal = self.credit_reversal.take()?; + let issuing_authorization = self.issuing_authorization.take()?; + let issuing_transaction = self.issuing_transaction.take()?; + let source_flow = self.source_flow.take()?; + let source_flow_details = self.source_flow_details.take()?; + let source_flow_type = self.source_flow_type.take()?; + + Some(Self::Out { credit_reversal, issuing_authorization, issuing_transaction, source_flow, source_flow_details, source_flow_type }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedCreditsResourceLinkedFlows { + type Builder = TreasuryReceivedCreditsResourceLinkedFlowsBuilder; + } + + impl FromValueOpt for TreasuryReceivedCreditsResourceLinkedFlows { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedCreditsResourceLinkedFlowsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "credit_reversal" => b.credit_reversal = Some(FromValueOpt::from_value(v)?), + "issuing_authorization" => b.issuing_authorization = Some(FromValueOpt::from_value(v)?), + "issuing_transaction" => b.issuing_transaction = Some(FromValueOpt::from_value(v)?), + "source_flow" => b.source_flow = Some(FromValueOpt::from_value(v)?), + "source_flow_details" => b.source_flow_details = Some(FromValueOpt::from_value(v)?), + "source_flow_type" => b.source_flow_type = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_received_credits_resource_reversal_details.rs b/generated/stripe_treasury/src/treasury_received_credits_resource_reversal_details.rs index e46815910..8ce9eef99 100644 --- a/generated/stripe_treasury/src/treasury_received_credits_resource_reversal_details.rs +++ b/generated/stripe_treasury/src/treasury_received_credits_resource_reversal_details.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedCreditsResourceReversalDetails { /// Time before which a ReceivedCredit can be reversed. pub deadline: Option<stripe_types::Timestamp>, /// Set if a ReceivedCredit cannot be reversed. pub restricted_reason: Option<TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedCreditsResourceReversalDetailsBuilder { + deadline: Option<Option<stripe_types::Timestamp>>, + restricted_reason: Option<Option<TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedCreditsResourceReversalDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedCreditsResourceReversalDetails>, + builder: TreasuryReceivedCreditsResourceReversalDetailsBuilder, + } + + impl Visitor for Place<TreasuryReceivedCreditsResourceReversalDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedCreditsResourceReversalDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedCreditsResourceReversalDetailsBuilder { + type Out = TreasuryReceivedCreditsResourceReversalDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deadline" => Deserialize::begin(&mut self.deadline), + "restricted_reason" => Deserialize::begin(&mut self.restricted_reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deadline: Deserialize::default(), restricted_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deadline = self.deadline.take()?; + let restricted_reason = self.restricted_reason.take()?; + + Some(Self::Out { deadline, restricted_reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedCreditsResourceReversalDetails { + type Builder = TreasuryReceivedCreditsResourceReversalDetailsBuilder; + } + + impl FromValueOpt for TreasuryReceivedCreditsResourceReversalDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedCreditsResourceReversalDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deadline" => b.deadline = Some(FromValueOpt::from_value(v)?), + "restricted_reason" => b.restricted_reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Set if a ReceivedCredit cannot be reversed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason { @@ -60,16 +152,28 @@ impl serde::Serialize for TreasuryReceivedCreditsResourceReversalDetailsRestrict serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason -{ +impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason); diff --git a/generated/stripe_treasury/src/treasury_received_credits_resource_source_flows_details.rs b/generated/stripe_treasury/src/treasury_received_credits_resource_source_flows_details.rs index b99995f83..3924e63d2 100644 --- a/generated/stripe_treasury/src/treasury_received_credits_resource_source_flows_details.rs +++ b/generated/stripe_treasury/src/treasury_received_credits_resource_source_flows_details.rs @@ -1,15 +1,112 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedCreditsResourceSourceFlowsDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub credit_reversal: Option<stripe_treasury::TreasuryCreditReversal>, - #[serde(skip_serializing_if = "Option::is_none")] pub outbound_payment: Option<stripe_treasury::TreasuryOutboundPayment>, - #[serde(skip_serializing_if = "Option::is_none")] pub payout: Option<stripe_shared::Payout>, /// The type of the source flow that originated the ReceivedCredit. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TreasuryReceivedCreditsResourceSourceFlowsDetailsType, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder { + credit_reversal: Option<Option<stripe_treasury::TreasuryCreditReversal>>, + outbound_payment: Option<Option<stripe_treasury::TreasuryOutboundPayment>>, + payout: Option<Option<stripe_shared::Payout>>, + type_: Option<TreasuryReceivedCreditsResourceSourceFlowsDetailsType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedCreditsResourceSourceFlowsDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedCreditsResourceSourceFlowsDetails>, + builder: TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder, + } + + impl Visitor for Place<TreasuryReceivedCreditsResourceSourceFlowsDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder { + type Out = TreasuryReceivedCreditsResourceSourceFlowsDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "credit_reversal" => Deserialize::begin(&mut self.credit_reversal), + "outbound_payment" => Deserialize::begin(&mut self.outbound_payment), + "payout" => Deserialize::begin(&mut self.payout), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { credit_reversal: Deserialize::default(), outbound_payment: Deserialize::default(), payout: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let credit_reversal = self.credit_reversal.take()?; + let outbound_payment = self.outbound_payment.take()?; + let payout = self.payout.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { credit_reversal, outbound_payment, payout, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedCreditsResourceSourceFlowsDetails { + type Builder = TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder; + } + + impl FromValueOpt for TreasuryReceivedCreditsResourceSourceFlowsDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "credit_reversal" => b.credit_reversal = Some(FromValueOpt::from_value(v)?), + "outbound_payment" => b.outbound_payment = Some(FromValueOpt::from_value(v)?), + "payout" => b.payout = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of the source flow that originated the ReceivedCredit. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryReceivedCreditsResourceSourceFlowsDetailsType { @@ -66,10 +163,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditsResourceSourceFlows fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryReceivedCreditsResourceSourceFlowsDetailsType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedCreditsResourceSourceFlowsDetailsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedCreditsResourceSourceFlowsDetailsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedCreditsResourceSourceFlowsDetailsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditsResourceSourceFlowsDetailsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditsResourceSourceFlowsDetailsType); diff --git a/generated/stripe_treasury/src/treasury_received_credits_resource_status_transitions.rs b/generated/stripe_treasury/src/treasury_received_credits_resource_status_transitions.rs index ebbdc717b..7d6abe0b5 100644 --- a/generated/stripe_treasury/src/treasury_received_credits_resource_status_transitions.rs +++ b/generated/stripe_treasury/src/treasury_received_credits_resource_status_transitions.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedCreditsResourceStatusTransitions { /// Timestamp describing when the CreditReversal changed status to `posted` pub posted_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedCreditsResourceStatusTransitionsBuilder { + posted_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedCreditsResourceStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedCreditsResourceStatusTransitions>, + builder: TreasuryReceivedCreditsResourceStatusTransitionsBuilder, + } + + impl Visitor for Place<TreasuryReceivedCreditsResourceStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedCreditsResourceStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedCreditsResourceStatusTransitionsBuilder { + type Out = TreasuryReceivedCreditsResourceStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "posted_at" => Deserialize::begin(&mut self.posted_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { posted_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let posted_at = self.posted_at.take()?; + + Some(Self::Out { posted_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedCreditsResourceStatusTransitions { + type Builder = TreasuryReceivedCreditsResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for TreasuryReceivedCreditsResourceStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedCreditsResourceStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "posted_at" => b.posted_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_received_debit/requests.rs b/generated/stripe_treasury/src/treasury_received_debit/requests.rs index d04972f91..db5cc3ae0 100644 --- a/generated/stripe_treasury/src/treasury_received_debit/requests.rs +++ b/generated/stripe_treasury/src/treasury_received_debit/requests.rs @@ -25,27 +25,15 @@ pub struct ListTreasuryReceivedDebit<'a> { } impl<'a> ListTreasuryReceivedDebit<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - ending_before: None, - expand: None, - financial_account, - limit: None, - starting_after: None, - status: None, - } + Self { ending_before: None, expand: None, financial_account, limit: None, starting_after: None, status: None } } } impl<'a> ListTreasuryReceivedDebit<'a> { /// Returns a list of ReceivedDebits. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryReceivedDebit>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryReceivedDebit>> { client.get_query("/treasury/received_debits", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryReceivedDebit>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryReceivedDebit>> { stripe::ListPaginator::from_list_params("/treasury/received_debits", self) } } @@ -62,11 +50,7 @@ impl<'a> RetrieveTreasuryReceivedDebit<'a> { } impl<'a> RetrieveTreasuryReceivedDebit<'a> { /// Retrieves the details of an existing ReceivedDebit by passing the unique ReceivedDebit ID from the ReceivedDebit list. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_treasury::TreasuryReceivedDebitId, - ) -> stripe::Response<stripe_treasury::TreasuryReceivedDebit> { + pub fn send(&self, client: &stripe::Client, id: &stripe_treasury::TreasuryReceivedDebitId) -> stripe::Response<stripe_treasury::TreasuryReceivedDebit> { client.get_query(&format!("/treasury/received_debits/{id}"), self) } } @@ -87,39 +71,24 @@ pub struct CreateTreasuryReceivedDebit<'a> { pub financial_account: &'a str, /// Initiating payment method details for the object. #[serde(skip_serializing_if = "Option::is_none")] - pub initiating_payment_method_details: - Option<CreateTreasuryReceivedDebitInitiatingPaymentMethodDetails<'a>>, + pub initiating_payment_method_details: Option<CreateTreasuryReceivedDebitInitiatingPaymentMethodDetails<'a>>, /// The rails used for the object. pub network: CreateTreasuryReceivedDebitNetwork, } impl<'a> CreateTreasuryReceivedDebit<'a> { - pub fn new( - amount: i64, - currency: stripe_types::Currency, - financial_account: &'a str, - network: CreateTreasuryReceivedDebitNetwork, - ) -> Self { - Self { - amount, - currency, - description: None, - expand: None, - financial_account, - initiating_payment_method_details: None, - network, - } + pub fn new(amount: i64, currency: stripe_types::Currency, financial_account: &'a str, network: CreateTreasuryReceivedDebitNetwork) -> Self { + Self { amount, currency, description: None, expand: None, financial_account, initiating_payment_method_details: None, network } } } /// Initiating payment method details for the object. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTreasuryReceivedDebitInitiatingPaymentMethodDetails<'a> { /// The source type. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: CreateTreasuryReceivedDebitInitiatingPaymentMethodDetailsType, /// Optional fields for `us_bank_account`. #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<CreateTreasuryReceivedDebitInitiatingPaymentMethodDetailsUsBankAccount<'a>>, + pub us_bank_account: Option<CreateTreasuryReceivedDebitInitiatingPaymentMethodDetailsUsBankAccount<'a>>, } impl<'a> CreateTreasuryReceivedDebitInitiatingPaymentMethodDetails<'a> { pub fn new(type_: CreateTreasuryReceivedDebitInitiatingPaymentMethodDetailsType) -> Self { @@ -233,10 +202,7 @@ impl serde::Serialize for CreateTreasuryReceivedDebitNetwork { impl<'a> CreateTreasuryReceivedDebit<'a> { /// Use this endpoint to simulate a test mode ReceivedDebit initiated by a third party. /// In live mode, you can’t directly create ReceivedDebits initiated by third parties. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_treasury::TreasuryReceivedDebit> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_treasury::TreasuryReceivedDebit> { client.send_form("/test_helpers/treasury/received_debits", self, http_types::Method::Post) } } diff --git a/generated/stripe_treasury/src/treasury_received_debit/types.rs b/generated/stripe_treasury/src/treasury_received_debit/types.rs index fe061ab9b..c2c26ecbe 100644 --- a/generated/stripe_treasury/src/treasury_received_debit/types.rs +++ b/generated/stripe_treasury/src/treasury_received_debit/types.rs @@ -1,42 +1,216 @@ /// ReceivedDebits represent funds pulled from a [FinancialAccount](https://stripe.com/docs/api#financial_accounts). /// These are not initiated from the FinancialAccount. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedDebit { /// Amount (in cents) transferred. -pub amount: i64, + pub amount: i64, /// Time at which the object was created. Measured in seconds since the Unix epoch. -pub created: stripe_types::Timestamp, - /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. + pub created: stripe_types::Timestamp, + /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// Must be a [supported currency](https://stripe.com/docs/currencies). -pub currency: stripe_types::Currency, + pub currency: stripe_types::Currency, /// An arbitrary string attached to the object. Often useful for displaying to users. -pub description: String, - /// Reason for the failure. + pub description: String, + /// Reason for the failure. /// A ReceivedDebit might fail because the FinancialAccount doesn't have sufficient funds, is closed, or is frozen. -pub failure_code: Option<TreasuryReceivedDebitFailureCode>, + pub failure_code: Option<TreasuryReceivedDebitFailureCode>, /// The FinancialAccount that funds were pulled from. -pub financial_account: Option<String>, - /// A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. -pub hosted_regulatory_receipt_url: Option<String>, + pub financial_account: Option<String>, + /// A [hosted transaction receipt](https://stripe.com/docs/treasury/moving-money/regulatory-receipts) URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. + pub hosted_regulatory_receipt_url: Option<String>, /// Unique identifier for the object. -pub id: stripe_treasury::TreasuryReceivedDebitId, -#[serde(skip_serializing_if = "Option::is_none")] -pub initiating_payment_method_details: Option<stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails>, -pub linked_flows: stripe_treasury::TreasuryReceivedDebitsResourceLinkedFlows, - /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. -pub livemode: bool, + pub id: stripe_treasury::TreasuryReceivedDebitId, + pub initiating_payment_method_details: Option<stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails>, + pub linked_flows: stripe_treasury::TreasuryReceivedDebitsResourceLinkedFlows, + /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. + pub livemode: bool, /// The network used for the ReceivedDebit. -pub network: TreasuryReceivedDebitNetwork, + pub network: TreasuryReceivedDebitNetwork, /// Details describing when a ReceivedDebit might be reversed. -pub reversal_details: Option<stripe_treasury::TreasuryReceivedDebitsResourceReversalDetails>, - /// Status of the ReceivedDebit. + pub reversal_details: Option<stripe_treasury::TreasuryReceivedDebitsResourceReversalDetails>, + /// Status of the ReceivedDebit. /// ReceivedDebits are created with a status of either `succeeded` (approved) or `failed` (declined). /// The failure reason can be found under the `failure_code`. -pub status: stripe_treasury::TreasuryReceivedDebitStatus, + pub status: stripe_treasury::TreasuryReceivedDebitStatus, /// The Transaction associated with this object. -pub transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, - + pub transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, +} +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedDebitBuilder { + amount: Option<i64>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<String>, + failure_code: Option<Option<TreasuryReceivedDebitFailureCode>>, + financial_account: Option<Option<String>>, + hosted_regulatory_receipt_url: Option<Option<String>>, + id: Option<stripe_treasury::TreasuryReceivedDebitId>, + initiating_payment_method_details: Option<Option<stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails>>, + linked_flows: Option<stripe_treasury::TreasuryReceivedDebitsResourceLinkedFlows>, + livemode: Option<bool>, + network: Option<TreasuryReceivedDebitNetwork>, + reversal_details: Option<Option<stripe_treasury::TreasuryReceivedDebitsResourceReversalDetails>>, + status: Option<stripe_treasury::TreasuryReceivedDebitStatus>, + transaction: Option<Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>>, } + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedDebit { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedDebit>, + builder: TreasuryReceivedDebitBuilder, + } + + impl Visitor for Place<TreasuryReceivedDebit> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedDebitBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedDebitBuilder { + type Out = TreasuryReceivedDebit; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "failure_code" => Deserialize::begin(&mut self.failure_code), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "hosted_regulatory_receipt_url" => Deserialize::begin(&mut self.hosted_regulatory_receipt_url), + "id" => Deserialize::begin(&mut self.id), + "initiating_payment_method_details" => Deserialize::begin(&mut self.initiating_payment_method_details), + "linked_flows" => Deserialize::begin(&mut self.linked_flows), + "livemode" => Deserialize::begin(&mut self.livemode), + "network" => Deserialize::begin(&mut self.network), + "reversal_details" => Deserialize::begin(&mut self.reversal_details), + "status" => Deserialize::begin(&mut self.status), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + failure_code: Deserialize::default(), + financial_account: Deserialize::default(), + hosted_regulatory_receipt_url: Deserialize::default(), + id: Deserialize::default(), + initiating_payment_method_details: Deserialize::default(), + linked_flows: Deserialize::default(), + livemode: Deserialize::default(), + network: Deserialize::default(), + reversal_details: Deserialize::default(), + status: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let failure_code = self.failure_code.take()?; + let financial_account = self.financial_account.take()?; + let hosted_regulatory_receipt_url = self.hosted_regulatory_receipt_url.take()?; + let id = self.id.take()?; + let initiating_payment_method_details = self.initiating_payment_method_details.take()?; + let linked_flows = self.linked_flows.take()?; + let livemode = self.livemode.take()?; + let network = self.network.take()?; + let reversal_details = self.reversal_details.take()?; + let status = self.status.take()?; + let transaction = self.transaction.take()?; + + Some(Self::Out { + amount, + created, + currency, + description, + failure_code, + financial_account, + hosted_regulatory_receipt_url, + id, + initiating_payment_method_details, + linked_flows, + livemode, + network, + reversal_details, + status, + transaction, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedDebit { + type Builder = TreasuryReceivedDebitBuilder; + } + + impl FromValueOpt for TreasuryReceivedDebit { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedDebitBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "failure_code" => b.failure_code = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "hosted_regulatory_receipt_url" => b.hosted_regulatory_receipt_url = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "initiating_payment_method_details" => b.initiating_payment_method_details = Some(FromValueOpt::from_value(v)?), + "linked_flows" => b.linked_flows = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "network" => b.network = Some(FromValueOpt::from_value(v)?), + "reversal_details" => b.reversal_details = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for the failure. /// A ReceivedDebit might fail because the FinancialAccount doesn't have sufficient funds, is closed, or is frozen. #[derive(Copy, Clone, Eq, PartialEq)] @@ -94,11 +268,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitFailureCode { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryReceivedDebitFailureCode") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedDebitFailureCode")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedDebitFailureCode { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedDebitFailureCode> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedDebitFailureCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitFailureCode); /// The network used for the ReceivedDebit. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryReceivedDebitNetwork { @@ -152,10 +342,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitNetwork { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedDebitNetwork")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedDebitNetwork")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedDebitNetwork { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedDebitNetwork> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedDebitNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitNetwork); impl stripe_types::Object for TreasuryReceivedDebit { type Id = stripe_treasury::TreasuryReceivedDebitId; fn id(&self) -> &Self::Id { @@ -212,7 +419,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedDebitStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedDebitStatus")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedDebitStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedDebitStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedDebitStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitStatus); diff --git a/generated/stripe_treasury/src/treasury_received_debits_resource_debit_reversal_linked_flows.rs b/generated/stripe_treasury/src/treasury_received_debits_resource_debit_reversal_linked_flows.rs index 96b31b048..f3781af7e 100644 --- a/generated/stripe_treasury/src/treasury_received_debits_resource_debit_reversal_linked_flows.rs +++ b/generated/stripe_treasury/src/treasury_received_debits_resource_debit_reversal_linked_flows.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedDebitsResourceDebitReversalLinkedFlows { /// Set if there is an Issuing dispute associated with the DebitReversal. pub issuing_dispute: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder { + issuing_dispute: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedDebitsResourceDebitReversalLinkedFlows { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedDebitsResourceDebitReversalLinkedFlows>, + builder: TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder, + } + + impl Visitor for Place<TreasuryReceivedDebitsResourceDebitReversalLinkedFlows> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder { + type Out = TreasuryReceivedDebitsResourceDebitReversalLinkedFlows; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "issuing_dispute" => Deserialize::begin(&mut self.issuing_dispute), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { issuing_dispute: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let issuing_dispute = self.issuing_dispute.take()?; + + Some(Self::Out { issuing_dispute }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedDebitsResourceDebitReversalLinkedFlows { + type Builder = TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder; + } + + impl FromValueOpt for TreasuryReceivedDebitsResourceDebitReversalLinkedFlows { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "issuing_dispute" => b.issuing_dispute = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_received_debits_resource_linked_flows.rs b/generated/stripe_treasury/src/treasury_received_debits_resource_linked_flows.rs index f5f2f5e4a..cb126fbbd 100644 --- a/generated/stripe_treasury/src/treasury_received_debits_resource_linked_flows.rs +++ b/generated/stripe_treasury/src/treasury_received_debits_resource_linked_flows.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedDebitsResourceLinkedFlows { /// The DebitReversal created as a result of this ReceivedDebit being reversed. pub debit_reversal: Option<String>, @@ -9,3 +11,101 @@ pub struct TreasuryReceivedDebitsResourceLinkedFlows { /// Set if the ReceivedDebit is also viewable as an [Issuing Dispute](https://stripe.com/docs/api#issuing_disputes) object. pub issuing_transaction: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedDebitsResourceLinkedFlowsBuilder { + debit_reversal: Option<Option<String>>, + inbound_transfer: Option<Option<String>>, + issuing_authorization: Option<Option<String>>, + issuing_transaction: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedDebitsResourceLinkedFlows { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedDebitsResourceLinkedFlows>, + builder: TreasuryReceivedDebitsResourceLinkedFlowsBuilder, + } + + impl Visitor for Place<TreasuryReceivedDebitsResourceLinkedFlows> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedDebitsResourceLinkedFlowsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedDebitsResourceLinkedFlowsBuilder { + type Out = TreasuryReceivedDebitsResourceLinkedFlows; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "debit_reversal" => Deserialize::begin(&mut self.debit_reversal), + "inbound_transfer" => Deserialize::begin(&mut self.inbound_transfer), + "issuing_authorization" => Deserialize::begin(&mut self.issuing_authorization), + "issuing_transaction" => Deserialize::begin(&mut self.issuing_transaction), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { debit_reversal: Deserialize::default(), inbound_transfer: Deserialize::default(), issuing_authorization: Deserialize::default(), issuing_transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let debit_reversal = self.debit_reversal.take()?; + let inbound_transfer = self.inbound_transfer.take()?; + let issuing_authorization = self.issuing_authorization.take()?; + let issuing_transaction = self.issuing_transaction.take()?; + + Some(Self::Out { debit_reversal, inbound_transfer, issuing_authorization, issuing_transaction }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedDebitsResourceLinkedFlows { + type Builder = TreasuryReceivedDebitsResourceLinkedFlowsBuilder; + } + + impl FromValueOpt for TreasuryReceivedDebitsResourceLinkedFlows { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedDebitsResourceLinkedFlowsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "debit_reversal" => b.debit_reversal = Some(FromValueOpt::from_value(v)?), + "inbound_transfer" => b.inbound_transfer = Some(FromValueOpt::from_value(v)?), + "issuing_authorization" => b.issuing_authorization = Some(FromValueOpt::from_value(v)?), + "issuing_transaction" => b.issuing_transaction = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_received_debits_resource_reversal_details.rs b/generated/stripe_treasury/src/treasury_received_debits_resource_reversal_details.rs index c83c17064..8441fa2cc 100644 --- a/generated/stripe_treasury/src/treasury_received_debits_resource_reversal_details.rs +++ b/generated/stripe_treasury/src/treasury_received_debits_resource_reversal_details.rs @@ -1,10 +1,102 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedDebitsResourceReversalDetails { /// Time before which a ReceivedDebit can be reversed. pub deadline: Option<stripe_types::Timestamp>, /// Set if a ReceivedDebit can't be reversed. pub restricted_reason: Option<TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedDebitsResourceReversalDetailsBuilder { + deadline: Option<Option<stripe_types::Timestamp>>, + restricted_reason: Option<Option<TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedDebitsResourceReversalDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedDebitsResourceReversalDetails>, + builder: TreasuryReceivedDebitsResourceReversalDetailsBuilder, + } + + impl Visitor for Place<TreasuryReceivedDebitsResourceReversalDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedDebitsResourceReversalDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedDebitsResourceReversalDetailsBuilder { + type Out = TreasuryReceivedDebitsResourceReversalDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "deadline" => Deserialize::begin(&mut self.deadline), + "restricted_reason" => Deserialize::begin(&mut self.restricted_reason), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deadline: Deserialize::default(), restricted_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let deadline = self.deadline.take()?; + let restricted_reason = self.restricted_reason.take()?; + + Some(Self::Out { deadline, restricted_reason }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedDebitsResourceReversalDetails { + type Builder = TreasuryReceivedDebitsResourceReversalDetailsBuilder; + } + + impl FromValueOpt for TreasuryReceivedDebitsResourceReversalDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedDebitsResourceReversalDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "deadline" => b.deadline = Some(FromValueOpt::from_value(v)?), + "restricted_reason" => b.restricted_reason = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Set if a ReceivedDebit can't be reversed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason { @@ -60,16 +152,28 @@ impl serde::Serialize for TreasuryReceivedDebitsResourceReversalDetailsRestricte serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason -{ +impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason); diff --git a/generated/stripe_treasury/src/treasury_received_debits_resource_status_transitions.rs b/generated/stripe_treasury/src/treasury_received_debits_resource_status_transitions.rs index 66df51d8e..8abb7c326 100644 --- a/generated/stripe_treasury/src/treasury_received_debits_resource_status_transitions.rs +++ b/generated/stripe_treasury/src/treasury_received_debits_resource_status_transitions.rs @@ -1,5 +1,93 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryReceivedDebitsResourceStatusTransitions { /// Timestamp describing when the DebitReversal changed status to `completed`. pub completed_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryReceivedDebitsResourceStatusTransitionsBuilder { + completed_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryReceivedDebitsResourceStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryReceivedDebitsResourceStatusTransitions>, + builder: TreasuryReceivedDebitsResourceStatusTransitionsBuilder, + } + + impl Visitor for Place<TreasuryReceivedDebitsResourceStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryReceivedDebitsResourceStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryReceivedDebitsResourceStatusTransitionsBuilder { + type Out = TreasuryReceivedDebitsResourceStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "completed_at" => Deserialize::begin(&mut self.completed_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { completed_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let completed_at = self.completed_at.take()?; + + Some(Self::Out { completed_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryReceivedDebitsResourceStatusTransitions { + type Builder = TreasuryReceivedDebitsResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for TreasuryReceivedDebitsResourceStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryReceivedDebitsResourceStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "completed_at" => b.completed_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_shared_resource_billing_details.rs b/generated/stripe_treasury/src/treasury_shared_resource_billing_details.rs index 6c3950af7..afbd69022 100644 --- a/generated/stripe_treasury/src/treasury_shared_resource_billing_details.rs +++ b/generated/stripe_treasury/src/treasury_shared_resource_billing_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasurySharedResourceBillingDetails { pub address: stripe_shared::Address, /// Email address. @@ -6,3 +8,97 @@ pub struct TreasurySharedResourceBillingDetails { /// Full name. pub name: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TreasurySharedResourceBillingDetailsBuilder { + address: Option<stripe_shared::Address>, + email: Option<Option<String>>, + name: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasurySharedResourceBillingDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasurySharedResourceBillingDetails>, + builder: TreasurySharedResourceBillingDetailsBuilder, + } + + impl Visitor for Place<TreasurySharedResourceBillingDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasurySharedResourceBillingDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasurySharedResourceBillingDetailsBuilder { + type Out = TreasurySharedResourceBillingDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "address" => Deserialize::begin(&mut self.address), + "email" => Deserialize::begin(&mut self.email), + "name" => Deserialize::begin(&mut self.name), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address: Deserialize::default(), email: Deserialize::default(), name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let address = self.address.take()?; + let email = self.email.take()?; + let name = self.name.take()?; + + Some(Self::Out { address, email, name }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasurySharedResourceBillingDetails { + type Builder = TreasurySharedResourceBillingDetailsBuilder; + } + + impl FromValueOpt for TreasurySharedResourceBillingDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasurySharedResourceBillingDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "address" => b.address = Some(FromValueOpt::from_value(v)?), + "email" => b.email = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_initiating_payment_method_details.rs b/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_initiating_payment_method_details.rs index 46ac9e487..1d3e8bdba 100644 --- a/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_initiating_payment_method_details.rs +++ b/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_initiating_payment_method_details.rs @@ -1,26 +1,133 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails { /// Set when `type` is `balance`. - #[serde(skip_serializing_if = "Option::is_none")] - pub balance: Option< - TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance, - >, + pub balance: Option<TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance>, pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, - #[serde(skip_serializing_if = "Option::is_none")] pub financial_account: Option<stripe_treasury::ReceivedPaymentMethodDetailsFinancialAccount>, /// Set when `type` is `issuing_card`. /// This is an [Issuing Card](https://stripe.com/docs/api#issuing_cards) ID. - #[serde(skip_serializing_if = "Option::is_none")] pub issuing_card: Option<String>, /// Polymorphic type matching the originating money movement's source. /// This can be an external account, a Stripe balance, or a FinancialAccount. - #[serde(rename = "type")] - pub type_: - TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType, - #[serde(skip_serializing_if = "Option::is_none")] - pub us_bank_account: - Option<stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount>, + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] + pub type_: TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType, + pub us_bank_account: Option<stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount>, } +#[cfg(feature = "min-ser")] +pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder { + balance: Option<Option<TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance>>, + billing_details: Option<stripe_treasury::TreasurySharedResourceBillingDetails>, + financial_account: Option<Option<stripe_treasury::ReceivedPaymentMethodDetailsFinancialAccount>>, + issuing_card: Option<Option<String>>, + type_: Option<TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType>, + us_bank_account: Option<Option<stripe_treasury::TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails>, + builder: TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder, + } + + impl Visitor for Place<TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder { + type Out = TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "balance" => Deserialize::begin(&mut self.balance), + "billing_details" => Deserialize::begin(&mut self.billing_details), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "issuing_card" => Deserialize::begin(&mut self.issuing_card), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + balance: Deserialize::default(), + billing_details: Deserialize::default(), + financial_account: Deserialize::default(), + issuing_card: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let balance = self.balance.take()?; + let billing_details = self.billing_details.take()?; + let financial_account = self.financial_account.take()?; + let issuing_card = self.issuing_card.take()?; + let type_ = self.type_.take()?; + let us_bank_account = self.us_bank_account.take()?; + + Some(Self::Out { balance, billing_details, financial_account, issuing_card, type_, us_bank_account }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails { + type Builder = TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder; + } + + impl FromValueOpt for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "balance" => b.balance = Some(FromValueOpt::from_value(v)?), + "billing_details" => b.billing_details = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "issuing_card" => b.issuing_card = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "us_bank_account" => b.us_bank_account = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Set when `type` is `balance`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { @@ -35,9 +142,7 @@ impl TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethod } } -impl std::str::FromStr - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance -{ +impl std::str::FromStr for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance::*; @@ -47,24 +152,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance -{ +impl std::fmt::Display for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance -{ +impl std::fmt::Debug for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance -{ +impl serde::Serialize for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -72,15 +171,31 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance -{ +impl<'de> serde::Deserialize<'de> for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance); /// Polymorphic type matching the originating money movement's source. /// This can be an external account, a Stripe balance, or a FinancialAccount. #[derive(Copy, Clone, Eq, PartialEq)] @@ -104,9 +219,7 @@ impl TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethod } } -impl std::str::FromStr - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType -{ +impl std::str::FromStr for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType { type Err = (); fn from_str(s: &str) -> Result<Self, Self::Err> { use TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType::*; @@ -120,24 +233,18 @@ impl std::str::FromStr } } } -impl std::fmt::Display - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType -{ +impl std::fmt::Display for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType -{ +impl std::fmt::Debug for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType -{ +impl serde::Serialize for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, @@ -145,12 +252,28 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> - for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType -{ +impl<'de> serde::Deserialize<'de> for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType); diff --git a/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_us_bank_account.rs b/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_us_bank_account.rs index 24ba0cdff..8dc2b1ef2 100644 --- a/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_us_bank_account.rs +++ b/generated/stripe_treasury/src/treasury_shared_resource_initiating_payment_method_details_us_bank_account.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount { /// Bank name. pub bank_name: Option<String>, @@ -7,3 +9,97 @@ pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount { /// The routing number for the bank account. pub routing_number: Option<String>, } +#[cfg(feature = "min-ser")] +pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder { + bank_name: Option<Option<String>>, + last4: Option<Option<String>>, + routing_number: Option<Option<String>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount>, + builder: TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place<TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder { + type Out = TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "bank_name" => Deserialize::begin(&mut self.bank_name), + "last4" => Deserialize::begin(&mut self.last4), + "routing_number" => Deserialize::begin(&mut self.routing_number), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_name: Deserialize::default(), last4: Deserialize::default(), routing_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let bank_name = self.bank_name.take()?; + let last4 = self.last4.take()?; + let routing_number = self.routing_number.take()?; + + Some(Self::Out { bank_name, last4, routing_number }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount { + type Builder = TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder; + } + + impl FromValueOpt for TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "bank_name" => b.bank_name = Some(FromValueOpt::from_value(v)?), + "last4" => b.last4 = Some(FromValueOpt::from_value(v)?), + "routing_number" => b.routing_number = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_transaction/requests.rs b/generated/stripe_treasury/src/treasury_transaction/requests.rs index e9dc83b9f..b0e2b7a21 100644 --- a/generated/stripe_treasury/src/treasury_transaction/requests.rs +++ b/generated/stripe_treasury/src/treasury_transaction/requests.rs @@ -1,3 +1,20 @@ +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTreasuryTransaction<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTreasuryTransaction<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTreasuryTransaction<'a> { + /// Retrieves the details of an existing Transaction. + pub fn send(&self, client: &stripe::Client, id: &stripe_treasury::TreasuryTransactionId) -> stripe::Response<stripe_treasury::TreasuryTransaction> { + client.get_query(&format!("/treasury/transactions/{id}"), self) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ListTreasuryTransaction<'a> { #[serde(skip_serializing_if = "Option::is_none")] @@ -35,17 +52,7 @@ pub struct ListTreasuryTransaction<'a> { } impl<'a> ListTreasuryTransaction<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - created: None, - ending_before: None, - expand: None, - financial_account, - limit: None, - order_by: None, - starting_after: None, - status: None, - status_transitions: None, - } + Self { created: None, ending_before: None, expand: None, financial_account, limit: None, order_by: None, starting_after: None, status: None, status_transitions: None } } } /// The results are in reverse chronological order by `created` or `posted_at`. @@ -110,36 +117,10 @@ impl ListTreasuryTransactionStatusTransitions { } impl<'a> ListTreasuryTransaction<'a> { /// Retrieves a list of Transaction objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryTransaction>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryTransaction>> { client.get_query("/treasury/transactions", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryTransaction>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryTransaction>> { stripe::ListPaginator::from_list_params("/treasury/transactions", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTreasuryTransaction<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveTreasuryTransaction<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveTreasuryTransaction<'a> { - /// Retrieves the details of an existing Transaction. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_treasury::TreasuryTransactionId, - ) -> stripe::Response<stripe_treasury::TreasuryTransaction> { - client.get_query(&format!("/treasury/transactions/{id}"), self) - } -} diff --git a/generated/stripe_treasury/src/treasury_transaction/types.rs b/generated/stripe_treasury/src/treasury_transaction/types.rs index 33e551d9a..f0fe62364 100644 --- a/generated/stripe_treasury/src/treasury_transaction/types.rs +++ b/generated/stripe_treasury/src/treasury_transaction/types.rs @@ -1,5 +1,7 @@ /// Transactions represent changes to a [FinancialAccount's](https://stripe.com/docs/api#financial_accounts) balance. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryTransaction { /// Amount (in cents) transferred. pub amount: i64, @@ -28,9 +30,161 @@ pub struct TreasuryTransaction { pub livemode: bool, /// Status of the Transaction. pub status: stripe_treasury::TreasuryTransactionStatus, - pub status_transitions: - stripe_treasury::TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions, + pub status_transitions: stripe_treasury::TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions, } +#[cfg(feature = "min-ser")] +pub struct TreasuryTransactionBuilder { + amount: Option<i64>, + balance_impact: Option<stripe_treasury::TreasuryTransactionsResourceBalanceImpact>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + description: Option<String>, + entries: Option<Option<stripe_types::List<stripe_treasury::TreasuryTransactionEntry>>>, + financial_account: Option<String>, + flow: Option<Option<String>>, + flow_details: Option<Option<stripe_treasury::TreasuryTransactionsResourceFlowDetails>>, + flow_type: Option<TreasuryTransactionFlowType>, + id: Option<stripe_treasury::TreasuryTransactionId>, + livemode: Option<bool>, + status: Option<stripe_treasury::TreasuryTransactionStatus>, + status_transitions: Option<stripe_treasury::TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryTransaction { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryTransaction>, + builder: TreasuryTransactionBuilder, + } + + impl Visitor for Place<TreasuryTransaction> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryTransactionBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryTransactionBuilder { + type Out = TreasuryTransaction; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount" => Deserialize::begin(&mut self.amount), + "balance_impact" => Deserialize::begin(&mut self.balance_impact), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "entries" => Deserialize::begin(&mut self.entries), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "flow" => Deserialize::begin(&mut self.flow), + "flow_details" => Deserialize::begin(&mut self.flow_details), + "flow_type" => Deserialize::begin(&mut self.flow_type), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + balance_impact: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + entries: Deserialize::default(), + financial_account: Deserialize::default(), + flow: Deserialize::default(), + flow_details: Deserialize::default(), + flow_type: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let amount = self.amount.take()?; + let balance_impact = self.balance_impact.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let description = self.description.take()?; + let entries = self.entries.take()?; + let financial_account = self.financial_account.take()?; + let flow = self.flow.take()?; + let flow_details = self.flow_details.take()?; + let flow_type = self.flow_type.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let status = self.status.take()?; + let status_transitions = self.status_transitions.take()?; + + Some(Self::Out { amount, balance_impact, created, currency, description, entries, financial_account, flow, flow_details, flow_type, id, livemode, status, status_transitions }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryTransaction { + type Builder = TreasuryTransactionBuilder; + } + + impl FromValueOpt for TreasuryTransaction { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryTransactionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount" => b.amount = Some(FromValueOpt::from_value(v)?), + "balance_impact" => b.balance_impact = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "entries" => b.entries = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "flow" => b.flow = Some(FromValueOpt::from_value(v)?), + "flow_details" => b.flow_details = Some(FromValueOpt::from_value(v)?), + "flow_type" => b.flow_type = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => b.status_transitions = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of the flow that created the Transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryTransactionFlowType { @@ -102,10 +256,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionFlowType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryTransactionFlowType")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryTransactionFlowType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryTransactionFlowType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryTransactionFlowType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionFlowType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionFlowType); impl stripe_types::Object for TreasuryTransaction { type Id = stripe_treasury::TreasuryTransactionId; fn id(&self) -> &Self::Id { @@ -165,7 +336,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionStatus { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s) - .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryTransactionStatus")) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryTransactionStatus")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryTransactionStatus { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryTransactionStatus> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionStatus); diff --git a/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs b/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs index 5e1cbf5d3..7a7d69424 100644 --- a/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs +++ b/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs @@ -1,3 +1,20 @@ +#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +pub struct RetrieveTreasuryTransactionEntry<'a> { + /// Specifies which fields in the response should be expanded. + #[serde(skip_serializing_if = "Option::is_none")] + pub expand: Option<&'a [&'a str]>, +} +impl<'a> RetrieveTreasuryTransactionEntry<'a> { + pub fn new() -> Self { + Self::default() + } +} +impl<'a> RetrieveTreasuryTransactionEntry<'a> { + /// Retrieves a TransactionEntry object. + pub fn send(&self, client: &stripe::Client, id: &stripe_treasury::TreasuryTransactionEntryId) -> stripe::Response<stripe_treasury::TreasuryTransactionEntry> { + client.get_query(&format!("/treasury/transaction_entries/{id}"), self) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ListTreasuryTransactionEntry<'a> { #[serde(skip_serializing_if = "Option::is_none")] @@ -33,17 +50,7 @@ pub struct ListTreasuryTransactionEntry<'a> { } impl<'a> ListTreasuryTransactionEntry<'a> { pub fn new(financial_account: &'a str) -> Self { - Self { - created: None, - effective_at: None, - ending_before: None, - expand: None, - financial_account, - limit: None, - order_by: None, - starting_after: None, - transaction: None, - } + Self { created: None, effective_at: None, ending_before: None, expand: None, financial_account, limit: None, order_by: None, starting_after: None, transaction: None } } } /// The results are in reverse chronological order by `created` or `effective_at`. @@ -95,36 +102,10 @@ impl serde::Serialize for ListTreasuryTransactionEntryOrderBy { } impl<'a> ListTreasuryTransactionEntry<'a> { /// Retrieves a list of TransactionEntry objects. - pub fn send( - &self, - client: &stripe::Client, - ) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryTransactionEntry>> { + pub fn send(&self, client: &stripe::Client) -> stripe::Response<stripe_types::List<stripe_treasury::TreasuryTransactionEntry>> { client.get_query("/treasury/transaction_entries", self) } - pub fn paginate( - self, - ) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryTransactionEntry>> { + pub fn paginate(self) -> stripe::ListPaginator<stripe_types::List<stripe_treasury::TreasuryTransactionEntry>> { stripe::ListPaginator::from_list_params("/treasury/transaction_entries", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveTreasuryTransactionEntry<'a> { - /// Specifies which fields in the response should be expanded. - #[serde(skip_serializing_if = "Option::is_none")] - pub expand: Option<&'a [&'a str]>, -} -impl<'a> RetrieveTreasuryTransactionEntry<'a> { - pub fn new() -> Self { - Self::default() - } -} -impl<'a> RetrieveTreasuryTransactionEntry<'a> { - /// Retrieves a TransactionEntry object. - pub fn send( - &self, - client: &stripe::Client, - id: &stripe_treasury::TreasuryTransactionEntryId, - ) -> stripe::Response<stripe_treasury::TreasuryTransactionEntry> { - client.get_query(&format!("/treasury/transaction_entries/{id}"), self) - } -} diff --git a/generated/stripe_treasury/src/treasury_transaction_entry/types.rs b/generated/stripe_treasury/src/treasury_transaction_entry/types.rs index 920eb0631..73bc09b39 100644 --- a/generated/stripe_treasury/src/treasury_transaction_entry/types.rs +++ b/generated/stripe_treasury/src/treasury_transaction_entry/types.rs @@ -1,5 +1,7 @@ /// TransactionEntries represent individual units of money movements within a single [Transaction](https://stripe.com/docs/api#transactions). -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryTransactionEntry { pub balance_impact: stripe_treasury::TreasuryTransactionsResourceBalanceImpact, /// Time at which the object was created. Measured in seconds since the Unix epoch. @@ -24,9 +26,152 @@ pub struct TreasuryTransactionEntry { /// The Transaction associated with this object. pub transaction: stripe_types::Expandable<stripe_treasury::TreasuryTransaction>, /// The specific money movement that generated the TransactionEntry. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TreasuryTransactionEntryType, } +#[cfg(feature = "min-ser")] +pub struct TreasuryTransactionEntryBuilder { + balance_impact: Option<stripe_treasury::TreasuryTransactionsResourceBalanceImpact>, + created: Option<stripe_types::Timestamp>, + currency: Option<stripe_types::Currency>, + effective_at: Option<stripe_types::Timestamp>, + financial_account: Option<String>, + flow: Option<Option<String>>, + flow_details: Option<Option<stripe_treasury::TreasuryTransactionsResourceFlowDetails>>, + flow_type: Option<TreasuryTransactionEntryFlowType>, + id: Option<stripe_treasury::TreasuryTransactionEntryId>, + livemode: Option<bool>, + transaction: Option<stripe_types::Expandable<stripe_treasury::TreasuryTransaction>>, + type_: Option<TreasuryTransactionEntryType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryTransactionEntry { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryTransactionEntry>, + builder: TreasuryTransactionEntryBuilder, + } + + impl Visitor for Place<TreasuryTransactionEntry> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryTransactionEntryBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryTransactionEntryBuilder { + type Out = TreasuryTransactionEntry; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "balance_impact" => Deserialize::begin(&mut self.balance_impact), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "effective_at" => Deserialize::begin(&mut self.effective_at), + "financial_account" => Deserialize::begin(&mut self.financial_account), + "flow" => Deserialize::begin(&mut self.flow), + "flow_details" => Deserialize::begin(&mut self.flow_details), + "flow_type" => Deserialize::begin(&mut self.flow_type), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "transaction" => Deserialize::begin(&mut self.transaction), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + balance_impact: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + effective_at: Deserialize::default(), + financial_account: Deserialize::default(), + flow: Deserialize::default(), + flow_details: Deserialize::default(), + flow_type: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + transaction: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let balance_impact = self.balance_impact.take()?; + let created = self.created.take()?; + let currency = self.currency.take()?; + let effective_at = self.effective_at.take()?; + let financial_account = self.financial_account.take()?; + let flow = self.flow.take()?; + let flow_details = self.flow_details.take()?; + let flow_type = self.flow_type.take()?; + let id = self.id.take()?; + let livemode = self.livemode.take()?; + let transaction = self.transaction.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { balance_impact, created, currency, effective_at, financial_account, flow, flow_details, flow_type, id, livemode, transaction, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryTransactionEntry { + type Builder = TreasuryTransactionEntryBuilder; + } + + impl FromValueOpt for TreasuryTransactionEntry { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryTransactionEntryBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "balance_impact" => b.balance_impact = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "effective_at" => b.effective_at = Some(FromValueOpt::from_value(v)?), + "financial_account" => b.financial_account = Some(FromValueOpt::from_value(v)?), + "flow" => b.flow = Some(FromValueOpt::from_value(v)?), + "flow_details" => b.flow_details = Some(FromValueOpt::from_value(v)?), + "flow_type" => b.flow_type = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "transaction" => b.transaction = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of the flow associated with the TransactionEntry. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryTransactionEntryFlowType { @@ -98,11 +243,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionEntryFlowType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom("Unknown value for TreasuryTransactionEntryFlowType") - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryTransactionEntryFlowType")) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryTransactionEntryFlowType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryTransactionEntryFlowType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionEntryFlowType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) } } + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionEntryFlowType); /// The specific money movement that generated the TransactionEntry. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -211,9 +372,27 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionEntryType { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Ok(Self::from_str(&s).unwrap_or(TreasuryTransactionEntryType::Unknown)) + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryTransactionEntryType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) } } + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryTransactionEntryType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionEntryType::from_str(s).unwrap_or(TreasuryTransactionEntryType::Unknown)); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionEntryType); impl stripe_types::Object for TreasuryTransactionEntry { type Id = stripe_treasury::TreasuryTransactionEntryId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_treasury/src/treasury_transactions_resource_abstract_transaction_resource_status_transitions.rs b/generated/stripe_treasury/src/treasury_transactions_resource_abstract_transaction_resource_status_transitions.rs index cf9550c30..b8e29e817 100644 --- a/generated/stripe_treasury/src/treasury_transactions_resource_abstract_transaction_resource_status_transitions.rs +++ b/generated/stripe_treasury/src/treasury_transactions_resource_abstract_transaction_resource_status_transitions.rs @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions { /// Timestamp describing when the Transaction changed status to `posted`. pub posted_at: Option<stripe_types::Timestamp>, /// Timestamp describing when the Transaction changed status to `void`. pub void_at: Option<stripe_types::Timestamp>, } +#[cfg(feature = "min-ser")] +pub struct TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder { + posted_at: Option<Option<stripe_types::Timestamp>>, + void_at: Option<Option<stripe_types::Timestamp>>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions>, + builder: TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder, + } + + impl Visitor for Place<TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder { + type Out = TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "posted_at" => Deserialize::begin(&mut self.posted_at), + "void_at" => Deserialize::begin(&mut self.void_at), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { posted_at: Deserialize::default(), void_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let posted_at = self.posted_at.take()?; + let void_at = self.void_at.take()?; + + Some(Self::Out { posted_at, void_at }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions { + type Builder = TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "posted_at" => b.posted_at = Some(FromValueOpt::from_value(v)?), + "void_at" => b.void_at = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_transactions_resource_balance_impact.rs b/generated/stripe_treasury/src/treasury_transactions_resource_balance_impact.rs index 13d65acb0..c2fd51875 100644 --- a/generated/stripe_treasury/src/treasury_transactions_resource_balance_impact.rs +++ b/generated/stripe_treasury/src/treasury_transactions_resource_balance_impact.rs @@ -1,5 +1,7 @@ /// Change to a FinancialAccount's balance -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryTransactionsResourceBalanceImpact { /// The change made to funds the user can spend right now. pub cash: i64, @@ -8,3 +10,97 @@ pub struct TreasuryTransactionsResourceBalanceImpact { /// The change made to funds in the account, but not spendable because they are being held for pending outbound flows. pub outbound_pending: i64, } +#[cfg(feature = "min-ser")] +pub struct TreasuryTransactionsResourceBalanceImpactBuilder { + cash: Option<i64>, + inbound_pending: Option<i64>, + outbound_pending: Option<i64>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryTransactionsResourceBalanceImpact { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryTransactionsResourceBalanceImpact>, + builder: TreasuryTransactionsResourceBalanceImpactBuilder, + } + + impl Visitor for Place<TreasuryTransactionsResourceBalanceImpact> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryTransactionsResourceBalanceImpactBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryTransactionsResourceBalanceImpactBuilder { + type Out = TreasuryTransactionsResourceBalanceImpact; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "cash" => Deserialize::begin(&mut self.cash), + "inbound_pending" => Deserialize::begin(&mut self.inbound_pending), + "outbound_pending" => Deserialize::begin(&mut self.outbound_pending), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { cash: Deserialize::default(), inbound_pending: Deserialize::default(), outbound_pending: Deserialize::default() } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let cash = self.cash.take()?; + let inbound_pending = self.inbound_pending.take()?; + let outbound_pending = self.outbound_pending.take()?; + + Some(Self::Out { cash, inbound_pending, outbound_pending }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryTransactionsResourceBalanceImpact { + type Builder = TreasuryTransactionsResourceBalanceImpactBuilder; + } + + impl FromValueOpt for TreasuryTransactionsResourceBalanceImpact { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryTransactionsResourceBalanceImpactBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "cash" => b.cash = Some(FromValueOpt::from_value(v)?), + "inbound_pending" => b.inbound_pending = Some(FromValueOpt::from_value(v)?), + "outbound_pending" => b.outbound_pending = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_treasury/src/treasury_transactions_resource_flow_details.rs b/generated/stripe_treasury/src/treasury_transactions_resource_flow_details.rs index 29a4ea2ee..92ce324fd 100644 --- a/generated/stripe_treasury/src/treasury_transactions_resource_flow_details.rs +++ b/generated/stripe_treasury/src/treasury_transactions_resource_flow_details.rs @@ -1,25 +1,147 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] pub struct TreasuryTransactionsResourceFlowDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub credit_reversal: Option<stripe_treasury::TreasuryCreditReversal>, - #[serde(skip_serializing_if = "Option::is_none")] pub debit_reversal: Option<stripe_treasury::TreasuryDebitReversal>, - #[serde(skip_serializing_if = "Option::is_none")] pub inbound_transfer: Option<stripe_treasury::TreasuryInboundTransfer>, - #[serde(skip_serializing_if = "Option::is_none")] pub issuing_authorization: Option<stripe_shared::IssuingAuthorization>, - #[serde(skip_serializing_if = "Option::is_none")] pub outbound_payment: Option<stripe_treasury::TreasuryOutboundPayment>, - #[serde(skip_serializing_if = "Option::is_none")] pub outbound_transfer: Option<stripe_treasury::TreasuryOutboundTransfer>, - #[serde(skip_serializing_if = "Option::is_none")] pub received_credit: Option<stripe_treasury::TreasuryReceivedCredit>, - #[serde(skip_serializing_if = "Option::is_none")] pub received_debit: Option<stripe_treasury::TreasuryReceivedDebit>, /// Type of the flow that created the Transaction. Set to the same value as `flow_type`. - #[serde(rename = "type")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "type"))] pub type_: TreasuryTransactionsResourceFlowDetailsType, } +#[cfg(feature = "min-ser")] +pub struct TreasuryTransactionsResourceFlowDetailsBuilder { + credit_reversal: Option<Option<stripe_treasury::TreasuryCreditReversal>>, + debit_reversal: Option<Option<stripe_treasury::TreasuryDebitReversal>>, + inbound_transfer: Option<Option<stripe_treasury::TreasuryInboundTransfer>>, + issuing_authorization: Option<Option<stripe_shared::IssuingAuthorization>>, + outbound_payment: Option<Option<stripe_treasury::TreasuryOutboundPayment>>, + outbound_transfer: Option<Option<stripe_treasury::TreasuryOutboundTransfer>>, + received_credit: Option<Option<stripe_treasury::TreasuryReceivedCredit>>, + received_debit: Option<Option<stripe_treasury::TreasuryReceivedDebit>>, + type_: Option<TreasuryTransactionsResourceFlowDetailsType>, +} + +#[cfg(feature = "min-ser")] +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TreasuryTransactionsResourceFlowDetails { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option<TreasuryTransactionsResourceFlowDetails>, + builder: TreasuryTransactionsResourceFlowDetailsBuilder, + } + + impl Visitor for Place<TreasuryTransactionsResourceFlowDetails> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: TreasuryTransactionsResourceFlowDetailsBuilder::deser_default() })) + } + } + + impl MapBuilder for TreasuryTransactionsResourceFlowDetailsBuilder { + type Out = TreasuryTransactionsResourceFlowDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "credit_reversal" => Deserialize::begin(&mut self.credit_reversal), + "debit_reversal" => Deserialize::begin(&mut self.debit_reversal), + "inbound_transfer" => Deserialize::begin(&mut self.inbound_transfer), + "issuing_authorization" => Deserialize::begin(&mut self.issuing_authorization), + "outbound_payment" => Deserialize::begin(&mut self.outbound_payment), + "outbound_transfer" => Deserialize::begin(&mut self.outbound_transfer), + "received_credit" => Deserialize::begin(&mut self.received_credit), + "received_debit" => Deserialize::begin(&mut self.received_debit), + "type" => Deserialize::begin(&mut self.type_), + + _ => <dyn Visitor>::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + credit_reversal: Deserialize::default(), + debit_reversal: Deserialize::default(), + inbound_transfer: Deserialize::default(), + issuing_authorization: Deserialize::default(), + outbound_payment: Deserialize::default(), + outbound_transfer: Deserialize::default(), + received_credit: Deserialize::default(), + received_debit: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option<Self::Out> { + let credit_reversal = self.credit_reversal.take()?; + let debit_reversal = self.debit_reversal.take()?; + let inbound_transfer = self.inbound_transfer.take()?; + let issuing_authorization = self.issuing_authorization.take()?; + let outbound_payment = self.outbound_payment.take()?; + let outbound_transfer = self.outbound_transfer.take()?; + let received_credit = self.received_credit.take()?; + let received_debit = self.received_debit.take()?; + let type_ = self.type_.take()?; + + Some(Self::Out { credit_reversal, debit_reversal, inbound_transfer, issuing_authorization, outbound_payment, outbound_transfer, received_credit, received_debit, type_ }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for TreasuryTransactionsResourceFlowDetails { + type Builder = TreasuryTransactionsResourceFlowDetailsBuilder; + } + + impl FromValueOpt for TreasuryTransactionsResourceFlowDetails { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TreasuryTransactionsResourceFlowDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "credit_reversal" => b.credit_reversal = Some(FromValueOpt::from_value(v)?), + "debit_reversal" => b.debit_reversal = Some(FromValueOpt::from_value(v)?), + "inbound_transfer" => b.inbound_transfer = Some(FromValueOpt::from_value(v)?), + "issuing_authorization" => b.issuing_authorization = Some(FromValueOpt::from_value(v)?), + "outbound_payment" => b.outbound_payment = Some(FromValueOpt::from_value(v)?), + "outbound_transfer" => b.outbound_transfer = Some(FromValueOpt::from_value(v)?), + "received_credit" => b.received_credit = Some(FromValueOpt::from_value(v)?), + "received_debit" => b.received_debit = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of the flow that created the Transaction. Set to the same value as `flow_type`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryTransactionsResourceFlowDetailsType { @@ -91,10 +213,24 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionsResourceFlowDetailsTyp fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| { - serde::de::Error::custom( - "Unknown value for TreasuryTransactionsResourceFlowDetailsType", - ) - }) + Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for TreasuryTransactionsResourceFlowDetailsType")) } } +#[cfg(feature = "min-ser")] +impl miniserde::Deserialize for TreasuryTransactionsResourceFlowDetailsType { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +#[cfg(feature = "min-ser")] +impl miniserde::de::Visitor for crate::Place<TreasuryTransactionsResourceFlowDetailsType> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionsResourceFlowDetailsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +#[cfg(feature = "min-ser")] +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionsResourceFlowDetailsType); diff --git a/openapi/src/codegen.rs b/openapi/src/codegen.rs index 0d4935ad9..309b912d3 100644 --- a/openapi/src/codegen.rs +++ b/openapi/src/codegen.rs @@ -116,11 +116,27 @@ impl CodeGen { {doc_comment} extern crate self as {crate_name}; + + #[cfg(feature = "min-ser")] + miniserde::make_place!(Place); "# }; let mod_path = base_path.join("src/mod.rs"); write_to_file(mod_rs, &mod_path)?; + + // NB: a hack to avoid the insanely long lines generated because of _very_ long + // type names causing `rustfmt` errors (https://github.com/rust-lang/rustfmt/issues/5315) + write_to_file( + r#" +use_small_heuristics = "Max" +reorder_imports = true +group_imports = "StdExternalCrate" +error_on_line_overflow = true +max_width = 200 + "#, + base_path.join(".rustfmt.toml"), + )?; } Ok(()) } diff --git a/openapi/src/object_writing.rs b/openapi/src/object_writing.rs index ea3efe846..72ac9f72b 100644 --- a/openapi/src/object_writing.rs +++ b/openapi/src/object_writing.rs @@ -3,6 +3,7 @@ use std::fmt::Write; use crate::components::Components; use crate::ids::write_object_id; use crate::printable::Lifetime; +use crate::rust_object::EnumOfObjects::ObjectUnion; use crate::rust_object::{as_enum_of_objects, ObjectMetadata, RustObject}; use crate::rust_type::RustType; use crate::stripe_object::{RequestSpec, StripeObject}; @@ -89,7 +90,10 @@ pub fn gen_obj( let Some(object_names) = as_enum_of_objects(components, variants) else { panic!("Object {} is an enum that is not a union of stripe objects", ident); }; - write_object_trait_for_enum(components, &mut out, ident, &object_names) + let ObjectUnion(objects) = object_names else { + panic!("Object {} is an enum that is not a union of stripe objects", ident); + }; + write_object_trait_for_enum(&mut out, ident, &objects) } RustObject::FieldlessEnum(_) => { panic!("Did not expect enum to have an id"); diff --git a/openapi/src/rust_object.rs b/openapi/src/rust_object.rs index ef6f28003..5755c7069 100644 --- a/openapi/src/rust_object.rs +++ b/openapi/src/rust_object.rs @@ -219,24 +219,77 @@ impl StructField { self.doc_comment = Some(doc_comment.to_string()); self } + + /// Expected name of the field when (de)serializing + pub fn wire_name(&self) -> &str { + self.rename_as.as_ref().unwrap_or(&self.field_name) + } } -pub fn as_enum_of_objects<'a>( - components: &'a Components, - variants: &'a [EnumVariant], -) -> Option<IndexMap<&'a str, ComponentPath>> { - let mut object_map = IndexMap::new(); +fn as_object_union( + components: &Components, + variants: &[EnumVariant], +) -> Option<IndexMap<String, ObjectRef>> { + let mut objects = IndexMap::new(); for variant in variants { - let path = variant.rust_type.as_ref().and_then(|t| t.as_component_path())?; + let path = variant.rust_type.as_ref()?.as_component_path()?; let obj = components.get(path); + let name = obj.data.object_name.as_deref()?; + let obj_ref = ObjectRef { path: path.clone(), ident: obj.ident().clone() }; - // If we have duplicate object names, we cannot distinguish by the object tag, so give up here - if object_map.insert(name, path.clone()).is_some() { + // Union of objects cannot have duplicate object names since then we cannot discriminate + // by the object key + if objects.insert(name.to_string(), obj_ref).is_some() { return None; } } - Some(object_map) + Some(objects) +} + +fn as_maybe_deleted(components: &Components, variants: &[EnumVariant]) -> Option<MaybeDeleted> { + if variants.len() != 2 { + return None; + } + + let mut base = None; + let mut deleted = None; + + for variant in variants { + let path = variant.rust_type.as_ref()?.as_component_path()?; + let obj = components.get(path); + let item = PathAndIdent { path: path.clone(), ident: obj.ident().clone() }; + if path.starts_with("deleted_") { + deleted = Some(item); + } else { + base = Some(item); + } + } + + Some(MaybeDeleted { base: base?, deleted: deleted? }) +} + +pub fn as_enum_of_objects( + components: &Components, + variants: &[EnumVariant], +) -> Option<EnumOfObjects> { + if let Some(obj_union) = as_object_union(components, variants) { + Some(EnumOfObjects::ObjectUnion(obj_union)) + } else { + as_maybe_deleted(components, variants).map(EnumOfObjects::MaybeDeleted) + } +} + +#[derive(Debug)] +pub struct ObjectRef { + pub path: ComponentPath, + pub ident: RustIdent, +} + +#[derive(Debug)] +pub enum EnumOfObjects { + MaybeDeleted(MaybeDeleted), + ObjectUnion(IndexMap<String, ObjectRef>), } #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] @@ -249,13 +302,35 @@ pub enum ObjectKind { Type, } +#[derive(Debug)] +pub struct PathAndIdent { + pub path: ComponentPath, + pub ident: RustIdent, +} + +#[derive(Debug)] +pub struct MaybeDeleted { + pub base: PathAndIdent, + pub deleted: PathAndIdent, +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub enum ShouldImplSerialize { + Always, + SkipIfMinSer, + Never, +} + impl ObjectKind { pub fn is_request_param(self) -> bool { matches!(self, Self::RequestParam) } - pub fn should_impl_serialize(self) -> bool { - true + pub fn should_impl_serialize(self) -> ShouldImplSerialize { + match self { + Self::RequestParam => ShouldImplSerialize::Always, + Self::Type | Self::RequestReturned => ShouldImplSerialize::SkipIfMinSer, + } } pub fn should_impl_deserialize(self) -> bool { diff --git a/openapi/src/rust_type.rs b/openapi/src/rust_type.rs index 63f3bd2c2..62079012b 100644 --- a/openapi/src/rust_type.rs +++ b/openapi/src/rust_type.rs @@ -195,8 +195,12 @@ impl RustType { Self::path(PathToType::Component(path), false) } + pub fn json_value(is_ref: bool) -> Self { + Self::Simple(SimpleType::Ext(ExtType::Value { is_ref, force_serde_json: false })) + } + pub fn serde_json_value(is_ref: bool) -> Self { - Self::Simple(SimpleType::Ext(ExtType::Value { is_ref })) + Self::Simple(SimpleType::Ext(ExtType::Value { is_ref, force_serde_json: true })) } pub fn object_id(id_path: ComponentPath, is_ref: bool) -> Self { @@ -210,13 +214,6 @@ impl RustType { } } - pub fn skip_serializing(&self) -> Option<&'static str> { - match self { - Self::Container(Container::Option(_)) => Some("Option::is_none"), - _ => None, - } - } - /// Find any `RustObject` that may be contained in this type pub fn extract_object(&self) -> Option<(&RustObject, &ObjectMetadata)> { match self { @@ -369,12 +366,12 @@ pub enum SimpleType { impl SimpleType { /// Does this type implement `Copy`? pub const fn is_copy(self) -> bool { - !matches!(self, Self::String | Self::Ext(ExtType::Value { is_ref: false })) + !matches!(self, Self::String | Self::Ext(ExtType::Value { is_ref: false, .. })) } /// Is this type a reference? pub const fn is_reference(self) -> bool { - matches!(self, Self::Str | Self::Ext(ExtType::Value { is_ref: true })) + matches!(self, Self::Str | Self::Ext(ExtType::Value { is_ref: true, .. })) } pub const fn ident(self) -> &'static str { @@ -438,9 +435,10 @@ pub enum ExtType { RangeQueryTs, Timestamp, AlwaysTrue, - /// serde_json::Value + /// Arbitrary JSON value Value { is_ref: bool, + force_serde_json: bool, }, } @@ -451,7 +449,13 @@ impl ExtType { Self::RangeQueryTs => "stripe_types::RangeQueryTs", Self::Timestamp => "stripe_types::Timestamp", Self::AlwaysTrue => "stripe_types::AlwaysTrue", - Self::Value { .. } => "serde_json::Value", + Self::Value { force_serde_json, .. } => { + if force_serde_json { + "serde_json::Value" + } else { + "stripe_types::Value" + } + } } } diff --git a/openapi/src/spec_inference.rs b/openapi/src/spec_inference.rs index af5fdd929..920d455c5 100644 --- a/openapi/src/spec_inference.rs +++ b/openapi/src/spec_inference.rs @@ -224,9 +224,13 @@ impl<'a> Inference<'a> { // when there is no specification of object shape. // FIXME: The unfortunate `field_name.is_some()` is used to avoid substituting - // a serde_json::Value for a top level component type (see for example mandate_us_bank_account) + // an arbitrary JSON value for a top level component type (see for example mandate_us_bank_account) if typ.properties.is_empty() && self.field_name.is_some() { - return RustType::serde_json_value(self.can_borrow); + return if self.kind.is_request_param() { + RustType::serde_json_value(self.can_borrow) + } else { + RustType::json_value(self.can_borrow) + }; } // Generate the struct type diff --git a/openapi/src/stripe_object.rs b/openapi/src/stripe_object.rs index ee228025b..1398c6991 100644 --- a/openapi/src/stripe_object.rs +++ b/openapi/src/stripe_object.rs @@ -83,6 +83,10 @@ impl StripeObject { self.resource.mod_path() } + pub fn object_name(&self) -> Option<&str> { + self.data.object_name.as_deref() + } + pub fn types_split_from_requests(&self) -> bool { self.types_are_shared() && self.krate_unwrapped().base() != Crate::SHARED } diff --git a/openapi/src/templates/cargo_toml.rs b/openapi/src/templates/cargo_toml.rs index 586fdebbb..02a4cdbd3 100644 --- a/openapi/src/templates/cargo_toml.rs +++ b/openapi/src/templates/cargo_toml.rs @@ -16,11 +16,17 @@ const CORE_FEATURES: &[&str] = &[ pub fn gen_crate_toml(krate: Crate, crate_deps: Vec<Crate>, crate_features: Vec<String>) -> String { let mut crate_dep_section = String::new(); + + let mut min_ser_features = vec!["miniserde".into(), "stripe_types/min-ser".into()]; for dep in crate_deps { let dep_path = format!("../../generated/{}", dep.name()); let _ = writeln!(crate_dep_section, r#"{} = {{path = "{}"}}"#, dep.name(), dep_path); + min_ser_features.push(format!("{}/min-ser", dep.name())); } + let min_ser_features_str = + min_ser_features.into_iter().map(|f| format!(r#""{f}""#)).collect::<Vec<_>>().join(","); + // Dependencies only needed for libraries which implement Stripe requests let request_deps = if krate == Crate::SHARED { "".into() @@ -57,12 +63,15 @@ pub fn gen_crate_toml(krate: Crate, crate_deps: Vec<Crate>, crate_features: Vec< serde.workspace = true smol_str.workspace = true serde_json.workspace = true + miniserde = {{ workspace = true, optional = true }} stripe_types = {{path = "../../stripe_types"}} {request_deps} {crate_dep_section} - + + [features] + min-ser = [{min_ser_features_str}] {features} "# } @@ -99,7 +108,6 @@ fn gen_feature_section(mut crate_features: Vec<String>) -> String { docs_rs_features.push(']'); formatdoc! { r#" - [features] {feature_section} [package.metadata.docs.rs] diff --git a/openapi/src/templates/derives.rs b/openapi/src/templates/derives.rs deleted file mode 100644 index fc837ba84..000000000 --- a/openapi/src/templates/derives.rs +++ /dev/null @@ -1,42 +0,0 @@ -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -pub struct Derives { - pub copy: bool, - pub debug: bool, - pub default: bool, - pub eq: bool, - pub serialize: bool, - pub deserialize: bool, -} - -impl Derives { - pub const fn new() -> Self { - Self { - debug: true, - copy: false, - default: false, - eq: false, - serialize: false, - deserialize: false, - } - } - - pub fn debug(mut self, debug: bool) -> Self { - self.debug = debug; - self - } - - pub fn copy(mut self, copy: bool) -> Self { - self.copy = copy; - self - } - - pub fn default(mut self, default: bool) -> Self { - self.default = default; - self - } - - pub fn eq(mut self, eq: bool) -> Self { - self.eq = eq; - self - } -} diff --git a/openapi/src/templates/enums.rs b/openapi/src/templates/enums.rs index 5f1f03599..2c8bf6db0 100644 --- a/openapi/src/templates/enums.rs +++ b/openapi/src/templates/enums.rs @@ -1,13 +1,12 @@ use std::fmt::Write as _; -use indexmap::IndexMap; use indoc::writedoc; use crate::printable::PrintableWithLifetime; -use crate::rust_object::{EnumVariant, FieldlessVariant}; +use crate::rust_object::{EnumOfObjects, EnumVariant, FieldlessVariant, ShouldImplSerialize}; +use crate::templates::miniserde::gen_enum_of_objects_miniserde; use crate::templates::object_writer::{write_derives_line, ObjectWriter}; -use crate::templates::utils::write_serde_rename; -use crate::types::ComponentPath; +use crate::templates::utils::{write_gated_serde_rename, write_gated_serde_tag}; impl<'a> ObjectWriter<'a> { pub fn write_enum_variants(&self, out: &mut String, variants: &[EnumVariant]) { @@ -26,47 +25,74 @@ impl<'a> ObjectWriter<'a> { } self.write_automatic_derives(out); let lifetime_str = self.lifetime_param(); + let serde_tag = if self.obj_kind.is_request_param() { + r#"#[serde(untagged)]"# + } else { + r#"#[cfg_attr(not(feature = "min-ser"), serde(untagged))]"# + }; let _ = writedoc!( out, r#" - #[serde(untagged)] + {serde_tag} pub enum {enum_name}{lifetime_str} {{ {enum_body} }} "# ); + if self.obj_kind.should_impl_deserialize() { + unimplemented!(); + } } - pub fn write_enum_of_objects(&self, out: &mut String, objects: &IndexMap<&str, ComponentPath>) { - if self.lifetime.is_some() { + pub fn write_enum_of_objects(&self, out: &mut String, objects: &EnumOfObjects) { + if self.lifetime.is_some() + || self.obj_kind.should_impl_serialize() != ShouldImplSerialize::SkipIfMinSer + { unimplemented!(); } let enum_name = self.ident; // Build the body of the enum definition let mut enum_body = String::with_capacity(64); - for (obj_name, obj_path) in objects { - let comp = self.components.get(obj_path); - let name = comp.ident(); - let printable = self.components.construct_printable_type_from_path(obj_path); - - write_serde_rename(&mut enum_body, obj_name); - let _ = writeln!(enum_body, "{name}({printable}),"); + match objects { + EnumOfObjects::MaybeDeleted(maybe_deleted) => { + for item in [&maybe_deleted.base, &maybe_deleted.deleted] { + let name = &item.ident; + let printable = self.components.construct_printable_type_from_path(&item.path); + let _ = writeln!(enum_body, "{name}({printable}),"); + } + } + EnumOfObjects::ObjectUnion(objects) => { + for (obj_name, obj) in objects { + let name = &obj.ident; + let printable = self.components.construct_printable_type_from_path(&obj.path); + write_gated_serde_rename(&mut enum_body, obj_name); + let _ = writeln!(enum_body, "{name}({printable}),"); + } + } } if self.provide_unknown_variant { - let _ = writeln!(enum_body, "#[serde(other)]"); + write_gated_serde_tag(&mut enum_body, "other"); let _ = writeln!(enum_body, "Unknown"); } self.write_automatic_derives(out); self.write_nonexhaustive_attr(out); + + match objects { + EnumOfObjects::MaybeDeleted(_) => write_gated_serde_tag(out, "untagged"), + EnumOfObjects::ObjectUnion(_) => write_gated_serde_tag(out, r#"tag = "object""#), + } + + let miniserde_impl = gen_enum_of_objects_miniserde(enum_name, objects); let _ = writedoc!( out, r#" - #[serde(tag = "object")] pub enum {enum_name} {{ {enum_body} }} + + {miniserde_impl} "# ); } @@ -151,27 +177,31 @@ impl<'a> ObjectWriter<'a> { "# ); - if self.obj_kind.should_impl_serialize() { - let _ = writedoc!( - out, - r#" + let _ = writedoc!( + out, + r#" impl serde::Serialize for {enum_name} {{ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer {{ serializer.serialize_str(self.as_str()) }} }} "# - ); - } + ); if self.obj_kind.should_impl_deserialize() { - let ret_line = if self.provide_unknown_variant { - format!("Ok(Self::from_str(&s).unwrap_or({enum_name}::Unknown))") + let serde_ret_line = if self.provide_unknown_variant { + "Ok(Self::from_str(&s).unwrap_or(Self::Unknown))".into() } else { format!( r#"Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for {enum_name}"))"# ) }; + + let miniserde_assign_line = if self.provide_unknown_variant { + format!("Some({enum_name}::from_str(s).unwrap_or({enum_name}::Unknown))") + } else { + format!("Some({enum_name}::from_str(s).map_err(|_| miniserde::Error)?)") + }; let _ = writedoc!( out, r#" @@ -179,9 +209,27 @@ impl<'a> ObjectWriter<'a> { fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {{ use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - {ret_line} + {serde_ret_line} }} }} + #[cfg(feature = "min-ser")] + impl miniserde::Deserialize for {enum_name} {{ + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {{ + crate::Place::new(out) + }} + }} + + #[cfg(feature = "min-ser")] + impl miniserde::de::Visitor for crate::Place<{enum_name}> {{ + fn string(&mut self, s: &str) -> miniserde::Result<()> {{ + use std::str::FromStr; + self.out = {miniserde_assign_line}; + Ok(()) + }} + }} + + #[cfg(feature = "min-ser")] + stripe_types::impl_from_val_with_from_str!({enum_name}); "# ); } diff --git a/openapi/src/templates/miniserde.rs b/openapi/src/templates/miniserde.rs new file mode 100644 index 000000000..1737d4f90 --- /dev/null +++ b/openapi/src/templates/miniserde.rs @@ -0,0 +1,297 @@ +use std::fmt::Write; + +use indoc::{formatdoc, writedoc}; + +use crate::rust_object::{EnumOfObjects, StructField}; +use crate::templates::ObjectWriter; +use crate::types::RustIdent; + +pub fn gen_enum_of_objects_miniserde(ident: &RustIdent, objects: &EnumOfObjects) -> String { + let builder_name = RustIdent::joined(ident, "Builder"); + let inner_builder_type = match objects { + EnumOfObjects::MaybeDeleted(_) => "MaybeDeletedBuilderInner", + EnumOfObjects::ObjectUnion(_) => "ObjectBuilderInner", + }; + let inner = build_inner(ident, &builder_name, objects); + formatdoc! { + r#" + #[cfg(feature = "min-ser")] + #[derive(Default)] + pub struct {builder_name} {{ + inner: stripe_types::miniserde_helpers::{inner_builder_type}, + }} + + #[cfg(feature = "min-ser")] + const _: () = {{ + use miniserde::de::{{Map, Visitor}}; + use miniserde::{{make_place, Deserialize, Result}}; + use stripe_types::MapBuilder; + use miniserde::json::Value; + use super::*; + use stripe_types::miniserde_helpers::FromValueOpt; + + make_place!(Place); + + {inner} + }}; + "# + } +} + +fn take_out_inner(ident: &RustIdent, objects: &EnumOfObjects) -> String { + match objects { + EnumOfObjects::MaybeDeleted(items) => { + let deleted_name = &items.deleted.ident; + let base_name = &items.base.ident; + formatdoc! {r#" + let (deleted, o) = self.inner.finish_inner()?; + Some(if deleted {{ + {ident}::{deleted_name}(FromValueOpt::from_value(Value::Object(o))?) + }} else {{ + {ident}::{base_name}(FromValueOpt::from_value(Value::Object(o))?) + }}) + "#} + } + EnumOfObjects::ObjectUnion(_) => { + formatdoc! {r#" + let (k, o) = self.inner.finish_inner()?; + {ident}::construct(&k, o) + "# + + } + } + } +} + +fn build_inner(ident: &RustIdent, builder_name: &RustIdent, objects: &EnumOfObjects) -> String { + let take_out_func_inner = take_out_inner(ident, objects); + let mut out = formatdoc! {r#" + struct Builder<'a> {{ + out: &'a mut Option<{ident}>, + builder: {builder_name}, + }} + + + impl Deserialize for {ident} {{ + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {{ + Place::new(out) + }} + }} + + impl Visitor for Place<{ident}> {{ + fn map(&mut self) -> Result<Box<dyn Map + '_>> {{ + Ok(Box::new(Builder {{ + out: &mut self.out, + builder: Default::default(), + }})) + }} + }} + + impl<'a> Map for Builder<'a> {{ + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {{ + self.builder.key(k) + }} + + fn finish(&mut self) -> Result<()> {{ + *self.out = self.builder.take_out(); + Ok(()) + }} + }} + + impl MapBuilder for {builder_name} {{ + type Out = {ident}; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {{ + self.inner.key_inner(k) + }} + + fn deser_default() -> Self {{ + Self::default() + }} + + fn take_out(&mut self) -> Option<Self::Out> {{ + {take_out_func_inner} + }} + }} + + impl stripe_types::ObjectDeser for {ident} {{ + type Builder = {builder_name}; + }} + "# + }; + if let EnumOfObjects::ObjectUnion(objects) = objects { + let mut cons_inner = String::new(); + for (obj_discr, obj) in objects { + let name = &obj.ident; + let _ = writeln!( + cons_inner, + r#""{obj_discr}" => Self::{name}(FromValueOpt::from_value(Value::Object(o))?),"# + ); + } + let _ = writedoc!( + out, + r#" + impl {ident} {{ + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> {{ + Some(match key {{ + {cons_inner} + _ => return None, + }}) + }} + }} + + impl FromValueOpt for {ident} {{ + fn from_value(v: Value) -> Option<Self> {{ + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + }} + }} + "# + ); + } + out +} + +impl<'a> ObjectWriter<'a> { + pub fn gen_miniserde_struct_deserialize(&self, out: &mut String, fields: &[StructField]) { + let ident = self.ident; + let builder_name = RustIdent::joined(ident, "Builder"); + let mut builder_inner = String::new(); + for field in fields { + let f_name = &field.field_name; + let printable = self.components.construct_printable_type(&field.rust_type); + let _ = writeln!(builder_inner, "{f_name}: Option<{printable}>,"); + } + + let inner = miniserde_struct_inner(ident, &builder_name, fields); + let _ = writedoc! { + out, + r#" + #[cfg(feature = "min-ser")] + pub struct {builder_name} {{ + {builder_inner} + }} + + #[cfg(feature = "min-ser")] + #[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] + const _: () = {{ + use miniserde::de::{{Map, Visitor}}; + use miniserde::json::Value; + use miniserde::{{make_place, Deserialize, Result}}; + use stripe_types::{{MapBuilder, ObjectDeser}}; + use stripe_types::miniserde_helpers::FromValueOpt; + + make_place!(Place); + + {inner} + }}; + "# + }; + } +} + +fn miniserde_struct_inner( + ident: &RustIdent, + builder_name: &RustIdent, + fields: &[StructField], +) -> String { + let mut finish_inner = String::new(); + let mut key_inner = String::new(); + let mut builder_new_inner = String::new(); + let mut from_obj_inner = String::new(); + for field in fields { + let f_name = &field.field_name; + + let _ = writeln!( + key_inner, + r#""{}" => Deserialize::begin(&mut self.{f_name}),"#, + field.wire_name() + ); + let _ = writeln!( + from_obj_inner, + r#""{}" => b.{f_name} = Some(FromValueOpt::from_value(v)?),"#, + field.wire_name() + ); + let _ = writeln!(finish_inner, "let {f_name} = self.{f_name}.take()?;"); + + // NB: using miniserde::Deserialize::default() instead of `None` is very important - this copies + // the miniserde derives in defaulting `Option<Option<T>>` to `Ok(Some)` so that missing + // values are allowed for option types + let _ = writeln!(builder_new_inner, "{f_name}: Deserialize::default(),"); + } + let finish_init = fields.iter().map(|f| f.field_name.as_str()).collect::<Vec<_>>().join(","); + + formatdoc! {r#" + impl Deserialize for {ident} {{ + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {{ + Place::new(out) + }} + }} + + struct Builder<'a> {{ + out: &'a mut Option<{ident}>, + builder: {builder_name}, + }} + + impl Visitor for Place<{ident}> {{ + fn map(&mut self) -> Result<Box<dyn Map + '_>> {{ + Ok(Box::new(Builder {{ + out: &mut self.out, + builder: {builder_name}::deser_default(), + }})) + }} + }} + + impl MapBuilder for {builder_name} {{ + type Out = {ident}; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {{ + Ok(match k {{ + {key_inner} + _ => <dyn Visitor>::ignore(), + }}) + }} + + fn deser_default() -> Self {{ + Self {{ + {builder_new_inner} + }} + }} + + fn take_out(&mut self) -> Option<Self::Out> {{ + {finish_inner} + Some(Self::Out {{ {finish_init} }}) + }} + }} + + impl<'a> Map for Builder<'a> {{ + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {{ + self.builder.key(k) + }} + + fn finish(&mut self) -> Result<()> {{ + *self.out = self.builder.take_out(); + Ok(()) + }} + }} + + impl ObjectDeser for {ident} {{ + type Builder = {builder_name}; + }} + + impl FromValueOpt for {ident} {{ + fn from_value(v: Value) -> Option<Self> {{ + let Value::Object(obj) = v else {{ + return None; + }}; + let mut b = {builder_name}::deser_default(); + for (k, v) in obj {{ + match k.as_str() {{ + {from_obj_inner} + _ => {{}} + }} + }} + b.take_out() + }} + }} + "# + } +} diff --git a/openapi/src/templates/mod.rs b/openapi/src/templates/mod.rs index a382220c0..6d8842f0d 100644 --- a/openapi/src/templates/mod.rs +++ b/openapi/src/templates/mod.rs @@ -1,10 +1,11 @@ //! This module holds methods relating to the generation of rust code. pub mod cargo_toml; -pub mod derives; pub mod enums; +mod miniserde; pub mod object_trait; pub mod object_writer; pub mod requests; pub mod structs; pub mod utils; + pub use object_writer::ObjectWriter; diff --git a/openapi/src/templates/object_trait.rs b/openapi/src/templates/object_trait.rs index 9f6e7621e..5379fd84b 100644 --- a/openapi/src/templates/object_trait.rs +++ b/openapi/src/templates/object_trait.rs @@ -3,9 +3,9 @@ use std::fmt::Write; use indexmap::IndexMap; use indoc::writedoc; -use crate::components::Components; use crate::printable::PrintableType; -use crate::types::{ComponentPath, RustIdent}; +use crate::rust_object::ObjectRef; +use crate::types::RustIdent; use crate::STRIPE_TYPES; pub fn write_object_trait(out: &mut String, ident: &RustIdent, id_type: &PrintableType) { @@ -23,15 +23,13 @@ pub fn write_object_trait(out: &mut String, ident: &RustIdent, id_type: &Printab } pub fn write_object_trait_for_enum( - components: &Components, out: &mut String, ident: &RustIdent, - variants: &IndexMap<&str, ComponentPath>, + variants: &IndexMap<String, ObjectRef>, ) { let mut match_inner = String::with_capacity(32); - for path in variants.values() { - let comp = components.get(path); - let ident = comp.ident(); + for variant in variants.values() { + let ident = &variant.ident; let _ = writeln!(match_inner, "Self::{ident}(v) => v.id.inner(),"); } let _ = writedoc!( diff --git a/openapi/src/templates/object_writer.rs b/openapi/src/templates/object_writer.rs index ad69710ab..76197eba7 100644 --- a/openapi/src/templates/object_writer.rs +++ b/openapi/src/templates/object_writer.rs @@ -2,9 +2,8 @@ use std::fmt::Write; use crate::components::Components; use crate::printable::{Lifetime, PrintableType}; -use crate::rust_object::ObjectKind; +use crate::rust_object::{ObjectKind, ShouldImplSerialize}; use crate::rust_type::RustType; -use crate::templates::derives::Derives; use crate::types::RustIdent; #[derive(Copy, Clone)] @@ -86,11 +85,62 @@ pub fn write_derives_line(out: &mut String, derives: Derives) { if derives.eq { let _ = write!(out, "Eq, PartialEq,"); } - if derives.serialize { - let _ = write!(out, "serde::Serialize,"); + let _ = out.write_str(")]"); + match derives.serialize { + ShouldImplSerialize::Always => { + let _ = write!(out, "#[derive(serde::Serialize)]"); + } + ShouldImplSerialize::SkipIfMinSer => { + let _ = + write!(out, r#"#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))]"#); + } + ShouldImplSerialize::Never => {} } + if derives.deserialize { - let _ = write!(out, "serde::Deserialize,"); + let _ = write!(out, r#"#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))]"#); + } +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct Derives { + pub copy: bool, + pub debug: bool, + pub default: bool, + pub eq: bool, + pub serialize: ShouldImplSerialize, + pub deserialize: bool, +} + +impl Derives { + pub const fn new() -> Self { + Self { + debug: true, + copy: false, + default: false, + eq: false, + serialize: ShouldImplSerialize::Never, + deserialize: false, + } + } + + pub fn debug(mut self, debug: bool) -> Self { + self.debug = debug; + self + } + + pub fn copy(mut self, copy: bool) -> Self { + self.copy = copy; + self + } + + pub fn default(mut self, default: bool) -> Self { + self.default = default; + self + } + + pub fn eq(mut self, eq: bool) -> Self { + self.eq = eq; + self } - let _ = out.write_str(")]"); } diff --git a/openapi/src/templates/structs.rs b/openapi/src/templates/structs.rs index fc6553b74..f12a0b45a 100644 --- a/openapi/src/templates/structs.rs +++ b/openapi/src/templates/structs.rs @@ -4,7 +4,7 @@ use indoc::{formatdoc, writedoc}; use crate::printable::PrintableWithLifetime; use crate::rust_object::{StructField, Visibility}; -use crate::templates::utils::{write_doc_comment, write_serde_rename}; +use crate::templates::utils::{write_doc_comment, write_gated_serde_rename}; use crate::templates::ObjectWriter; impl<'a> ObjectWriter<'a> { @@ -72,6 +72,9 @@ impl<'a> ObjectWriter<'a> { " ); } + if self.obj_kind.should_impl_deserialize() { + self.gen_miniserde_struct_deserialize(out, fields) + } } fn write_struct_field(&self, out: &mut String, field: &StructField) { @@ -79,12 +82,16 @@ impl<'a> ObjectWriter<'a> { let _ = writeln!(out, "{}", write_doc_comment(doc_comment, 1).trim_end()); } if let Some(renamer) = &field.rename_as { - write_serde_rename(out, renamer); + write_gated_serde_rename(out, renamer); } - if !field.required { - if let Some(skip_ser) = field.rust_type.skip_serializing() { - let _ = writeln!(out, r#"#[serde(skip_serializing_if = "{skip_ser}")]"#); - } + + if !field.required && self.obj_kind.is_request_param() && field.rust_type.is_option() { + let _ = writeln!(out, r#"#[serde(skip_serializing_if = "Option::is_none")]"#); + } + // For the private `AlwaysTrue` field used as a serde discriminant. For `miniserde`, it + // is unused + if field.rust_type.implies_private_field() { + let _ = writeln!(out, "#[allow(dead_code)]"); } let printable = self.get_printable(&field.rust_type); diff --git a/openapi/src/templates/utils.rs b/openapi/src/templates/utils.rs index de1d2e706..35fc8d80d 100644 --- a/openapi/src/templates/utils.rs +++ b/openapi/src/templates/utils.rs @@ -1,4 +1,4 @@ -use std::fmt::Write; +use std::fmt::{Display, Write}; use lazy_static::lazy_static; use regex_lite::Regex; @@ -8,8 +8,12 @@ lazy_static! { static ref PERIOD_THEN_WHITESPACE: Regex = Regex::new(r"\.\s[\s]?").unwrap(); } -pub fn write_serde_rename(out: &mut String, rename: &str) { - let _ = writeln!(out, r#"#[serde(rename = "{rename}")]"#); +pub fn write_gated_serde_rename(out: &mut String, rename: &str) { + write_gated_serde_tag(out, format!(r#"rename = "{rename}""#)); +} + +pub fn write_gated_serde_tag(out: &mut String, tag: impl Display) { + let _ = writeln!(out, r#"#[cfg_attr(not(feature = "min-ser"), serde({tag}))]"#); } /// Write a formatted doc comment. diff --git a/openapi/src/types.rs b/openapi/src/types.rs index 754182f8d..2b691176e 100644 --- a/openapi/src/types.rs +++ b/openapi/src/types.rs @@ -64,6 +64,10 @@ impl ComponentPath { pub fn as_not_deleted(&self) -> Self { Self::new(self.0.trim_start_matches("deleted_").to_string()) } + + pub fn is_deleted_obj(&self) -> bool { + self.0.starts_with("deleted_") + } } // This is a bit silly...just done because `petgraph` prints graph labels using `Debug` so this diff --git a/openapi/src/url_finder.rs b/openapi/src/url_finder.rs index fd4ee695b..b790446e4 100644 --- a/openapi/src/url_finder.rs +++ b/openapi/src/url_finder.rs @@ -24,10 +24,8 @@ impl UrlFinder { } pub fn url_for_object(&self, object: &str) -> Option<String> { - let Some(unprefixed_link) = self.doc_links.get(object) else { - return None; - }; - Some(format!("https://stripe.com/docs/api{}", unprefixed_link)) + let unprefixed = self.doc_links.get(object)?; + Some(format!("https://stripe.com/docs/api{unprefixed}")) } } diff --git a/openapi/src/webhook.rs b/openapi/src/webhook.rs index de6db1fcb..d09bba7ca 100644 --- a/openapi/src/webhook.rs +++ b/openapi/src/webhook.rs @@ -11,8 +11,7 @@ use crate::printable::PrintableType; use crate::rust_object::{as_enum_of_objects, ObjectKind, RustObject}; use crate::rust_type::RustType; use crate::spec_inference::Inference; -use crate::templates::derives::Derives; -use crate::templates::object_writer::write_derives_line; +use crate::templates::object_writer::{write_derives_line, Derives}; use crate::templates::utils::write_doc_comment; use crate::templates::ObjectWriter; use crate::types::RustIdent; @@ -28,8 +27,9 @@ fn write_event_object(components: &Components, out_path: &Path) -> anyhow::Resul let mut out = String::new(); let mut enum_body = String::new(); let mut match_inner = String::new(); + let mut match_inner_min_ser = String::new(); for webhook_obj in &components.webhook_objs { - let ident = RustIdent::create(&webhook_obj.wire_name); + let ident = RustIdent::create(&webhook_obj.event_type); let (printable, feature_gate) = if let Some(enum_objs) = webhook_obj.typ.as_rust_object().and_then(|o| match o { @@ -68,14 +68,19 @@ fn write_event_object(components: &Components, out_path: &Path) -> anyhow::Resul if let Some(gate) = feature_gate { let _ = writeln!(match_inner, r#"#[cfg(feature = "{gate}")]"#); + let _ = writeln!(match_inner_min_ser, r#"#[cfg(feature = "{gate}")]"#); } - let wire_name = &webhook_obj.wire_name; + let evt_type = &webhook_obj.event_type; let _ = writeln!( match_inner, - r#""{wire_name}" => EventObject::{ident}(serde_json::from_value(data)?),"# + r#""{evt_type}" => Self::{ident}(serde_json::from_value(data)?),"# + ); + let _ = writeln!( + match_inner_min_ser, + r#""{evt_type}" => Self::{ident}(FromValueOpt::from_value(data)?),"# ); } - let _ = writeln!(enum_body, "Unknown(serde_json::Value),"); + let _ = writeln!(enum_body, "Unknown(stripe_types::Value),"); write_derives_line(&mut out, Derives::new()); let _ = writedoc! {out, r#" @@ -88,10 +93,20 @@ fn write_event_object(components: &Components, out_path: &Path) -> anyhow::Resul let _ = writedoc! {out, r#" impl EventObject {{ - pub(crate) fn from_raw_data(typ: &str, data: serde_json::Value) -> serde_json::Result<Self> {{ + #[cfg(not(feature = "min-ser"))] + pub(crate) fn from_raw_data(typ: &str, data: serde_json::Value) -> Result<Self, serde_json::Error> {{ Ok(match typ {{ {match_inner} - _ => EventObject::Unknown(data), + _ => Self::Unknown(data), + }}) + }} + + #[cfg(feature = "min-ser")] + pub(crate) fn from_raw_data(typ: &str, data: miniserde::json::Value) -> Option<Self> {{ + use stripe_types::miniserde_helpers::FromValueOpt; + Some(match typ {{ + {match_inner_min_ser} + _ => Self::Unknown(data), }}) }} }} @@ -103,7 +118,7 @@ fn write_event_object(components: &Components, out_path: &Path) -> anyhow::Resul #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct WebhookObject { - pub wire_name: String, + pub event_type: String, pub doc: String, pub typ: RustType, } @@ -122,7 +137,7 @@ impl WebhookObject { let typ = infer_ctx.required(true).infer_schema_type(schema); Ok(Some(Self { - wire_name: event_type.to_string(), + event_type: event_type.to_string(), doc: desc.to_string(), typ: extract_object_type(typ)?, })) diff --git a/stripe_types/Cargo.toml b/stripe_types/Cargo.toml index 067503983..6a83f5dbd 100644 --- a/stripe_types/Cargo.toml +++ b/stripe_types/Cargo.toml @@ -12,9 +12,15 @@ keywords.workspace = true categories.workspace = true [dependencies] -serde = {workspace = true } +serde = { workspace = true } smol_str.workspace = true serde_json.workspace = true +serde_path_to_error = "0.1.8" + +miniserde = { workspace = true, optional = true } + +[features] +min-ser = ["miniserde"] [dev-dependencies] serde_qs = "0.12.0" \ No newline at end of file diff --git a/stripe_types/src/currency.rs b/stripe_types/src/currency.rs index 6bf2ade64..3ceb351d2 100644 --- a/stripe_types/src/currency.rs +++ b/stripe_types/src/currency.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; /// /// For more details see <https://support.stripe.com/questions/which-currencies-does-stripe-support>. #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq, Hash, Default)] +#[cfg_attr(feature = "min-ser", derive(miniserde::Deserialize))] pub enum Currency { #[serde(rename = "byn")] BYN, // Belarusian Ruble diff --git a/stripe_types/src/deser.rs b/stripe_types/src/deser.rs new file mode 100644 index 000000000..e27687985 --- /dev/null +++ b/stripe_types/src/deser.rs @@ -0,0 +1,26 @@ +pub trait StripeDeserialize { + fn deserialize(str: &str) -> Result<Self, String> + where + Self: Sized; +} + +#[cfg(feature = "min-ser")] +impl<T: miniserde::Deserialize> StripeDeserialize for T { + fn deserialize(str: &str) -> Result<Self, String> { + miniserde::json::from_str(str).map_err(|err| err.to_string()) + } +} + +#[cfg(not(feature = "min-ser"))] +impl<T: serde::de::DeserializeOwned> StripeDeserialize for T { + fn deserialize(str: &str) -> Result<Self, String> { + let json_deserializer = &mut serde_json::Deserializer::from_str(str); + serde_path_to_error::deserialize(json_deserializer).map_err(|err| err.to_string()) + } +} + +#[cfg(feature = "min-ser")] +pub type Value = miniserde::json::Value; + +#[cfg(not(feature = "min-ser"))] +pub type Value = serde_json::Value; diff --git a/stripe_types/src/expandable.rs b/stripe_types/src/expandable.rs index 2d942c107..992af8710 100644 --- a/stripe_types/src/expandable.rs +++ b/stripe_types/src/expandable.rs @@ -54,3 +54,98 @@ impl<T: Object> Expandable<T> { } } } + +#[cfg(feature = "min-ser")] +mod miniserde { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize}; + + use crate::miniserde_helpers::FromValueOpt; + use crate::{Expandable, FromCursor, Object}; + make_place!(Place); + + pub trait MapBuilder { + type Out; + + /// Initial state for the builder. Note that this does _not_ match the `Default` trait, it + /// matches `miniserde::Deserialize::default` -> specifically we need `Option<Option<>>` to + /// default to `Some(None)` + fn deser_default() -> Self; + + fn key(&mut self, k: &str) -> miniserde::Result<&mut dyn Visitor>; + + fn take_out(&mut self) -> Option<Self::Out> + where + Self::Out: Sized; + } + + pub trait ObjectDeser + where + Self: Sized, + { + type Builder: MapBuilder<Out = Self>; + } + + impl<T> Deserialize for Expandable<T> + where + T: Object + Deserialize + ObjectDeser, + { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct ExpandableBuilder<'a, T: ObjectDeser + Object> { + out: &'a mut Option<Expandable<T>>, + builder: T::Builder, + } + + impl<'a, T> Map for ExpandableBuilder<'a, T> + where + T: ObjectDeser + Object, + { + fn key(&mut self, k: &str) -> miniserde::Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> miniserde::Result<()> { + let finalized = self.builder.take_out().ok_or(miniserde::Error)?; + *self.out = Some(Expandable::Object(Box::new(finalized))); + Ok(()) + } + } + + impl<T> Visitor for Place<Expandable<T>> + where + T: Object + ObjectDeser, + { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + let val = T::Id::from_cursor(s).ok_or(miniserde::Error)?; + self.out = Some(Expandable::Id(val)); + Ok(()) + } + + fn map(&mut self) -> miniserde::Result<Box<dyn Map + '_>> { + Ok(Box::new(ExpandableBuilder { + out: &mut self.out, + builder: T::Builder::deser_default(), + })) + } + } + + impl<T: FromValueOpt + Object> FromValueOpt for Expandable<T> { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::String(id) => Some(Self::Id(T::Id::from_cursor(&id)?)), + Value::Object(obj) => { + Some(Self::Object(Box::new(T::from_value(Value::Object(obj))?))) + } + _ => None, + } + } + } +} + +#[cfg(feature = "min-ser")] +pub use miniserde::{MapBuilder, ObjectDeser}; diff --git a/stripe_types/src/ids.rs b/stripe_types/src/ids.rs index 36e123179..cb0d75573 100644 --- a/stripe_types/src/ids.rs +++ b/stripe_types/src/ids.rs @@ -1,3 +1,4 @@ +#[allow(clippy::crate_in_macro_def)] #[doc(hidden)] #[macro_export] macro_rules! def_id_serde_impls { @@ -20,6 +21,30 @@ macro_rules! def_id_serde_impls { s.parse::<Self>().map_err(::serde::de::Error::custom) } } + + impl stripe_types::FromCursor for $struct_name { + fn from_cursor(val: &str) -> Option<Self> { + use std::str::FromStr; + Self::from_str(val).ok() + } + } + + #[cfg(feature = "min-ser")] + impl miniserde::Deserialize for $struct_name { + fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } + } + + #[cfg(feature = "min-ser")] + impl miniserde::de::Visitor for crate::Place<$struct_name> { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + self.out = Some(s.parse::<$struct_name>().map_err(|_| miniserde::Error)?); + Ok(()) + } + } + #[cfg(feature = "min-ser")] + $crate::impl_from_val_with_from_str!($struct_name); }; } diff --git a/stripe_types/src/lib.rs b/stripe_types/src/lib.rs index 08e1a4ec8..52b9bcdb0 100644 --- a/stripe_types/src/lib.rs +++ b/stripe_types/src/lib.rs @@ -1,16 +1,24 @@ //! This crate provides Rust bindings for core types to the Stripe HTTP API. mod currency; +mod deser; mod expandable; mod ids; mod pagination; mod params; pub use currency::{Currency, ParseCurrencyError}; +pub use deser::{StripeDeserialize, Value}; pub use expandable::*; pub use ids::*; pub use pagination::*; pub use params::*; +#[cfg(feature = "min-ser")] +miniserde::make_place!(Place); +#[cfg(feature = "min-ser")] +#[doc(hidden)] +pub mod miniserde_helpers; + // Allow generated code to use absolute paths starting with `stripe` instead of `crate` extern crate self as stripe_types; diff --git a/stripe_types/src/miniserde_helpers.rs b/stripe_types/src/miniserde_helpers.rs new file mode 100644 index 000000000..aa3e2b982 --- /dev/null +++ b/stripe_types/src/miniserde_helpers.rs @@ -0,0 +1,248 @@ +use std::collections::HashMap; +use std::mem; +use std::str::FromStr; + +use miniserde::de::Visitor; +use miniserde::json::{Number, Object, Value}; +use miniserde::Deserialize; + +use crate::Currency; + +#[derive(Default)] +pub struct ObjectBuilderInner { + obj_key: Option<String>, + object: Object, + key: Option<String>, + value: Option<Value>, +} + +impl ObjectBuilderInner { + pub fn shift(&mut self) { + if let (Some(k), Some(v)) = (self.key.take(), self.value.take()) { + self.object.insert(k, v); + } + } + + pub fn key_inner(&mut self, k: &str) -> miniserde::Result<&mut dyn Visitor> { + self.shift(); + if k == "object" { + return Ok(Deserialize::begin(&mut self.obj_key)); + } + self.key = Some(k.to_owned()); + Ok(Deserialize::begin(&mut self.value)) + } + + pub fn finish_inner(&mut self) -> Option<(String, Object)> { + self.shift(); + let obj_key = self.obj_key.take()?; + let final_object = mem::replace(&mut self.object, Object::new()); + Some((obj_key, final_object)) + } +} + +#[derive(Default)] +pub struct MaybeDeletedBuilderInner { + object: Object, + key: Option<String>, + value: Option<Value>, +} + +impl MaybeDeletedBuilderInner { + pub fn shift(&mut self) { + if let (Some(k), Some(v)) = (self.key.take(), self.value.take()) { + self.object.insert(k, v); + } + } + + pub fn key_inner(&mut self, k: &str) -> miniserde::Result<&mut dyn Visitor> { + self.shift(); + self.key = Some(k.to_owned()); + Ok(Deserialize::begin(&mut self.value)) + } + + pub fn finish_inner(&mut self) -> Option<(bool, Object)> { + self.shift(); + let deleted = self + .object + .get("deleted") + .map(|o| match o { + Value::Bool(bool) => *bool, + _ => false, + }) + .unwrap_or(false); + let final_object = mem::replace(&mut self.object, Object::new()); + Some((deleted, final_object)) + } +} + +pub trait FromValueOpt { + fn from_value(v: Value) -> Option<Self> + where + Self: Sized; +} + +impl FromValueOpt for bool { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Bool(b) => Some(b), + _ => None, + } + } +} + +impl FromValueOpt for i64 { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Number(num) => match num { + Number::U64(u) => Some(u as i64), + Number::I64(i) => Some(i), + Number::F64(_) => None, + }, + _ => None, + } + } +} + +impl FromValueOpt for u64 { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Number(num) => match num { + Number::U64(u) => Some(u), + Number::I64(i) => Some(i.try_into().ok()?), + Number::F64(_) => None, + }, + _ => None, + } + } +} + +impl FromValueOpt for f64 { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Number(num) => match num { + Number::U64(u) => Some(u as f64), + Number::I64(i) => Some(i as f64), + Number::F64(f) => Some(f), + }, + _ => None, + } + } +} +impl FromValueOpt for u32 { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Number(num) => match num { + Number::U64(u) => Some(u.try_into().ok()?), + Number::I64(i) => Some(i.try_into().ok()?), + Number::F64(_) => None, + }, + _ => None, + } + } +} +impl FromValueOpt for u8 { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Number(num) => match num { + Number::U64(u) => Some(u.try_into().ok()?), + Number::I64(i) => Some(i.try_into().ok()?), + Number::F64(_) => None, + }, + _ => None, + } + } +} + +impl FromValueOpt for String { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::String(str) => Some(str), + _ => None, + } + } +} + +impl<T: FromValueOpt> FromValueOpt for Option<T> { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Null => Some(None), + val => Some(T::from_value(val)), + } + } +} + +impl<T: FromValueOpt> FromValueOpt for Vec<T> { + fn from_value(v: Value) -> Option<Self> { + match v { + Value::Array(items) => items.into_iter().map(|i| T::from_value(i)).collect(), + _ => None, + } + } +} + +impl<V: FromValueOpt> FromValueOpt for HashMap<String, V> { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + obj.into_iter() + .map(|(k, v)| { + let v = V::from_value(v)?; + Some((k, v)) + }) + .collect::<Option<HashMap<_, _>>>() + } +} + +impl<V: FromValueOpt> FromValueOpt for HashMap<Currency, V> { + fn from_value(v: Value) -> Option<Self> { + let Value::Object(obj) = v else { + return None; + }; + obj.into_iter() + .map(|(k, v)| { + let k = Currency::from_str(&k).ok()?; + let v = V::from_value(v)?; + Some((k, v)) + }) + .collect::<Option<HashMap<_, _>>>() + } +} + +pub fn extract_object_discr(value: Value) -> Option<(String, Object)> { + let Value::Object(mut obj) = value else { return None }; + let obj_name = obj.remove("object")?; + let obj_str = match obj_name { + Value::String(str) => str, + _ => return None, + }; + Some((obj_str, obj)) +} + +impl FromValueOpt for Value { + fn from_value(v: Value) -> Option<Self> { + Some(v) + } +} + +impl<T: FromValueOpt> FromValueOpt for Box<T> { + fn from_value(v: Value) -> Option<Self> { + Some(Box::new(T::from_value(v)?)) + } +} + +#[macro_export] +macro_rules! impl_from_val_with_from_str { + ($struct_name:ident) => { + impl $crate::miniserde_helpers::FromValueOpt for $struct_name { + fn from_value(v: miniserde::json::Value) -> Option<Self> { + match v { + miniserde::json::Value::String(str) => std::str::FromStr::from_str(&str).ok(), + _ => None, + } + } + } + }; +} + +impl_from_val_with_from_str!(Currency); diff --git a/stripe_types/src/pagination.rs b/stripe_types/src/pagination.rs index 5b3f43338..2121eeaae 100644 --- a/stripe_types/src/pagination.rs +++ b/stripe_types/src/pagination.rs @@ -1,15 +1,27 @@ use std::fmt::Debug; +use std::str::FromStr; -use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use serde_json::Value; -/// Implemented by types which represent stripe objects. -pub trait Object { - /// The canonical id type for this object. - type Id: AsCursorOpt; - /// The id of the object. - fn id(&self) -> &Self::Id; +use crate::StripeDeserialize; + +pub trait FromCursor { + fn from_cursor(val: &str) -> Option<Self> + where + Self: Sized; +} + +impl FromCursor for smol_str::SmolStr { + fn from_cursor(val: &str) -> Option<Self> { + Self::from_str(val).ok() + } +} + +impl<T: FromCursor> FromCursor for Option<T> { + fn from_cursor(val: &str) -> Option<Self> { + Some(T::from_cursor(val)) + } } pub trait AsCursorOpt { @@ -38,6 +50,14 @@ impl<T: AsCursor> AsCursorOpt for Option<T> { } } +/// Implemented by types which represent stripe objects. +pub trait Object { + /// The canonical id type for this object. + type Id: AsCursorOpt + FromCursor; + /// The id of the object. + fn id(&self) -> &Self::Id; +} + /// A trait allowing `List<T>` and `SearchList<T>` to be treated the same. Not part of the /// public API. /// @@ -47,7 +67,7 @@ impl<T: AsCursor> AsCursorOpt for Option<T> { /// is not part of the shared list impl. We account for this by ensuring to call `update_params` /// before breaking the `SearchList` into pieces. #[doc(hidden)] -pub trait PaginableList: DeserializeOwned { +pub trait PaginableList: StripeDeserialize { /// Underlying single element type, e.g. `Account` type Data; @@ -77,7 +97,11 @@ pub struct ListParts<T> { pub has_more: bool, } -impl<T: Object + DeserializeOwned> PaginableList for List<T> { +impl<T> PaginableList for List<T> +where + T: Object, + List<T>: StripeDeserialize, +{ type Data = T; fn into_parts(self) -> ListParts<Self::Data> { @@ -153,7 +177,10 @@ impl<T: Clone> Clone for SearchList<T> { } } -impl<T: DeserializeOwned> PaginableList for SearchList<T> { +impl<T> PaginableList for SearchList<T> +where + SearchList<T>: StripeDeserialize, +{ type Data = T; /// NB: here we lose `next_page`, so we should be sure to `update_params` @@ -185,3 +212,134 @@ impl<T: DeserializeOwned> PaginableList for SearchList<T> { } } } + +#[cfg(feature = "min-ser")] +mod miniserde { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Error}; + + use crate::miniserde_helpers::FromValueOpt; + use crate::{List, SearchList}; + make_place!(Place); + + impl<T: Deserialize> Deserialize for List<T> { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl<T: Deserialize> Visitor for Place<List<T>> { + fn map(&mut self) -> miniserde::Result<Box<dyn Map + '_>> { + Ok(Box::new(ListBuilder { + out: &mut self.out, + data: Deserialize::default(), + has_more: Deserialize::default(), + total_count: Deserialize::default(), + url: Deserialize::default(), + })) + } + } + + struct ListBuilder<'a, T> { + out: &'a mut Option<List<T>>, + data: Option<Vec<T>>, + has_more: Option<bool>, + total_count: Option<Option<u64>>, + url: Option<String>, + } + + impl<'a, T: Deserialize> Map for ListBuilder<'a, T> { + fn key(&mut self, k: &str) -> miniserde::Result<&mut dyn Visitor> { + match k { + "url" => Ok(Deserialize::begin(&mut self.url)), + "data" => Ok(Deserialize::begin(&mut self.data)), + "has_more" => Ok(Deserialize::begin(&mut self.has_more)), + "total_count" => Ok(Deserialize::begin(&mut self.total_count)), + _ => Ok(<dyn Visitor>::ignore()), + } + } + + fn finish(&mut self) -> miniserde::Result<()> { + let url = self.url.take().ok_or(Error)?; + let data = self.data.take().ok_or(Error)?; + let has_more = self.has_more.take().ok_or(Error)?; + let total_count = self.total_count.take().ok_or(Error)?; + *self.out = Some(List { data, has_more, total_count, url }); + Ok(()) + } + } + + impl<T: FromValueOpt> FromValueOpt for List<T> { + fn from_value(v: Value) -> Option<Self> { + let mut data: Option<Vec<T>> = None; + let mut has_more: Option<bool> = None; + let mut total_count: Option<Option<u64>> = Some(None); + let mut url: Option<String> = None; + let Value::Object(obj) = v else { + return None; + }; + for (k, v) in obj { + match k.as_str() { + "has_more" => has_more = Some(bool::from_value(v)?), + "data" => data = Some(FromValueOpt::from_value(v)?), + "url" => url = Some(FromValueOpt::from_value(v)?), + "total_count" => total_count = Some(FromValueOpt::from_value(v)?), + _ => {} + } + } + Some(Self { data: data?, has_more: has_more?, total_count: total_count?, url: url? }) + } + } + + impl<T: Deserialize> Deserialize for SearchList<T> { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct SearchListBuilder<'a, T> { + out: &'a mut Option<SearchList<T>>, + data: Option<Vec<T>>, + has_more: Option<bool>, + total_count: Option<Option<u64>>, + url: Option<String>, + next_page: Option<Option<String>>, + } + + impl<T: Deserialize> Visitor for Place<SearchList<T>> { + fn map(&mut self) -> miniserde::Result<Box<dyn Map + '_>> { + Ok(Box::new(SearchListBuilder { + out: &mut self.out, + data: Deserialize::default(), + has_more: Deserialize::default(), + total_count: Deserialize::default(), + url: Deserialize::default(), + next_page: Deserialize::default(), + })) + } + } + + impl<'a, T: Deserialize> Map for SearchListBuilder<'a, T> { + fn key(&mut self, k: &str) -> miniserde::Result<&mut dyn Visitor> { + match k { + "url" => Ok(Deserialize::begin(&mut self.url)), + "data" => Ok(Deserialize::begin(&mut self.data)), + "has_more" => Ok(Deserialize::begin(&mut self.has_more)), + "total_count" => Ok(Deserialize::begin(&mut self.total_count)), + "next_page" => Ok(Deserialize::begin(&mut self.next_page)), + _ => Ok(<dyn Visitor>::ignore()), + } + } + + fn finish(&mut self) -> miniserde::Result<()> { + let url = self.url.take().ok_or(Error)?; + let data = self.data.take().ok_or(Error)?; + let has_more = self.has_more.take().ok_or(Error)?; + let total_count = self.total_count.take().ok_or(Error)?; + let next_page = self.next_page.take().ok_or(Error)?; + *self.out = Some(SearchList { data, has_more, total_count, url, next_page }); + Ok(()) + } + } +} diff --git a/stripe_types/src/params.rs b/stripe_types/src/params.rs index 837daa096..f97b0547a 100644 --- a/stripe_types/src/params.rs +++ b/stripe_types/src/params.rs @@ -28,6 +28,44 @@ impl<'de> serde::Deserialize<'de> for AlwaysTrue { } } +#[cfg(feature = "min-ser")] +mod miniserde_deser { + use miniserde::de::Visitor; + use miniserde::json::Value; + use miniserde::Deserialize; + + use crate::miniserde_helpers::FromValueOpt; + use crate::{AlwaysTrue, Place}; + + impl Deserialize for AlwaysTrue { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<AlwaysTrue> { + fn boolean(&mut self, b: bool) -> miniserde::Result<()> { + if b { + self.out = Some(AlwaysTrue); + Ok(()) + } else { + Err(miniserde::Error) + } + } + } + + impl FromValueOpt for AlwaysTrue { + fn from_value(v: Value) -> Option<Self> { + let b = bool::from_value(v)?; + if b { + Some(AlwaysTrue) + } else { + None + } + } + } +} + pub type Metadata = HashMap<String, String>; pub type Timestamp = i64; diff --git a/stripe_webhook/Cargo.toml b/stripe_webhook/Cargo.toml index f37595c9b..637dcbccd 100644 --- a/stripe_webhook/Cargo.toml +++ b/stripe_webhook/Cargo.toml @@ -12,19 +12,23 @@ keywords.workspace = true categories.workspace = true [dependencies] -stripe_types = {path = "../stripe_types"} -stripe_shared = {path = "../generated/stripe_shared"} +stripe_types = { path = "../stripe_types" } +stripe_shared = { path = "../generated/stripe_shared" } hmac = "0.12" sha2 = "0.10" hex = "0.4" chrono = { version = "0.4", default-features = false, features = ["clock"] } thiserror = "1.0.24" +miniserde = { workspace = true, optional = true } serde_json.workspace = true serde.workspace = true -stripe_core = {path = "../generated/stripe_core", optional = true} -stripe_checkout = {path = "../generated/stripe_checkout", optional = true} -stripe_billing = {path = "../generated/stripe_billing", optional = true} +stripe_core = { path = "../generated/stripe_core", optional = true } +stripe_checkout = { path = "../generated/stripe_checkout", optional = true } +stripe_billing = { path = "../generated/stripe_billing", optional = true } + +[features] +min-ser = ["miniserde", "stripe_core/min-ser", "stripe_checkout/min-ser", "stripe_billing/min-ser", "stripe_types/min-ser", "stripe_shared/min-ser"] [package.metadata.docs.rs] features = ["stripe_core", "stripe_checkout", "stripe_billing"] \ No newline at end of file diff --git a/stripe_webhook/src/error.rs b/stripe_webhook/src/error.rs index 00649a7f2..19a05ce60 100644 --- a/stripe_webhook/src/error.rs +++ b/stripe_webhook/src/error.rs @@ -11,6 +11,6 @@ pub enum WebhookError { BadSignature, #[error("error comparing timestamps - over tolerance")] BadTimestamp(i64), - #[error("error parsing event object")] - BadParse(#[from] serde_json::Error), + #[error("error parsing event object: {0}")] + BadParse(String), } diff --git a/stripe_webhook/src/generated/mod.rs b/stripe_webhook/src/generated/mod.rs index 65ffb1753..1ff6ba354 100644 --- a/stripe_webhook/src/generated/mod.rs +++ b/stripe_webhook/src/generated/mod.rs @@ -1,71 +1,686 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum AccountExternalAccountCreated { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct AccountExternalAccountCreatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<AccountExternalAccountCreated>, + builder: AccountExternalAccountCreatedBuilder, + } + + impl Deserialize for AccountExternalAccountCreated { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<AccountExternalAccountCreated> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for AccountExternalAccountCreatedBuilder { + type Out = AccountExternalAccountCreated; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + AccountExternalAccountCreated::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for AccountExternalAccountCreated { + type Builder = AccountExternalAccountCreatedBuilder; + } + impl AccountExternalAccountCreated { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for AccountExternalAccountCreated { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum AccountExternalAccountDeleted { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct AccountExternalAccountDeletedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<AccountExternalAccountDeleted>, + builder: AccountExternalAccountDeletedBuilder, + } + + impl Deserialize for AccountExternalAccountDeleted { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<AccountExternalAccountDeleted> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for AccountExternalAccountDeletedBuilder { + type Out = AccountExternalAccountDeleted; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + AccountExternalAccountDeleted::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for AccountExternalAccountDeleted { + type Builder = AccountExternalAccountDeletedBuilder; + } + impl AccountExternalAccountDeleted { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for AccountExternalAccountDeleted { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum AccountExternalAccountUpdated { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct AccountExternalAccountUpdatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<AccountExternalAccountUpdated>, + builder: AccountExternalAccountUpdatedBuilder, + } + + impl Deserialize for AccountExternalAccountUpdated { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<AccountExternalAccountUpdated> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for AccountExternalAccountUpdatedBuilder { + type Out = AccountExternalAccountUpdated; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + AccountExternalAccountUpdated::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for AccountExternalAccountUpdated { + type Builder = AccountExternalAccountUpdatedBuilder; + } + impl AccountExternalAccountUpdated { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for AccountExternalAccountUpdated { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum CustomerSourceCreated { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct CustomerSourceCreatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<CustomerSourceCreated>, + builder: CustomerSourceCreatedBuilder, + } + + impl Deserialize for CustomerSourceCreated { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<CustomerSourceCreated> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for CustomerSourceCreatedBuilder { + type Out = CustomerSourceCreated; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + CustomerSourceCreated::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for CustomerSourceCreated { + type Builder = CustomerSourceCreatedBuilder; + } + impl CustomerSourceCreated { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for CustomerSourceCreated { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum CustomerSourceDeleted { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct CustomerSourceDeletedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<CustomerSourceDeleted>, + builder: CustomerSourceDeletedBuilder, + } + + impl Deserialize for CustomerSourceDeleted { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<CustomerSourceDeleted> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for CustomerSourceDeletedBuilder { + type Out = CustomerSourceDeleted; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + CustomerSourceDeleted::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for CustomerSourceDeleted { + type Builder = CustomerSourceDeletedBuilder; + } + impl CustomerSourceDeleted { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for CustomerSourceDeleted { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum CustomerSourceExpiring { - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct CustomerSourceExpiringBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<CustomerSourceExpiring>, + builder: CustomerSourceExpiringBuilder, + } + + impl Deserialize for CustomerSourceExpiring { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<CustomerSourceExpiring> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for CustomerSourceExpiringBuilder { + type Out = CustomerSourceExpiring; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + CustomerSourceExpiring::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for CustomerSourceExpiring { + type Builder = CustomerSourceExpiringBuilder; + } + impl CustomerSourceExpiring { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for CustomerSourceExpiring { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Serialize))] +#[cfg_attr(not(feature = "min-ser"), derive(serde::Deserialize))] +#[cfg_attr(not(feature = "min-ser"), serde(tag = "object"))] pub enum CustomerSourceUpdated { - #[serde(rename = "bank_account")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(not(feature = "min-ser"), serde(rename = "source"))] Source(stripe_shared::Source), } + +#[cfg(feature = "min-ser")] +#[derive(Default)] +pub struct CustomerSourceUpdatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +#[cfg(feature = "min-ser")] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::MapBuilder; + + use super::*; + + make_place!(Place); + + struct Builder<'a> { + out: &'a mut Option<CustomerSourceUpdated>, + builder: CustomerSourceUpdatedBuilder, + } + + impl Deserialize for CustomerSourceUpdated { + fn begin(out: &mut Option<Self>) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place<CustomerSourceUpdated> { + fn map(&mut self) -> Result<Box<dyn Map + '_>> { + Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() })) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl MapBuilder for CustomerSourceUpdatedBuilder { + type Out = CustomerSourceUpdated; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.inner.key_inner(k) + } + + fn deser_default() -> Self { + Self::default() + } + + fn take_out(&mut self) -> Option<Self::Out> { + let (k, o) = self.inner.finish_inner()?; + CustomerSourceUpdated::construct(&k, o) + } + } + + impl stripe_types::ObjectDeser for CustomerSourceUpdated { + type Builder = CustomerSourceUpdatedBuilder; + } + impl CustomerSourceUpdated { + fn construct(key: &str, o: miniserde::json::Object) -> Option<Self> { + Some(match key { + "bank_account" => Self::BankAccount(FromValueOpt::from_value(Value::Object(o))?), + "card" => Self::Card(FromValueOpt::from_value(Value::Object(o))?), + "source" => Self::Source(FromValueOpt::from_value(Value::Object(o))?), + + _ => return None, + }) + } + } + + impl FromValueOpt for CustomerSourceUpdated { + fn from_value(v: Value) -> Option<Self> { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + #[derive(Clone, Debug)] #[non_exhaustive] /// The event data for a webhook event. @@ -147,27 +762,6 @@ pub enum EventObject { /// Occurs when a Checkout Session is expired. #[cfg(feature = "stripe_checkout")] CheckoutSessionExpired(stripe_checkout::CheckoutSession), - /// Occurs when a Climate order is canceled. - #[cfg(feature = "stripe_misc")] - ClimateOrderCanceled(stripe_misc::ClimateOrder), - /// Occurs when a Climate order is created. - #[cfg(feature = "stripe_misc")] - ClimateOrderCreated(stripe_misc::ClimateOrder), - /// Occurs when a Climate order is delayed. - #[cfg(feature = "stripe_misc")] - ClimateOrderDelayed(stripe_misc::ClimateOrder), - /// Occurs when a Climate order is delivered. - #[cfg(feature = "stripe_misc")] - ClimateOrderDelivered(stripe_misc::ClimateOrder), - /// Occurs when a Climate order's product is substituted for another. - #[cfg(feature = "stripe_misc")] - ClimateOrderProductSubstituted(stripe_misc::ClimateOrder), - /// Occurs when a Climate product is created. - #[cfg(feature = "stripe_misc")] - ClimateProductCreated(stripe_misc::ClimateProduct), - /// Occurs when a Climate product is updated. - #[cfg(feature = "stripe_misc")] - ClimateProductPricingUpdated(stripe_misc::ClimateProduct), /// Occurs whenever a coupon is created. CouponCreated(stripe_shared::Coupon), /// Occurs whenever a coupon is deleted. @@ -243,9 +837,6 @@ pub enum EventObject { /// Occurs when an Account’s `balance_refresh` status transitions from `pending` to either `succeeded` or `failed`. #[cfg(feature = "stripe_misc")] FinancialConnectionsAccountRefreshedBalance(stripe_misc::FinancialConnectionsAccount), - /// Occurs when an Account’s `transaction_refresh` status transitions from `pending` to either `succeeded` or `failed`. - #[cfg(feature = "stripe_misc")] - FinancialConnectionsAccountRefreshedTransactions(stripe_misc::FinancialConnectionsAccount), /// Occurs whenever a VerificationSession is canceled #[cfg(feature = "stripe_misc")] IdentityVerificationSessionCanceled(stripe_misc::IdentityVerificationSession), @@ -601,627 +1192,1070 @@ pub enum EventObject { /// Occurs whenever a received_debit is created as a result of funds being pulled by another account. #[cfg(feature = "stripe_treasury")] TreasuryReceivedDebitCreated(stripe_treasury::TreasuryReceivedDebit), - Unknown(serde_json::Value), + Unknown(stripe_types::Value), } impl EventObject { - pub(crate) fn from_raw_data(typ: &str, data: serde_json::Value) -> serde_json::Result<Self> { + #[cfg(not(feature = "min-ser"))] + pub(crate) fn from_raw_data( + typ: &str, + data: serde_json::Value, + ) -> Result<Self, serde_json::Error> { Ok(match typ { "account.application.authorized" => { - EventObject::AccountApplicationAuthorized(serde_json::from_value(data)?) + Self::AccountApplicationAuthorized(serde_json::from_value(data)?) } "account.application.deauthorized" => { - EventObject::AccountApplicationDeauthorized(serde_json::from_value(data)?) + Self::AccountApplicationDeauthorized(serde_json::from_value(data)?) } "account.external_account.created" => { - EventObject::AccountExternalAccountCreated(serde_json::from_value(data)?) + Self::AccountExternalAccountCreated(serde_json::from_value(data)?) } "account.external_account.deleted" => { - EventObject::AccountExternalAccountDeleted(serde_json::from_value(data)?) + Self::AccountExternalAccountDeleted(serde_json::from_value(data)?) } "account.external_account.updated" => { - EventObject::AccountExternalAccountUpdated(serde_json::from_value(data)?) - } - "account.updated" => EventObject::AccountUpdated(serde_json::from_value(data)?), - "application_fee.created" => { - EventObject::ApplicationFeeCreated(serde_json::from_value(data)?) + Self::AccountExternalAccountUpdated(serde_json::from_value(data)?) } + "account.updated" => Self::AccountUpdated(serde_json::from_value(data)?), + "application_fee.created" => Self::ApplicationFeeCreated(serde_json::from_value(data)?), "application_fee.refund.updated" => { - EventObject::ApplicationFeeRefundUpdated(serde_json::from_value(data)?) + Self::ApplicationFeeRefundUpdated(serde_json::from_value(data)?) } "application_fee.refunded" => { - EventObject::ApplicationFeeRefunded(serde_json::from_value(data)?) + Self::ApplicationFeeRefunded(serde_json::from_value(data)?) } #[cfg(feature = "stripe_core")] - "balance.available" => EventObject::BalanceAvailable(serde_json::from_value(data)?), + "balance.available" => Self::BalanceAvailable(serde_json::from_value(data)?), #[cfg(feature = "stripe_billing")] "billing_portal.configuration.created" => { - EventObject::BillingPortalConfigurationCreated(serde_json::from_value(data)?) + Self::BillingPortalConfigurationCreated(serde_json::from_value(data)?) } #[cfg(feature = "stripe_billing")] "billing_portal.configuration.updated" => { - EventObject::BillingPortalConfigurationUpdated(serde_json::from_value(data)?) + Self::BillingPortalConfigurationUpdated(serde_json::from_value(data)?) } #[cfg(feature = "stripe_billing")] "billing_portal.session.created" => { - EventObject::BillingPortalSessionCreated(serde_json::from_value(data)?) + Self::BillingPortalSessionCreated(serde_json::from_value(data)?) } - "capability.updated" => EventObject::CapabilityUpdated(serde_json::from_value(data)?), + "capability.updated" => Self::CapabilityUpdated(serde_json::from_value(data)?), "cash_balance.funds_available" => { - EventObject::CashBalanceFundsAvailable(serde_json::from_value(data)?) - } - "charge.captured" => EventObject::ChargeCaptured(serde_json::from_value(data)?), - "charge.dispute.closed" => { - EventObject::ChargeDisputeClosed(serde_json::from_value(data)?) - } - "charge.dispute.created" => { - EventObject::ChargeDisputeCreated(serde_json::from_value(data)?) + Self::CashBalanceFundsAvailable(serde_json::from_value(data)?) } + "charge.captured" => Self::ChargeCaptured(serde_json::from_value(data)?), + "charge.dispute.closed" => Self::ChargeDisputeClosed(serde_json::from_value(data)?), + "charge.dispute.created" => Self::ChargeDisputeCreated(serde_json::from_value(data)?), "charge.dispute.funds_reinstated" => { - EventObject::ChargeDisputeFundsReinstated(serde_json::from_value(data)?) + Self::ChargeDisputeFundsReinstated(serde_json::from_value(data)?) } "charge.dispute.funds_withdrawn" => { - EventObject::ChargeDisputeFundsWithdrawn(serde_json::from_value(data)?) - } - "charge.dispute.updated" => { - EventObject::ChargeDisputeUpdated(serde_json::from_value(data)?) - } - "charge.expired" => EventObject::ChargeExpired(serde_json::from_value(data)?), - "charge.failed" => EventObject::ChargeFailed(serde_json::from_value(data)?), - "charge.pending" => EventObject::ChargePending(serde_json::from_value(data)?), - "charge.refund.updated" => { - EventObject::ChargeRefundUpdated(serde_json::from_value(data)?) - } - "charge.refunded" => EventObject::ChargeRefunded(serde_json::from_value(data)?), - "charge.succeeded" => EventObject::ChargeSucceeded(serde_json::from_value(data)?), - "charge.updated" => EventObject::ChargeUpdated(serde_json::from_value(data)?), + Self::ChargeDisputeFundsWithdrawn(serde_json::from_value(data)?) + } + "charge.dispute.updated" => Self::ChargeDisputeUpdated(serde_json::from_value(data)?), + "charge.expired" => Self::ChargeExpired(serde_json::from_value(data)?), + "charge.failed" => Self::ChargeFailed(serde_json::from_value(data)?), + "charge.pending" => Self::ChargePending(serde_json::from_value(data)?), + "charge.refund.updated" => Self::ChargeRefundUpdated(serde_json::from_value(data)?), + "charge.refunded" => Self::ChargeRefunded(serde_json::from_value(data)?), + "charge.succeeded" => Self::ChargeSucceeded(serde_json::from_value(data)?), + "charge.updated" => Self::ChargeUpdated(serde_json::from_value(data)?), #[cfg(feature = "stripe_checkout")] "checkout.session.async_payment_failed" => { - EventObject::CheckoutSessionAsyncPaymentFailed(serde_json::from_value(data)?) + Self::CheckoutSessionAsyncPaymentFailed(serde_json::from_value(data)?) } #[cfg(feature = "stripe_checkout")] "checkout.session.async_payment_succeeded" => { - EventObject::CheckoutSessionAsyncPaymentSucceeded(serde_json::from_value(data)?) + Self::CheckoutSessionAsyncPaymentSucceeded(serde_json::from_value(data)?) } #[cfg(feature = "stripe_checkout")] "checkout.session.completed" => { - EventObject::CheckoutSessionCompleted(serde_json::from_value(data)?) + Self::CheckoutSessionCompleted(serde_json::from_value(data)?) } #[cfg(feature = "stripe_checkout")] "checkout.session.expired" => { - EventObject::CheckoutSessionExpired(serde_json::from_value(data)?) + Self::CheckoutSessionExpired(serde_json::from_value(data)?) + } + "coupon.created" => Self::CouponCreated(serde_json::from_value(data)?), + "coupon.deleted" => Self::CouponDeleted(serde_json::from_value(data)?), + "coupon.updated" => Self::CouponUpdated(serde_json::from_value(data)?), + "credit_note.created" => Self::CreditNoteCreated(serde_json::from_value(data)?), + "credit_note.updated" => Self::CreditNoteUpdated(serde_json::from_value(data)?), + "credit_note.voided" => Self::CreditNoteVoided(serde_json::from_value(data)?), + "customer.created" => Self::CustomerCreated(serde_json::from_value(data)?), + "customer.deleted" => Self::CustomerDeleted(serde_json::from_value(data)?), + "customer.discount.created" => { + Self::CustomerDiscountCreated(serde_json::from_value(data)?) + } + "customer.discount.deleted" => { + Self::CustomerDiscountDeleted(serde_json::from_value(data)?) + } + "customer.discount.updated" => { + Self::CustomerDiscountUpdated(serde_json::from_value(data)?) + } + "customer.source.created" => Self::CustomerSourceCreated(serde_json::from_value(data)?), + "customer.source.deleted" => Self::CustomerSourceDeleted(serde_json::from_value(data)?), + "customer.source.expiring" => { + Self::CustomerSourceExpiring(serde_json::from_value(data)?) + } + "customer.source.updated" => Self::CustomerSourceUpdated(serde_json::from_value(data)?), + "customer.subscription.created" => { + Self::CustomerSubscriptionCreated(serde_json::from_value(data)?) + } + "customer.subscription.deleted" => { + Self::CustomerSubscriptionDeleted(serde_json::from_value(data)?) + } + "customer.subscription.paused" => { + Self::CustomerSubscriptionPaused(serde_json::from_value(data)?) + } + "customer.subscription.pending_update_applied" => { + Self::CustomerSubscriptionPendingUpdateApplied(serde_json::from_value(data)?) + } + "customer.subscription.pending_update_expired" => { + Self::CustomerSubscriptionPendingUpdateExpired(serde_json::from_value(data)?) + } + "customer.subscription.resumed" => { + Self::CustomerSubscriptionResumed(serde_json::from_value(data)?) + } + "customer.subscription.trial_will_end" => { + Self::CustomerSubscriptionTrialWillEnd(serde_json::from_value(data)?) + } + "customer.subscription.updated" => { + Self::CustomerSubscriptionUpdated(serde_json::from_value(data)?) + } + "customer.tax_id.created" => Self::CustomerTaxIdCreated(serde_json::from_value(data)?), + "customer.tax_id.deleted" => Self::CustomerTaxIdDeleted(serde_json::from_value(data)?), + "customer.tax_id.updated" => Self::CustomerTaxIdUpdated(serde_json::from_value(data)?), + "customer.updated" => Self::CustomerUpdated(serde_json::from_value(data)?), + "customer_cash_balance_transaction.created" => { + Self::CustomerCashBalanceTransactionCreated(serde_json::from_value(data)?) + } + "file.created" => Self::FileCreated(serde_json::from_value(data)?), + #[cfg(feature = "stripe_misc")] + "financial_connections.account.created" => { + Self::FinancialConnectionsAccountCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "financial_connections.account.deactivated" => { + Self::FinancialConnectionsAccountDeactivated(serde_json::from_value(data)?) } #[cfg(feature = "stripe_misc")] - "climate.order.canceled" => { - EventObject::ClimateOrderCanceled(serde_json::from_value(data)?) + "financial_connections.account.disconnected" => { + Self::FinancialConnectionsAccountDisconnected(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "financial_connections.account.reactivated" => { + Self::FinancialConnectionsAccountReactivated(serde_json::from_value(data)?) } #[cfg(feature = "stripe_misc")] - "climate.order.created" => { - EventObject::ClimateOrderCreated(serde_json::from_value(data)?) + "financial_connections.account.refreshed_balance" => { + Self::FinancialConnectionsAccountRefreshedBalance(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "identity.verification_session.canceled" => { + Self::IdentityVerificationSessionCanceled(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "identity.verification_session.created" => { + Self::IdentityVerificationSessionCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "identity.verification_session.processing" => { + Self::IdentityVerificationSessionProcessing(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "identity.verification_session.redacted" => { + Self::IdentityVerificationSessionRedacted(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "identity.verification_session.requires_input" => { + Self::IdentityVerificationSessionRequiresInput(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_misc")] + "identity.verification_session.verified" => { + Self::IdentityVerificationSessionVerified(serde_json::from_value(data)?) } + "invoice.created" => Self::InvoiceCreated(serde_json::from_value(data)?), + "invoice.deleted" => Self::InvoiceDeleted(serde_json::from_value(data)?), + "invoice.finalization_failed" => { + Self::InvoiceFinalizationFailed(serde_json::from_value(data)?) + } + "invoice.finalized" => Self::InvoiceFinalized(serde_json::from_value(data)?), + "invoice.marked_uncollectible" => { + Self::InvoiceMarkedUncollectible(serde_json::from_value(data)?) + } + "invoice.paid" => Self::InvoicePaid(serde_json::from_value(data)?), + "invoice.payment_action_required" => { + Self::InvoicePaymentActionRequired(serde_json::from_value(data)?) + } + "invoice.payment_failed" => Self::InvoicePaymentFailed(serde_json::from_value(data)?), + "invoice.payment_succeeded" => { + Self::InvoicePaymentSucceeded(serde_json::from_value(data)?) + } + "invoice.sent" => Self::InvoiceSent(serde_json::from_value(data)?), + "invoice.upcoming" => Self::InvoiceUpcoming(serde_json::from_value(data)?), + "invoice.updated" => Self::InvoiceUpdated(serde_json::from_value(data)?), + "invoice.voided" => Self::InvoiceVoided(serde_json::from_value(data)?), + "invoiceitem.created" => Self::InvoiceitemCreated(serde_json::from_value(data)?), + "invoiceitem.deleted" => Self::InvoiceitemDeleted(serde_json::from_value(data)?), + "issuing_authorization.created" => { + Self::IssuingAuthorizationCreated(serde_json::from_value(data)?) + } + "issuing_authorization.request" => { + Self::IssuingAuthorizationRequest(serde_json::from_value(data)?) + } + "issuing_authorization.updated" => { + Self::IssuingAuthorizationUpdated(serde_json::from_value(data)?) + } + "issuing_card.created" => Self::IssuingCardCreated(serde_json::from_value(data)?), + "issuing_card.updated" => Self::IssuingCardUpdated(serde_json::from_value(data)?), + "issuing_cardholder.created" => { + Self::IssuingCardholderCreated(serde_json::from_value(data)?) + } + "issuing_cardholder.updated" => { + Self::IssuingCardholderUpdated(serde_json::from_value(data)?) + } + "issuing_dispute.closed" => Self::IssuingDisputeClosed(serde_json::from_value(data)?), + "issuing_dispute.created" => Self::IssuingDisputeCreated(serde_json::from_value(data)?), + "issuing_dispute.funds_reinstated" => { + Self::IssuingDisputeFundsReinstated(serde_json::from_value(data)?) + } + "issuing_dispute.submitted" => { + Self::IssuingDisputeSubmitted(serde_json::from_value(data)?) + } + "issuing_dispute.updated" => Self::IssuingDisputeUpdated(serde_json::from_value(data)?), + "issuing_token.created" => Self::IssuingTokenCreated(serde_json::from_value(data)?), + "issuing_token.updated" => Self::IssuingTokenUpdated(serde_json::from_value(data)?), + "issuing_transaction.created" => { + Self::IssuingTransactionCreated(serde_json::from_value(data)?) + } + "issuing_transaction.updated" => { + Self::IssuingTransactionUpdated(serde_json::from_value(data)?) + } + "mandate.updated" => Self::MandateUpdated(serde_json::from_value(data)?), + "payment_intent.amount_capturable_updated" => { + Self::PaymentIntentAmountCapturableUpdated(serde_json::from_value(data)?) + } + "payment_intent.canceled" => Self::PaymentIntentCanceled(serde_json::from_value(data)?), + "payment_intent.created" => Self::PaymentIntentCreated(serde_json::from_value(data)?), + "payment_intent.partially_funded" => { + Self::PaymentIntentPartiallyFunded(serde_json::from_value(data)?) + } + "payment_intent.payment_failed" => { + Self::PaymentIntentPaymentFailed(serde_json::from_value(data)?) + } + "payment_intent.processing" => { + Self::PaymentIntentProcessing(serde_json::from_value(data)?) + } + "payment_intent.requires_action" => { + Self::PaymentIntentRequiresAction(serde_json::from_value(data)?) + } + "payment_intent.succeeded" => { + Self::PaymentIntentSucceeded(serde_json::from_value(data)?) + } + "payment_link.created" => Self::PaymentLinkCreated(serde_json::from_value(data)?), + "payment_link.updated" => Self::PaymentLinkUpdated(serde_json::from_value(data)?), + "payment_method.attached" => Self::PaymentMethodAttached(serde_json::from_value(data)?), + "payment_method.automatically_updated" => { + Self::PaymentMethodAutomaticallyUpdated(serde_json::from_value(data)?) + } + "payment_method.detached" => Self::PaymentMethodDetached(serde_json::from_value(data)?), + "payment_method.updated" => Self::PaymentMethodUpdated(serde_json::from_value(data)?), + "payout.canceled" => Self::PayoutCanceled(serde_json::from_value(data)?), + "payout.created" => Self::PayoutCreated(serde_json::from_value(data)?), + "payout.failed" => Self::PayoutFailed(serde_json::from_value(data)?), + "payout.paid" => Self::PayoutPaid(serde_json::from_value(data)?), + "payout.reconciliation_completed" => { + Self::PayoutReconciliationCompleted(serde_json::from_value(data)?) + } + "payout.updated" => Self::PayoutUpdated(serde_json::from_value(data)?), + "person.created" => Self::PersonCreated(serde_json::from_value(data)?), + "person.deleted" => Self::PersonDeleted(serde_json::from_value(data)?), + "person.updated" => Self::PersonUpdated(serde_json::from_value(data)?), + "plan.created" => Self::PlanCreated(serde_json::from_value(data)?), + "plan.deleted" => Self::PlanDeleted(serde_json::from_value(data)?), + "plan.updated" => Self::PlanUpdated(serde_json::from_value(data)?), + "price.created" => Self::PriceCreated(serde_json::from_value(data)?), + "price.deleted" => Self::PriceDeleted(serde_json::from_value(data)?), + "price.updated" => Self::PriceUpdated(serde_json::from_value(data)?), + "product.created" => Self::ProductCreated(serde_json::from_value(data)?), + "product.deleted" => Self::ProductDeleted(serde_json::from_value(data)?), + "product.updated" => Self::ProductUpdated(serde_json::from_value(data)?), + "promotion_code.created" => Self::PromotionCodeCreated(serde_json::from_value(data)?), + "promotion_code.updated" => Self::PromotionCodeUpdated(serde_json::from_value(data)?), + "quote.accepted" => Self::QuoteAccepted(serde_json::from_value(data)?), + "quote.canceled" => Self::QuoteCanceled(serde_json::from_value(data)?), + "quote.created" => Self::QuoteCreated(serde_json::from_value(data)?), + "quote.finalized" => Self::QuoteFinalized(serde_json::from_value(data)?), + #[cfg(feature = "stripe_fraud")] + "radar.early_fraud_warning.created" => { + Self::RadarEarlyFraudWarningCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_fraud")] + "radar.early_fraud_warning.updated" => { + Self::RadarEarlyFraudWarningUpdated(serde_json::from_value(data)?) + } + "refund.created" => Self::RefundCreated(serde_json::from_value(data)?), + "refund.updated" => Self::RefundUpdated(serde_json::from_value(data)?), #[cfg(feature = "stripe_misc")] - "climate.order.delayed" => { - EventObject::ClimateOrderDelayed(serde_json::from_value(data)?) + "reporting.report_run.failed" => { + Self::ReportingReportRunFailed(serde_json::from_value(data)?) } #[cfg(feature = "stripe_misc")] - "climate.order.delivered" => { - EventObject::ClimateOrderDelivered(serde_json::from_value(data)?) + "reporting.report_run.succeeded" => { + Self::ReportingReportRunSucceeded(serde_json::from_value(data)?) } #[cfg(feature = "stripe_misc")] - "climate.order.product_substituted" => { - EventObject::ClimateOrderProductSubstituted(serde_json::from_value(data)?) + "reporting.report_type.updated" => { + Self::ReportingReportTypeUpdated(serde_json::from_value(data)?) } + "review.closed" => Self::ReviewClosed(serde_json::from_value(data)?), + "review.opened" => Self::ReviewOpened(serde_json::from_value(data)?), + "setup_intent.canceled" => Self::SetupIntentCanceled(serde_json::from_value(data)?), + "setup_intent.created" => Self::SetupIntentCreated(serde_json::from_value(data)?), + "setup_intent.requires_action" => { + Self::SetupIntentRequiresAction(serde_json::from_value(data)?) + } + "setup_intent.setup_failed" => { + Self::SetupIntentSetupFailed(serde_json::from_value(data)?) + } + "setup_intent.succeeded" => Self::SetupIntentSucceeded(serde_json::from_value(data)?), #[cfg(feature = "stripe_misc")] - "climate.product.created" => { - EventObject::ClimateProductCreated(serde_json::from_value(data)?) + "sigma.scheduled_query_run.created" => { + Self::SigmaScheduledQueryRunCreated(serde_json::from_value(data)?) + } + "source.canceled" => Self::SourceCanceled(serde_json::from_value(data)?), + "source.chargeable" => Self::SourceChargeable(serde_json::from_value(data)?), + "source.failed" => Self::SourceFailed(serde_json::from_value(data)?), + #[cfg(feature = "stripe_payment")] + "source.mandate_notification" => { + Self::SourceMandateNotification(serde_json::from_value(data)?) + } + "source.refund_attributes_required" => { + Self::SourceRefundAttributesRequired(serde_json::from_value(data)?) + } + "source.transaction.created" => { + Self::SourceTransactionCreated(serde_json::from_value(data)?) + } + "source.transaction.updated" => { + Self::SourceTransactionUpdated(serde_json::from_value(data)?) + } + "subscription_schedule.aborted" => { + Self::SubscriptionScheduleAborted(serde_json::from_value(data)?) + } + "subscription_schedule.canceled" => { + Self::SubscriptionScheduleCanceled(serde_json::from_value(data)?) + } + "subscription_schedule.completed" => { + Self::SubscriptionScheduleCompleted(serde_json::from_value(data)?) + } + "subscription_schedule.created" => { + Self::SubscriptionScheduleCreated(serde_json::from_value(data)?) + } + "subscription_schedule.expiring" => { + Self::SubscriptionScheduleExpiring(serde_json::from_value(data)?) + } + "subscription_schedule.released" => { + Self::SubscriptionScheduleReleased(serde_json::from_value(data)?) + } + "subscription_schedule.updated" => { + Self::SubscriptionScheduleUpdated(serde_json::from_value(data)?) } #[cfg(feature = "stripe_misc")] - "climate.product.pricing_updated" => { - EventObject::ClimateProductPricingUpdated(serde_json::from_value(data)?) - } - "coupon.created" => EventObject::CouponCreated(serde_json::from_value(data)?), - "coupon.deleted" => EventObject::CouponDeleted(serde_json::from_value(data)?), - "coupon.updated" => EventObject::CouponUpdated(serde_json::from_value(data)?), - "credit_note.created" => EventObject::CreditNoteCreated(serde_json::from_value(data)?), - "credit_note.updated" => EventObject::CreditNoteUpdated(serde_json::from_value(data)?), - "credit_note.voided" => EventObject::CreditNoteVoided(serde_json::from_value(data)?), - "customer.created" => EventObject::CustomerCreated(serde_json::from_value(data)?), - "customer.deleted" => EventObject::CustomerDeleted(serde_json::from_value(data)?), + "tax.settings.updated" => Self::TaxSettingsUpdated(serde_json::from_value(data)?), + "tax_rate.created" => Self::TaxRateCreated(serde_json::from_value(data)?), + "tax_rate.updated" => Self::TaxRateUpdated(serde_json::from_value(data)?), + #[cfg(feature = "stripe_terminal")] + "terminal.reader.action_failed" => { + Self::TerminalReaderActionFailed(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_terminal")] + "terminal.reader.action_succeeded" => { + Self::TerminalReaderActionSucceeded(serde_json::from_value(data)?) + } + "test_helpers.test_clock.advancing" => { + Self::TestHelpersTestClockAdvancing(serde_json::from_value(data)?) + } + "test_helpers.test_clock.created" => { + Self::TestHelpersTestClockCreated(serde_json::from_value(data)?) + } + "test_helpers.test_clock.deleted" => { + Self::TestHelpersTestClockDeleted(serde_json::from_value(data)?) + } + "test_helpers.test_clock.internal_failure" => { + Self::TestHelpersTestClockInternalFailure(serde_json::from_value(data)?) + } + "test_helpers.test_clock.ready" => { + Self::TestHelpersTestClockReady(serde_json::from_value(data)?) + } + "topup.canceled" => Self::TopupCanceled(serde_json::from_value(data)?), + "topup.created" => Self::TopupCreated(serde_json::from_value(data)?), + "topup.failed" => Self::TopupFailed(serde_json::from_value(data)?), + "topup.reversed" => Self::TopupReversed(serde_json::from_value(data)?), + "topup.succeeded" => Self::TopupSucceeded(serde_json::from_value(data)?), + "transfer.created" => Self::TransferCreated(serde_json::from_value(data)?), + "transfer.reversed" => Self::TransferReversed(serde_json::from_value(data)?), + "transfer.updated" => Self::TransferUpdated(serde_json::from_value(data)?), + #[cfg(feature = "stripe_treasury")] + "treasury.credit_reversal.created" => { + Self::TreasuryCreditReversalCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.credit_reversal.posted" => { + Self::TreasuryCreditReversalPosted(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.debit_reversal.completed" => { + Self::TreasuryDebitReversalCompleted(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.debit_reversal.created" => { + Self::TreasuryDebitReversalCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.debit_reversal.initial_credit_granted" => { + Self::TreasuryDebitReversalInitialCreditGranted(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.financial_account.closed" => { + Self::TreasuryFinancialAccountClosed(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.financial_account.created" => { + Self::TreasuryFinancialAccountCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.financial_account.features_status_updated" => { + Self::TreasuryFinancialAccountFeaturesStatusUpdated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.inbound_transfer.canceled" => { + Self::TreasuryInboundTransferCanceled(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.inbound_transfer.created" => { + Self::TreasuryInboundTransferCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.inbound_transfer.failed" => { + Self::TreasuryInboundTransferFailed(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.inbound_transfer.succeeded" => { + Self::TreasuryInboundTransferSucceeded(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_payment.canceled" => { + Self::TreasuryOutboundPaymentCanceled(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_payment.created" => { + Self::TreasuryOutboundPaymentCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_payment.expected_arrival_date_updated" => { + Self::TreasuryOutboundPaymentExpectedArrivalDateUpdated(serde_json::from_value( + data, + )?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_payment.failed" => { + Self::TreasuryOutboundPaymentFailed(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_payment.posted" => { + Self::TreasuryOutboundPaymentPosted(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_payment.returned" => { + Self::TreasuryOutboundPaymentReturned(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_transfer.canceled" => { + Self::TreasuryOutboundTransferCanceled(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_transfer.created" => { + Self::TreasuryOutboundTransferCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_transfer.expected_arrival_date_updated" => { + Self::TreasuryOutboundTransferExpectedArrivalDateUpdated(serde_json::from_value( + data, + )?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_transfer.failed" => { + Self::TreasuryOutboundTransferFailed(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_transfer.posted" => { + Self::TreasuryOutboundTransferPosted(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.outbound_transfer.returned" => { + Self::TreasuryOutboundTransferReturned(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.received_credit.created" => { + Self::TreasuryReceivedCreditCreated(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.received_credit.failed" => { + Self::TreasuryReceivedCreditFailed(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.received_credit.succeeded" => { + Self::TreasuryReceivedCreditSucceeded(serde_json::from_value(data)?) + } + #[cfg(feature = "stripe_treasury")] + "treasury.received_debit.created" => { + Self::TreasuryReceivedDebitCreated(serde_json::from_value(data)?) + } + + _ => Self::Unknown(data), + }) + } + + #[cfg(feature = "min-ser")] + pub(crate) fn from_raw_data(typ: &str, data: miniserde::json::Value) -> Option<Self> { + use stripe_types::miniserde_helpers::FromValueOpt; + Some(match typ { + "account.application.authorized" => { + Self::AccountApplicationAuthorized(FromValueOpt::from_value(data)?) + } + "account.application.deauthorized" => { + Self::AccountApplicationDeauthorized(FromValueOpt::from_value(data)?) + } + "account.external_account.created" => { + Self::AccountExternalAccountCreated(FromValueOpt::from_value(data)?) + } + "account.external_account.deleted" => { + Self::AccountExternalAccountDeleted(FromValueOpt::from_value(data)?) + } + "account.external_account.updated" => { + Self::AccountExternalAccountUpdated(FromValueOpt::from_value(data)?) + } + "account.updated" => Self::AccountUpdated(FromValueOpt::from_value(data)?), + "application_fee.created" => { + Self::ApplicationFeeCreated(FromValueOpt::from_value(data)?) + } + "application_fee.refund.updated" => { + Self::ApplicationFeeRefundUpdated(FromValueOpt::from_value(data)?) + } + "application_fee.refunded" => { + Self::ApplicationFeeRefunded(FromValueOpt::from_value(data)?) + } + #[cfg(feature = "stripe_core")] + "balance.available" => Self::BalanceAvailable(FromValueOpt::from_value(data)?), + #[cfg(feature = "stripe_billing")] + "billing_portal.configuration.created" => { + Self::BillingPortalConfigurationCreated(FromValueOpt::from_value(data)?) + } + #[cfg(feature = "stripe_billing")] + "billing_portal.configuration.updated" => { + Self::BillingPortalConfigurationUpdated(FromValueOpt::from_value(data)?) + } + #[cfg(feature = "stripe_billing")] + "billing_portal.session.created" => { + Self::BillingPortalSessionCreated(FromValueOpt::from_value(data)?) + } + "capability.updated" => Self::CapabilityUpdated(FromValueOpt::from_value(data)?), + "cash_balance.funds_available" => { + Self::CashBalanceFundsAvailable(FromValueOpt::from_value(data)?) + } + "charge.captured" => Self::ChargeCaptured(FromValueOpt::from_value(data)?), + "charge.dispute.closed" => Self::ChargeDisputeClosed(FromValueOpt::from_value(data)?), + "charge.dispute.created" => Self::ChargeDisputeCreated(FromValueOpt::from_value(data)?), + "charge.dispute.funds_reinstated" => { + Self::ChargeDisputeFundsReinstated(FromValueOpt::from_value(data)?) + } + "charge.dispute.funds_withdrawn" => { + Self::ChargeDisputeFundsWithdrawn(FromValueOpt::from_value(data)?) + } + "charge.dispute.updated" => Self::ChargeDisputeUpdated(FromValueOpt::from_value(data)?), + "charge.expired" => Self::ChargeExpired(FromValueOpt::from_value(data)?), + "charge.failed" => Self::ChargeFailed(FromValueOpt::from_value(data)?), + "charge.pending" => Self::ChargePending(FromValueOpt::from_value(data)?), + "charge.refund.updated" => Self::ChargeRefundUpdated(FromValueOpt::from_value(data)?), + "charge.refunded" => Self::ChargeRefunded(FromValueOpt::from_value(data)?), + "charge.succeeded" => Self::ChargeSucceeded(FromValueOpt::from_value(data)?), + "charge.updated" => Self::ChargeUpdated(FromValueOpt::from_value(data)?), + #[cfg(feature = "stripe_checkout")] + "checkout.session.async_payment_failed" => { + Self::CheckoutSessionAsyncPaymentFailed(FromValueOpt::from_value(data)?) + } + #[cfg(feature = "stripe_checkout")] + "checkout.session.async_payment_succeeded" => { + Self::CheckoutSessionAsyncPaymentSucceeded(FromValueOpt::from_value(data)?) + } + #[cfg(feature = "stripe_checkout")] + "checkout.session.completed" => { + Self::CheckoutSessionCompleted(FromValueOpt::from_value(data)?) + } + #[cfg(feature = "stripe_checkout")] + "checkout.session.expired" => { + Self::CheckoutSessionExpired(FromValueOpt::from_value(data)?) + } + "coupon.created" => Self::CouponCreated(FromValueOpt::from_value(data)?), + "coupon.deleted" => Self::CouponDeleted(FromValueOpt::from_value(data)?), + "coupon.updated" => Self::CouponUpdated(FromValueOpt::from_value(data)?), + "credit_note.created" => Self::CreditNoteCreated(FromValueOpt::from_value(data)?), + "credit_note.updated" => Self::CreditNoteUpdated(FromValueOpt::from_value(data)?), + "credit_note.voided" => Self::CreditNoteVoided(FromValueOpt::from_value(data)?), + "customer.created" => Self::CustomerCreated(FromValueOpt::from_value(data)?), + "customer.deleted" => Self::CustomerDeleted(FromValueOpt::from_value(data)?), "customer.discount.created" => { - EventObject::CustomerDiscountCreated(serde_json::from_value(data)?) + Self::CustomerDiscountCreated(FromValueOpt::from_value(data)?) } "customer.discount.deleted" => { - EventObject::CustomerDiscountDeleted(serde_json::from_value(data)?) + Self::CustomerDiscountDeleted(FromValueOpt::from_value(data)?) } "customer.discount.updated" => { - EventObject::CustomerDiscountUpdated(serde_json::from_value(data)?) + Self::CustomerDiscountUpdated(FromValueOpt::from_value(data)?) } "customer.source.created" => { - EventObject::CustomerSourceCreated(serde_json::from_value(data)?) + Self::CustomerSourceCreated(FromValueOpt::from_value(data)?) } "customer.source.deleted" => { - EventObject::CustomerSourceDeleted(serde_json::from_value(data)?) + Self::CustomerSourceDeleted(FromValueOpt::from_value(data)?) } "customer.source.expiring" => { - EventObject::CustomerSourceExpiring(serde_json::from_value(data)?) + Self::CustomerSourceExpiring(FromValueOpt::from_value(data)?) } "customer.source.updated" => { - EventObject::CustomerSourceUpdated(serde_json::from_value(data)?) + Self::CustomerSourceUpdated(FromValueOpt::from_value(data)?) } "customer.subscription.created" => { - EventObject::CustomerSubscriptionCreated(serde_json::from_value(data)?) + Self::CustomerSubscriptionCreated(FromValueOpt::from_value(data)?) } "customer.subscription.deleted" => { - EventObject::CustomerSubscriptionDeleted(serde_json::from_value(data)?) + Self::CustomerSubscriptionDeleted(FromValueOpt::from_value(data)?) } "customer.subscription.paused" => { - EventObject::CustomerSubscriptionPaused(serde_json::from_value(data)?) + Self::CustomerSubscriptionPaused(FromValueOpt::from_value(data)?) } "customer.subscription.pending_update_applied" => { - EventObject::CustomerSubscriptionPendingUpdateApplied(serde_json::from_value(data)?) + Self::CustomerSubscriptionPendingUpdateApplied(FromValueOpt::from_value(data)?) } "customer.subscription.pending_update_expired" => { - EventObject::CustomerSubscriptionPendingUpdateExpired(serde_json::from_value(data)?) + Self::CustomerSubscriptionPendingUpdateExpired(FromValueOpt::from_value(data)?) } "customer.subscription.resumed" => { - EventObject::CustomerSubscriptionResumed(serde_json::from_value(data)?) + Self::CustomerSubscriptionResumed(FromValueOpt::from_value(data)?) } "customer.subscription.trial_will_end" => { - EventObject::CustomerSubscriptionTrialWillEnd(serde_json::from_value(data)?) + Self::CustomerSubscriptionTrialWillEnd(FromValueOpt::from_value(data)?) } "customer.subscription.updated" => { - EventObject::CustomerSubscriptionUpdated(serde_json::from_value(data)?) + Self::CustomerSubscriptionUpdated(FromValueOpt::from_value(data)?) } "customer.tax_id.created" => { - EventObject::CustomerTaxIdCreated(serde_json::from_value(data)?) + Self::CustomerTaxIdCreated(FromValueOpt::from_value(data)?) } "customer.tax_id.deleted" => { - EventObject::CustomerTaxIdDeleted(serde_json::from_value(data)?) + Self::CustomerTaxIdDeleted(FromValueOpt::from_value(data)?) } "customer.tax_id.updated" => { - EventObject::CustomerTaxIdUpdated(serde_json::from_value(data)?) + Self::CustomerTaxIdUpdated(FromValueOpt::from_value(data)?) } - "customer.updated" => EventObject::CustomerUpdated(serde_json::from_value(data)?), + "customer.updated" => Self::CustomerUpdated(FromValueOpt::from_value(data)?), "customer_cash_balance_transaction.created" => { - EventObject::CustomerCashBalanceTransactionCreated(serde_json::from_value(data)?) + Self::CustomerCashBalanceTransactionCreated(FromValueOpt::from_value(data)?) } - "file.created" => EventObject::FileCreated(serde_json::from_value(data)?), + "file.created" => Self::FileCreated(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_misc")] "financial_connections.account.created" => { - EventObject::FinancialConnectionsAccountCreated(serde_json::from_value(data)?) + Self::FinancialConnectionsAccountCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "financial_connections.account.deactivated" => { - EventObject::FinancialConnectionsAccountDeactivated(serde_json::from_value(data)?) + Self::FinancialConnectionsAccountDeactivated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "financial_connections.account.disconnected" => { - EventObject::FinancialConnectionsAccountDisconnected(serde_json::from_value(data)?) + Self::FinancialConnectionsAccountDisconnected(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "financial_connections.account.reactivated" => { - EventObject::FinancialConnectionsAccountReactivated(serde_json::from_value(data)?) + Self::FinancialConnectionsAccountReactivated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "financial_connections.account.refreshed_balance" => { - EventObject::FinancialConnectionsAccountRefreshedBalance(serde_json::from_value( - data, - )?) - } - #[cfg(feature = "stripe_misc")] - "financial_connections.account.refreshed_transactions" => { - EventObject::FinancialConnectionsAccountRefreshedTransactions( - serde_json::from_value(data)?, - ) + Self::FinancialConnectionsAccountRefreshedBalance(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "identity.verification_session.canceled" => { - EventObject::IdentityVerificationSessionCanceled(serde_json::from_value(data)?) + Self::IdentityVerificationSessionCanceled(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "identity.verification_session.created" => { - EventObject::IdentityVerificationSessionCreated(serde_json::from_value(data)?) + Self::IdentityVerificationSessionCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "identity.verification_session.processing" => { - EventObject::IdentityVerificationSessionProcessing(serde_json::from_value(data)?) + Self::IdentityVerificationSessionProcessing(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "identity.verification_session.redacted" => { - EventObject::IdentityVerificationSessionRedacted(serde_json::from_value(data)?) + Self::IdentityVerificationSessionRedacted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "identity.verification_session.requires_input" => { - EventObject::IdentityVerificationSessionRequiresInput(serde_json::from_value(data)?) + Self::IdentityVerificationSessionRequiresInput(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "identity.verification_session.verified" => { - EventObject::IdentityVerificationSessionVerified(serde_json::from_value(data)?) + Self::IdentityVerificationSessionVerified(FromValueOpt::from_value(data)?) } - "invoice.created" => EventObject::InvoiceCreated(serde_json::from_value(data)?), - "invoice.deleted" => EventObject::InvoiceDeleted(serde_json::from_value(data)?), + "invoice.created" => Self::InvoiceCreated(FromValueOpt::from_value(data)?), + "invoice.deleted" => Self::InvoiceDeleted(FromValueOpt::from_value(data)?), "invoice.finalization_failed" => { - EventObject::InvoiceFinalizationFailed(serde_json::from_value(data)?) + Self::InvoiceFinalizationFailed(FromValueOpt::from_value(data)?) } - "invoice.finalized" => EventObject::InvoiceFinalized(serde_json::from_value(data)?), + "invoice.finalized" => Self::InvoiceFinalized(FromValueOpt::from_value(data)?), "invoice.marked_uncollectible" => { - EventObject::InvoiceMarkedUncollectible(serde_json::from_value(data)?) + Self::InvoiceMarkedUncollectible(FromValueOpt::from_value(data)?) } - "invoice.paid" => EventObject::InvoicePaid(serde_json::from_value(data)?), + "invoice.paid" => Self::InvoicePaid(FromValueOpt::from_value(data)?), "invoice.payment_action_required" => { - EventObject::InvoicePaymentActionRequired(serde_json::from_value(data)?) - } - "invoice.payment_failed" => { - EventObject::InvoicePaymentFailed(serde_json::from_value(data)?) + Self::InvoicePaymentActionRequired(FromValueOpt::from_value(data)?) } + "invoice.payment_failed" => Self::InvoicePaymentFailed(FromValueOpt::from_value(data)?), "invoice.payment_succeeded" => { - EventObject::InvoicePaymentSucceeded(serde_json::from_value(data)?) - } - "invoice.sent" => EventObject::InvoiceSent(serde_json::from_value(data)?), - "invoice.upcoming" => EventObject::InvoiceUpcoming(serde_json::from_value(data)?), - "invoice.updated" => EventObject::InvoiceUpdated(serde_json::from_value(data)?), - "invoice.voided" => EventObject::InvoiceVoided(serde_json::from_value(data)?), - "invoiceitem.created" => EventObject::InvoiceitemCreated(serde_json::from_value(data)?), - "invoiceitem.deleted" => EventObject::InvoiceitemDeleted(serde_json::from_value(data)?), + Self::InvoicePaymentSucceeded(FromValueOpt::from_value(data)?) + } + "invoice.sent" => Self::InvoiceSent(FromValueOpt::from_value(data)?), + "invoice.upcoming" => Self::InvoiceUpcoming(FromValueOpt::from_value(data)?), + "invoice.updated" => Self::InvoiceUpdated(FromValueOpt::from_value(data)?), + "invoice.voided" => Self::InvoiceVoided(FromValueOpt::from_value(data)?), + "invoiceitem.created" => Self::InvoiceitemCreated(FromValueOpt::from_value(data)?), + "invoiceitem.deleted" => Self::InvoiceitemDeleted(FromValueOpt::from_value(data)?), "issuing_authorization.created" => { - EventObject::IssuingAuthorizationCreated(serde_json::from_value(data)?) + Self::IssuingAuthorizationCreated(FromValueOpt::from_value(data)?) } "issuing_authorization.request" => { - EventObject::IssuingAuthorizationRequest(serde_json::from_value(data)?) + Self::IssuingAuthorizationRequest(FromValueOpt::from_value(data)?) } "issuing_authorization.updated" => { - EventObject::IssuingAuthorizationUpdated(serde_json::from_value(data)?) - } - "issuing_card.created" => { - EventObject::IssuingCardCreated(serde_json::from_value(data)?) - } - "issuing_card.updated" => { - EventObject::IssuingCardUpdated(serde_json::from_value(data)?) + Self::IssuingAuthorizationUpdated(FromValueOpt::from_value(data)?) } + "issuing_card.created" => Self::IssuingCardCreated(FromValueOpt::from_value(data)?), + "issuing_card.updated" => Self::IssuingCardUpdated(FromValueOpt::from_value(data)?), "issuing_cardholder.created" => { - EventObject::IssuingCardholderCreated(serde_json::from_value(data)?) + Self::IssuingCardholderCreated(FromValueOpt::from_value(data)?) } "issuing_cardholder.updated" => { - EventObject::IssuingCardholderUpdated(serde_json::from_value(data)?) - } - "issuing_dispute.closed" => { - EventObject::IssuingDisputeClosed(serde_json::from_value(data)?) + Self::IssuingCardholderUpdated(FromValueOpt::from_value(data)?) } + "issuing_dispute.closed" => Self::IssuingDisputeClosed(FromValueOpt::from_value(data)?), "issuing_dispute.created" => { - EventObject::IssuingDisputeCreated(serde_json::from_value(data)?) + Self::IssuingDisputeCreated(FromValueOpt::from_value(data)?) } "issuing_dispute.funds_reinstated" => { - EventObject::IssuingDisputeFundsReinstated(serde_json::from_value(data)?) + Self::IssuingDisputeFundsReinstated(FromValueOpt::from_value(data)?) } "issuing_dispute.submitted" => { - EventObject::IssuingDisputeSubmitted(serde_json::from_value(data)?) + Self::IssuingDisputeSubmitted(FromValueOpt::from_value(data)?) } "issuing_dispute.updated" => { - EventObject::IssuingDisputeUpdated(serde_json::from_value(data)?) - } - "issuing_token.created" => { - EventObject::IssuingTokenCreated(serde_json::from_value(data)?) - } - "issuing_token.updated" => { - EventObject::IssuingTokenUpdated(serde_json::from_value(data)?) + Self::IssuingDisputeUpdated(FromValueOpt::from_value(data)?) } + "issuing_token.created" => Self::IssuingTokenCreated(FromValueOpt::from_value(data)?), + "issuing_token.updated" => Self::IssuingTokenUpdated(FromValueOpt::from_value(data)?), "issuing_transaction.created" => { - EventObject::IssuingTransactionCreated(serde_json::from_value(data)?) + Self::IssuingTransactionCreated(FromValueOpt::from_value(data)?) } "issuing_transaction.updated" => { - EventObject::IssuingTransactionUpdated(serde_json::from_value(data)?) + Self::IssuingTransactionUpdated(FromValueOpt::from_value(data)?) } - "mandate.updated" => EventObject::MandateUpdated(serde_json::from_value(data)?), + "mandate.updated" => Self::MandateUpdated(FromValueOpt::from_value(data)?), "payment_intent.amount_capturable_updated" => { - EventObject::PaymentIntentAmountCapturableUpdated(serde_json::from_value(data)?) + Self::PaymentIntentAmountCapturableUpdated(FromValueOpt::from_value(data)?) } "payment_intent.canceled" => { - EventObject::PaymentIntentCanceled(serde_json::from_value(data)?) - } - "payment_intent.created" => { - EventObject::PaymentIntentCreated(serde_json::from_value(data)?) + Self::PaymentIntentCanceled(FromValueOpt::from_value(data)?) } + "payment_intent.created" => Self::PaymentIntentCreated(FromValueOpt::from_value(data)?), "payment_intent.partially_funded" => { - EventObject::PaymentIntentPartiallyFunded(serde_json::from_value(data)?) + Self::PaymentIntentPartiallyFunded(FromValueOpt::from_value(data)?) } "payment_intent.payment_failed" => { - EventObject::PaymentIntentPaymentFailed(serde_json::from_value(data)?) + Self::PaymentIntentPaymentFailed(FromValueOpt::from_value(data)?) } "payment_intent.processing" => { - EventObject::PaymentIntentProcessing(serde_json::from_value(data)?) + Self::PaymentIntentProcessing(FromValueOpt::from_value(data)?) } "payment_intent.requires_action" => { - EventObject::PaymentIntentRequiresAction(serde_json::from_value(data)?) + Self::PaymentIntentRequiresAction(FromValueOpt::from_value(data)?) } "payment_intent.succeeded" => { - EventObject::PaymentIntentSucceeded(serde_json::from_value(data)?) - } - "payment_link.created" => { - EventObject::PaymentLinkCreated(serde_json::from_value(data)?) - } - "payment_link.updated" => { - EventObject::PaymentLinkUpdated(serde_json::from_value(data)?) + Self::PaymentIntentSucceeded(FromValueOpt::from_value(data)?) } + "payment_link.created" => Self::PaymentLinkCreated(FromValueOpt::from_value(data)?), + "payment_link.updated" => Self::PaymentLinkUpdated(FromValueOpt::from_value(data)?), "payment_method.attached" => { - EventObject::PaymentMethodAttached(serde_json::from_value(data)?) + Self::PaymentMethodAttached(FromValueOpt::from_value(data)?) } "payment_method.automatically_updated" => { - EventObject::PaymentMethodAutomaticallyUpdated(serde_json::from_value(data)?) + Self::PaymentMethodAutomaticallyUpdated(FromValueOpt::from_value(data)?) } "payment_method.detached" => { - EventObject::PaymentMethodDetached(serde_json::from_value(data)?) + Self::PaymentMethodDetached(FromValueOpt::from_value(data)?) } - "payment_method.updated" => { - EventObject::PaymentMethodUpdated(serde_json::from_value(data)?) - } - "payout.canceled" => EventObject::PayoutCanceled(serde_json::from_value(data)?), - "payout.created" => EventObject::PayoutCreated(serde_json::from_value(data)?), - "payout.failed" => EventObject::PayoutFailed(serde_json::from_value(data)?), - "payout.paid" => EventObject::PayoutPaid(serde_json::from_value(data)?), + "payment_method.updated" => Self::PaymentMethodUpdated(FromValueOpt::from_value(data)?), + "payout.canceled" => Self::PayoutCanceled(FromValueOpt::from_value(data)?), + "payout.created" => Self::PayoutCreated(FromValueOpt::from_value(data)?), + "payout.failed" => Self::PayoutFailed(FromValueOpt::from_value(data)?), + "payout.paid" => Self::PayoutPaid(FromValueOpt::from_value(data)?), "payout.reconciliation_completed" => { - EventObject::PayoutReconciliationCompleted(serde_json::from_value(data)?) - } - "payout.updated" => EventObject::PayoutUpdated(serde_json::from_value(data)?), - "person.created" => EventObject::PersonCreated(serde_json::from_value(data)?), - "person.deleted" => EventObject::PersonDeleted(serde_json::from_value(data)?), - "person.updated" => EventObject::PersonUpdated(serde_json::from_value(data)?), - "plan.created" => EventObject::PlanCreated(serde_json::from_value(data)?), - "plan.deleted" => EventObject::PlanDeleted(serde_json::from_value(data)?), - "plan.updated" => EventObject::PlanUpdated(serde_json::from_value(data)?), - "price.created" => EventObject::PriceCreated(serde_json::from_value(data)?), - "price.deleted" => EventObject::PriceDeleted(serde_json::from_value(data)?), - "price.updated" => EventObject::PriceUpdated(serde_json::from_value(data)?), - "product.created" => EventObject::ProductCreated(serde_json::from_value(data)?), - "product.deleted" => EventObject::ProductDeleted(serde_json::from_value(data)?), - "product.updated" => EventObject::ProductUpdated(serde_json::from_value(data)?), - "promotion_code.created" => { - EventObject::PromotionCodeCreated(serde_json::from_value(data)?) - } - "promotion_code.updated" => { - EventObject::PromotionCodeUpdated(serde_json::from_value(data)?) - } - "quote.accepted" => EventObject::QuoteAccepted(serde_json::from_value(data)?), - "quote.canceled" => EventObject::QuoteCanceled(serde_json::from_value(data)?), - "quote.created" => EventObject::QuoteCreated(serde_json::from_value(data)?), - "quote.finalized" => EventObject::QuoteFinalized(serde_json::from_value(data)?), + Self::PayoutReconciliationCompleted(FromValueOpt::from_value(data)?) + } + "payout.updated" => Self::PayoutUpdated(FromValueOpt::from_value(data)?), + "person.created" => Self::PersonCreated(FromValueOpt::from_value(data)?), + "person.deleted" => Self::PersonDeleted(FromValueOpt::from_value(data)?), + "person.updated" => Self::PersonUpdated(FromValueOpt::from_value(data)?), + "plan.created" => Self::PlanCreated(FromValueOpt::from_value(data)?), + "plan.deleted" => Self::PlanDeleted(FromValueOpt::from_value(data)?), + "plan.updated" => Self::PlanUpdated(FromValueOpt::from_value(data)?), + "price.created" => Self::PriceCreated(FromValueOpt::from_value(data)?), + "price.deleted" => Self::PriceDeleted(FromValueOpt::from_value(data)?), + "price.updated" => Self::PriceUpdated(FromValueOpt::from_value(data)?), + "product.created" => Self::ProductCreated(FromValueOpt::from_value(data)?), + "product.deleted" => Self::ProductDeleted(FromValueOpt::from_value(data)?), + "product.updated" => Self::ProductUpdated(FromValueOpt::from_value(data)?), + "promotion_code.created" => Self::PromotionCodeCreated(FromValueOpt::from_value(data)?), + "promotion_code.updated" => Self::PromotionCodeUpdated(FromValueOpt::from_value(data)?), + "quote.accepted" => Self::QuoteAccepted(FromValueOpt::from_value(data)?), + "quote.canceled" => Self::QuoteCanceled(FromValueOpt::from_value(data)?), + "quote.created" => Self::QuoteCreated(FromValueOpt::from_value(data)?), + "quote.finalized" => Self::QuoteFinalized(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_fraud")] "radar.early_fraud_warning.created" => { - EventObject::RadarEarlyFraudWarningCreated(serde_json::from_value(data)?) + Self::RadarEarlyFraudWarningCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_fraud")] "radar.early_fraud_warning.updated" => { - EventObject::RadarEarlyFraudWarningUpdated(serde_json::from_value(data)?) + Self::RadarEarlyFraudWarningUpdated(FromValueOpt::from_value(data)?) } - "refund.created" => EventObject::RefundCreated(serde_json::from_value(data)?), - "refund.updated" => EventObject::RefundUpdated(serde_json::from_value(data)?), + "refund.created" => Self::RefundCreated(FromValueOpt::from_value(data)?), + "refund.updated" => Self::RefundUpdated(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_misc")] "reporting.report_run.failed" => { - EventObject::ReportingReportRunFailed(serde_json::from_value(data)?) + Self::ReportingReportRunFailed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "reporting.report_run.succeeded" => { - EventObject::ReportingReportRunSucceeded(serde_json::from_value(data)?) + Self::ReportingReportRunSucceeded(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "reporting.report_type.updated" => { - EventObject::ReportingReportTypeUpdated(serde_json::from_value(data)?) - } - "review.closed" => EventObject::ReviewClosed(serde_json::from_value(data)?), - "review.opened" => EventObject::ReviewOpened(serde_json::from_value(data)?), - "setup_intent.canceled" => { - EventObject::SetupIntentCanceled(serde_json::from_value(data)?) - } - "setup_intent.created" => { - EventObject::SetupIntentCreated(serde_json::from_value(data)?) + Self::ReportingReportTypeUpdated(FromValueOpt::from_value(data)?) } + "review.closed" => Self::ReviewClosed(FromValueOpt::from_value(data)?), + "review.opened" => Self::ReviewOpened(FromValueOpt::from_value(data)?), + "setup_intent.canceled" => Self::SetupIntentCanceled(FromValueOpt::from_value(data)?), + "setup_intent.created" => Self::SetupIntentCreated(FromValueOpt::from_value(data)?), "setup_intent.requires_action" => { - EventObject::SetupIntentRequiresAction(serde_json::from_value(data)?) + Self::SetupIntentRequiresAction(FromValueOpt::from_value(data)?) } "setup_intent.setup_failed" => { - EventObject::SetupIntentSetupFailed(serde_json::from_value(data)?) - } - "setup_intent.succeeded" => { - EventObject::SetupIntentSucceeded(serde_json::from_value(data)?) + Self::SetupIntentSetupFailed(FromValueOpt::from_value(data)?) } + "setup_intent.succeeded" => Self::SetupIntentSucceeded(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_misc")] "sigma.scheduled_query_run.created" => { - EventObject::SigmaScheduledQueryRunCreated(serde_json::from_value(data)?) + Self::SigmaScheduledQueryRunCreated(FromValueOpt::from_value(data)?) } - "source.canceled" => EventObject::SourceCanceled(serde_json::from_value(data)?), - "source.chargeable" => EventObject::SourceChargeable(serde_json::from_value(data)?), - "source.failed" => EventObject::SourceFailed(serde_json::from_value(data)?), + "source.canceled" => Self::SourceCanceled(FromValueOpt::from_value(data)?), + "source.chargeable" => Self::SourceChargeable(FromValueOpt::from_value(data)?), + "source.failed" => Self::SourceFailed(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_payment")] "source.mandate_notification" => { - EventObject::SourceMandateNotification(serde_json::from_value(data)?) + Self::SourceMandateNotification(FromValueOpt::from_value(data)?) } "source.refund_attributes_required" => { - EventObject::SourceRefundAttributesRequired(serde_json::from_value(data)?) + Self::SourceRefundAttributesRequired(FromValueOpt::from_value(data)?) } "source.transaction.created" => { - EventObject::SourceTransactionCreated(serde_json::from_value(data)?) + Self::SourceTransactionCreated(FromValueOpt::from_value(data)?) } "source.transaction.updated" => { - EventObject::SourceTransactionUpdated(serde_json::from_value(data)?) + Self::SourceTransactionUpdated(FromValueOpt::from_value(data)?) } "subscription_schedule.aborted" => { - EventObject::SubscriptionScheduleAborted(serde_json::from_value(data)?) + Self::SubscriptionScheduleAborted(FromValueOpt::from_value(data)?) } "subscription_schedule.canceled" => { - EventObject::SubscriptionScheduleCanceled(serde_json::from_value(data)?) + Self::SubscriptionScheduleCanceled(FromValueOpt::from_value(data)?) } "subscription_schedule.completed" => { - EventObject::SubscriptionScheduleCompleted(serde_json::from_value(data)?) + Self::SubscriptionScheduleCompleted(FromValueOpt::from_value(data)?) } "subscription_schedule.created" => { - EventObject::SubscriptionScheduleCreated(serde_json::from_value(data)?) + Self::SubscriptionScheduleCreated(FromValueOpt::from_value(data)?) } "subscription_schedule.expiring" => { - EventObject::SubscriptionScheduleExpiring(serde_json::from_value(data)?) + Self::SubscriptionScheduleExpiring(FromValueOpt::from_value(data)?) } "subscription_schedule.released" => { - EventObject::SubscriptionScheduleReleased(serde_json::from_value(data)?) + Self::SubscriptionScheduleReleased(FromValueOpt::from_value(data)?) } "subscription_schedule.updated" => { - EventObject::SubscriptionScheduleUpdated(serde_json::from_value(data)?) + Self::SubscriptionScheduleUpdated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] - "tax.settings.updated" => { - EventObject::TaxSettingsUpdated(serde_json::from_value(data)?) - } - "tax_rate.created" => EventObject::TaxRateCreated(serde_json::from_value(data)?), - "tax_rate.updated" => EventObject::TaxRateUpdated(serde_json::from_value(data)?), + "tax.settings.updated" => Self::TaxSettingsUpdated(FromValueOpt::from_value(data)?), + "tax_rate.created" => Self::TaxRateCreated(FromValueOpt::from_value(data)?), + "tax_rate.updated" => Self::TaxRateUpdated(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_terminal")] "terminal.reader.action_failed" => { - EventObject::TerminalReaderActionFailed(serde_json::from_value(data)?) + Self::TerminalReaderActionFailed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_terminal")] "terminal.reader.action_succeeded" => { - EventObject::TerminalReaderActionSucceeded(serde_json::from_value(data)?) + Self::TerminalReaderActionSucceeded(FromValueOpt::from_value(data)?) } "test_helpers.test_clock.advancing" => { - EventObject::TestHelpersTestClockAdvancing(serde_json::from_value(data)?) + Self::TestHelpersTestClockAdvancing(FromValueOpt::from_value(data)?) } "test_helpers.test_clock.created" => { - EventObject::TestHelpersTestClockCreated(serde_json::from_value(data)?) + Self::TestHelpersTestClockCreated(FromValueOpt::from_value(data)?) } "test_helpers.test_clock.deleted" => { - EventObject::TestHelpersTestClockDeleted(serde_json::from_value(data)?) + Self::TestHelpersTestClockDeleted(FromValueOpt::from_value(data)?) } "test_helpers.test_clock.internal_failure" => { - EventObject::TestHelpersTestClockInternalFailure(serde_json::from_value(data)?) + Self::TestHelpersTestClockInternalFailure(FromValueOpt::from_value(data)?) } "test_helpers.test_clock.ready" => { - EventObject::TestHelpersTestClockReady(serde_json::from_value(data)?) - } - "topup.canceled" => EventObject::TopupCanceled(serde_json::from_value(data)?), - "topup.created" => EventObject::TopupCreated(serde_json::from_value(data)?), - "topup.failed" => EventObject::TopupFailed(serde_json::from_value(data)?), - "topup.reversed" => EventObject::TopupReversed(serde_json::from_value(data)?), - "topup.succeeded" => EventObject::TopupSucceeded(serde_json::from_value(data)?), - "transfer.created" => EventObject::TransferCreated(serde_json::from_value(data)?), - "transfer.reversed" => EventObject::TransferReversed(serde_json::from_value(data)?), - "transfer.updated" => EventObject::TransferUpdated(serde_json::from_value(data)?), + Self::TestHelpersTestClockReady(FromValueOpt::from_value(data)?) + } + "topup.canceled" => Self::TopupCanceled(FromValueOpt::from_value(data)?), + "topup.created" => Self::TopupCreated(FromValueOpt::from_value(data)?), + "topup.failed" => Self::TopupFailed(FromValueOpt::from_value(data)?), + "topup.reversed" => Self::TopupReversed(FromValueOpt::from_value(data)?), + "topup.succeeded" => Self::TopupSucceeded(FromValueOpt::from_value(data)?), + "transfer.created" => Self::TransferCreated(FromValueOpt::from_value(data)?), + "transfer.reversed" => Self::TransferReversed(FromValueOpt::from_value(data)?), + "transfer.updated" => Self::TransferUpdated(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_treasury")] "treasury.credit_reversal.created" => { - EventObject::TreasuryCreditReversalCreated(serde_json::from_value(data)?) + Self::TreasuryCreditReversalCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.credit_reversal.posted" => { - EventObject::TreasuryCreditReversalPosted(serde_json::from_value(data)?) + Self::TreasuryCreditReversalPosted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.debit_reversal.completed" => { - EventObject::TreasuryDebitReversalCompleted(serde_json::from_value(data)?) + Self::TreasuryDebitReversalCompleted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.debit_reversal.created" => { - EventObject::TreasuryDebitReversalCreated(serde_json::from_value(data)?) + Self::TreasuryDebitReversalCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.debit_reversal.initial_credit_granted" => { - EventObject::TreasuryDebitReversalInitialCreditGranted(serde_json::from_value( - data, - )?) + Self::TreasuryDebitReversalInitialCreditGranted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.financial_account.closed" => { - EventObject::TreasuryFinancialAccountClosed(serde_json::from_value(data)?) + Self::TreasuryFinancialAccountClosed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.financial_account.created" => { - EventObject::TreasuryFinancialAccountCreated(serde_json::from_value(data)?) + Self::TreasuryFinancialAccountCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.financial_account.features_status_updated" => { - EventObject::TreasuryFinancialAccountFeaturesStatusUpdated(serde_json::from_value( - data, - )?) + Self::TreasuryFinancialAccountFeaturesStatusUpdated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.inbound_transfer.canceled" => { - EventObject::TreasuryInboundTransferCanceled(serde_json::from_value(data)?) + Self::TreasuryInboundTransferCanceled(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.inbound_transfer.created" => { - EventObject::TreasuryInboundTransferCreated(serde_json::from_value(data)?) + Self::TreasuryInboundTransferCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.inbound_transfer.failed" => { - EventObject::TreasuryInboundTransferFailed(serde_json::from_value(data)?) + Self::TreasuryInboundTransferFailed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.inbound_transfer.succeeded" => { - EventObject::TreasuryInboundTransferSucceeded(serde_json::from_value(data)?) + Self::TreasuryInboundTransferSucceeded(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_payment.canceled" => { - EventObject::TreasuryOutboundPaymentCanceled(serde_json::from_value(data)?) + Self::TreasuryOutboundPaymentCanceled(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_payment.created" => { - EventObject::TreasuryOutboundPaymentCreated(serde_json::from_value(data)?) + Self::TreasuryOutboundPaymentCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_payment.expected_arrival_date_updated" => { - EventObject::TreasuryOutboundPaymentExpectedArrivalDateUpdated( - serde_json::from_value(data)?, - ) + Self::TreasuryOutboundPaymentExpectedArrivalDateUpdated(FromValueOpt::from_value( + data, + )?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_payment.failed" => { - EventObject::TreasuryOutboundPaymentFailed(serde_json::from_value(data)?) + Self::TreasuryOutboundPaymentFailed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_payment.posted" => { - EventObject::TreasuryOutboundPaymentPosted(serde_json::from_value(data)?) + Self::TreasuryOutboundPaymentPosted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_payment.returned" => { - EventObject::TreasuryOutboundPaymentReturned(serde_json::from_value(data)?) + Self::TreasuryOutboundPaymentReturned(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_transfer.canceled" => { - EventObject::TreasuryOutboundTransferCanceled(serde_json::from_value(data)?) + Self::TreasuryOutboundTransferCanceled(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_transfer.created" => { - EventObject::TreasuryOutboundTransferCreated(serde_json::from_value(data)?) + Self::TreasuryOutboundTransferCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_transfer.expected_arrival_date_updated" => { - EventObject::TreasuryOutboundTransferExpectedArrivalDateUpdated( - serde_json::from_value(data)?, - ) + Self::TreasuryOutboundTransferExpectedArrivalDateUpdated(FromValueOpt::from_value( + data, + )?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_transfer.failed" => { - EventObject::TreasuryOutboundTransferFailed(serde_json::from_value(data)?) + Self::TreasuryOutboundTransferFailed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_transfer.posted" => { - EventObject::TreasuryOutboundTransferPosted(serde_json::from_value(data)?) + Self::TreasuryOutboundTransferPosted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.outbound_transfer.returned" => { - EventObject::TreasuryOutboundTransferReturned(serde_json::from_value(data)?) + Self::TreasuryOutboundTransferReturned(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.received_credit.created" => { - EventObject::TreasuryReceivedCreditCreated(serde_json::from_value(data)?) + Self::TreasuryReceivedCreditCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.received_credit.failed" => { - EventObject::TreasuryReceivedCreditFailed(serde_json::from_value(data)?) + Self::TreasuryReceivedCreditFailed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.received_credit.succeeded" => { - EventObject::TreasuryReceivedCreditSucceeded(serde_json::from_value(data)?) + Self::TreasuryReceivedCreditSucceeded(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_treasury")] "treasury.received_debit.created" => { - EventObject::TreasuryReceivedDebitCreated(serde_json::from_value(data)?) + Self::TreasuryReceivedDebitCreated(FromValueOpt::from_value(data)?) } - _ => EventObject::Unknown(data), + _ => Self::Unknown(data), }) } } diff --git a/stripe_webhook/src/webhook.rs b/stripe_webhook/src/webhook.rs index 184b900a9..4a056e23f 100644 --- a/stripe_webhook/src/webhook.rs +++ b/stripe_webhook/src/webhook.rs @@ -6,6 +6,7 @@ use hmac::{Hmac, Mac}; use sha2::Sha256; use stripe_shared::event::EventType; use stripe_shared::ApiVersion; +use stripe_types::StripeDeserialize; use crate::{EventObject, WebhookError}; @@ -44,7 +45,7 @@ pub struct EventData { /// /// If an array attribute has any updated elements, this object contains the entire array. /// In Stripe API versions 2017-04-06 or earlier, an updated array attribute in this object includes only the updated array elements. - pub previous_attributes: Option<serde_json::Value>, + pub previous_attributes: Option<stripe_types::Value>, } pub struct Webhook { @@ -109,7 +110,17 @@ impl Webhook { return Err(WebhookError::BadTimestamp(signature.t)); } - let base_evt: stripe_shared::Event = serde_json::from_str(payload)?; + let base_evt = + stripe_shared::Event::deserialize(payload).map_err(WebhookError::BadParse)?; + #[cfg(not(feature = "min-ser"))] + let event_obj = EventObject::from_raw_data(base_evt.type_.as_str(), base_evt.data.object) + .map_err(|err| { + WebhookError::BadParse(format!("could not parse event object: {err}")) + })?; + #[cfg(feature = "min-ser")] + let event_obj = + EventObject::from_raw_data(base_evt.type_.as_str(), base_evt.data.object) + .ok_or_else(|| WebhookError::BadParse("could not parse event object".into()))?; Ok(Event { account: base_evt.account, @@ -118,7 +129,7 @@ impl Webhook { .map(|s| ApiVersion::from_str(&s).unwrap_or(ApiVersion::Unknown)), created: base_evt.created, data: EventData { - object: EventObject::from_raw_data(base_evt.type_.as_str(), base_evt.data.object)?, + object: event_obj, previous_attributes: base_evt.data.previous_attributes, }, id: base_evt.id, diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 9ad327741..65104e8a6 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -13,19 +13,22 @@ httpmock = "0.6.7" wiremock = "0.5.22" futures-util = { version = "0.3.21" } tokio = { version = "1.24.1", features = ["rt", "macros"] } -stripe_types = {path = "../stripe_types"} -async-stripe = {path = "../async-stripe"} -stripe_connect = {path = "../generated/stripe_connect", features = ["account", "transfer_reversal"]} -stripe_billing = {path = "../generated/stripe_billing", features = ["invoice", "plan", "subscription", "subscription_item", "usage_record"]} -stripe_core = {path = "../generated/stripe_core", features = ["customer", "charge", "token"]} -stripe_checkout = {path = "../generated/stripe_checkout", features = ["checkout_session"]} -stripe_product = {path = "../generated/stripe_product", features = ["product", "price", "promotion_code"]} -stripe_misc = {path = "../generated/stripe_misc"} +miniserde = { workspace = true } +stripe_types = { path = "../stripe_types" } +async-stripe = { path = "../async-stripe" } +stripe_connect = { path = "../generated/stripe_connect", features = ["account", "transfer_reversal"] } +stripe_billing = { path = "../generated/stripe_billing", features = ["invoice", "plan", "subscription", "subscription_item", "usage_record"] } +stripe_core = { path = "../generated/stripe_core", features = ["customer", "charge", "token"] } +stripe_checkout = { path = "../generated/stripe_checkout", features = ["checkout_session"] } +stripe_product = { path = "../generated/stripe_product", features = ["product", "price", "promotion_code"] } +stripe_payment = { path = "../generated/stripe_payment" } +stripe_misc = { path = "../generated/stripe_misc" } [features] async = [] blocking = [] +min-ser = ["stripe_billing/min-ser", "stripe_checkout/min-ser", "stripe_core/min-ser", "stripe_product/min-ser", "stripe_connect/min-ser", "stripe_misc/min-ser", "stripe_payment/min-ser", "stripe_types/min-ser"] runtime-tokio-hyper = ["async-stripe/runtime-tokio-hyper", "async"] runtime-tokio-hyper-rustls = ["async-stripe/runtime-tokio-hyper-rustls", "async"] runtime-tokio-hyper-rustls-webpki = ["async-stripe/runtime-tokio-hyper-rustls-webpki", "async"] diff --git a/tests/tests/it/deser.rs b/tests/tests/it/deser.rs index a04e4e1c2..bf8b3c22a 100644 --- a/tests/tests/it/deser.rs +++ b/tests/tests/it/deser.rs @@ -1,10 +1,13 @@ -use serde_json::json; -use stripe_core::{Charge, ChargeStatus, Customer}; -use stripe_types::Currency; +use serde_json::{json, Value}; +use stripe_connect::Account; +use stripe_core::customer::RetrieveCustomerReturned; +use stripe_core::{ + Charge, ChargeStatus, Customer, CustomerTaxExempt, File, FileLink, FilePurpose, PaymentSource, +}; +use stripe_types::{Currency, StripeDeserialize, Timestamp}; -#[test] -fn deserialize_customer_with_card() { - let example = json!({ +fn mock_customer_with_card() -> Value { + json!({ "id": "cus_1234", "object": "customer", "account_balance": 0, @@ -61,8 +64,13 @@ fn deserialize_customer_with_card() { }, "tax_info": null, "tax_info_verification": null - }); - let result = serde_json::from_value::<Customer>(example); + }) +} + +#[test] +fn deserialize_customer_with_card() { + let example = mock_customer_with_card().to_string(); + let result = Customer::deserialize(&example); assert!(result.is_ok(), "expected ok; was {:?}", result); } @@ -142,8 +150,10 @@ fn deserialize_customer_with_source() { }, "tax_info": null, "tax_info_verification": null - }); - let result = serde_json::from_value::<Customer>(example); + }) + .to_string(); + + let result = Customer::deserialize(&example); assert!(result.is_ok(), "expected ok; was {:?}", result); } @@ -195,8 +205,9 @@ fn deserialize_checkout_event() { "success_url": "https://example.com/success" } } - }); - let result = serde_json::from_value::<Event>(example); + }) + .to_string(); + let result = Event::deserialize(&example); assert!(result.is_ok(), "expected ok; was {:?}", result); } @@ -219,10 +230,175 @@ fn deserialize_charge_with_no_refunds() { "paid": false, "status": "pending", "refunded": false, - }); - let charge: Charge = serde_json::from_value(example).unwrap(); + }) + .to_string(); + let charge = Charge::deserialize(&example).unwrap(); assert_eq!(charge.id.as_str(), "ch_123"); assert_eq!(charge.currency, Currency::CAD); assert_eq!(charge.status, ChargeStatus::Pending); assert_eq!(charge.created, 1703349829); } + +const FILE_CREATED: Timestamp = 1704511150; +fn mock_file() -> Value { + json!({ + "created": FILE_CREATED, + "id": "file_123", + "size": 0, + "purpose": "account_requirement" + }) +} + +#[test] +fn deserialize_file() { + let file = mock_file(); + let file = File::deserialize(&file.to_string()).unwrap(); + assert_eq!(file.purpose, FilePurpose::AccountRequirement); + assert_eq!(file.created, FILE_CREATED); +} + +#[cfg(feature = "min-ser")] +#[test] +fn deserialize_id() { + use std::str::FromStr; + + use stripe_core::FileId; + + #[derive(miniserde::Deserialize)] + struct Id { + id: FileId, + } + let data = json!({"id": "file_123"}); + let id: Id = miniserde::json::from_str(&data.to_string()).unwrap(); + assert_eq!(id.id, FileId::from_str("file_123").unwrap()); +} + +#[test] +fn deserialize_account() { + let acct_url = "/v1/accounts/acct_123/external_accounts"; + let account = json!({ + "id": "acct_123", + "external_accounts": { + "data": [], + "has_more": false, + "object": "list", + "url": acct_url + }, + }); + let result = Account::deserialize(&account.to_string()).unwrap(); + assert_eq!(result.id.as_str(), "acct_123"); + + let external_accts = result.external_accounts.as_ref().unwrap(); + assert_eq!(external_accts.url, acct_url); + assert!(external_accts.data.is_empty()); +} + +fn mock_payment_source() -> Value { + json!({ + "object": "bank_account", + "currency": "usd", + "country": "us", + "id": "ba_123", + "status": "new", + "last4": "1234", + }) +} + +#[track_caller] +fn assert_payment_source_matches(result: &PaymentSource) { + let PaymentSource::BankAccount(bank) = result else { + panic!("Expected bank account"); + }; + assert_eq!(bank.last4, "1234"); + assert_eq!(bank.status, "new"); +} + +#[test] +fn deserialize_polymorphic() { + let payment_source = mock_payment_source(); + let result = PaymentSource::deserialize(&payment_source.to_string()).unwrap(); + assert_payment_source_matches(&result); +} + +#[test] +fn deserialize_expandable() { + let file_link_base = json!({ + "created": 1704511150, + "expired": false, + "livemode": false, + "metadata": {}, + "url": "http://localhost:3000", + "id": "link_123", + }); + + let mut file_link = file_link_base.clone(); + file_link.as_object_mut().unwrap().insert("file".into(), Value::String("file_123".into())); + + let result = FileLink::deserialize(&file_link.to_string()).unwrap(); + assert!(result.metadata.is_empty()); + assert!(!result.livemode); + assert!(!result.expired); + + assert_eq!(result.url.as_ref().unwrap(), "http://localhost:3000"); + assert_eq!(result.created, 1704511150); + assert_eq!(result.file.id().as_str(), "file_123"); + + let mut file_link = file_link_base.clone(); + file_link.as_object_mut().unwrap().insert("file".into(), mock_file()); + + let result = FileLink::deserialize(&file_link.to_string()).unwrap(); + let file = result.file.as_object().unwrap(); + + assert_eq!(file.created, FILE_CREATED); + assert_eq!(file.purpose, FilePurpose::AccountRequirement); + assert_eq!(file.id.as_str(), "file_123"); +} + +#[test] +fn deserialize_expandable_polymorphic() { + let base_cust = json!({ + "currency": "usd", + "created": 1704511150, + "id": "cus_123", + "livemode": false, + "tax_exempt": "exempt", + }); + + let mut cust = base_cust.clone(); + cust.as_object_mut().unwrap().insert("default_source".into(), Value::String("ba_123".into())); + + let result = Customer::deserialize(&cust.to_string()).unwrap(); + assert_eq!(result.created, 1704511150); + assert_eq!(result.currency, Some(Currency::USD)); + assert_eq!(result.tax_exempt, Some(CustomerTaxExempt::Exempt)); + assert_eq!(result.id.as_str(), "cus_123"); + assert_eq!(result.default_source.as_ref().unwrap().id().as_str(), "ba_123"); + + let mut cust = base_cust.clone(); + cust.as_object_mut().unwrap().insert("default_source".into(), mock_payment_source()); + + let result = Customer::deserialize(&cust.to_string()).unwrap(); + let payment_source = result.default_source.as_ref().unwrap().as_object().unwrap(); + assert_payment_source_matches(&payment_source); +} + +#[test] +fn deserialize_customer_deleted_or_not() { + let deleted_cust = json!({ + "deleted": true, + "id": "cus_123" + }); + let result = RetrieveCustomerReturned::deserialize(&deleted_cust.to_string()).unwrap(); + let RetrieveCustomerReturned::DeletedCustomer(deleted) = result else { + panic!("expected deleted variant"); + }; + assert_eq!(deleted.id.as_str(), "cus_123"); + + let cust = mock_customer_with_card().to_string(); + let result = RetrieveCustomerReturned::deserialize(&cust).unwrap(); + let RetrieveCustomerReturned::Customer(cust) = result else { + panic!("did not expected deleted variant") + }; + assert_eq!(cust.id.as_str(), "cus_1234"); + assert_eq!(cust.sources.unwrap().data.len(), 1); +} diff --git a/tests/tests/it/price.rs b/tests/tests/it/price.rs index 4f85341f5..d7d2baae6 100644 --- a/tests/tests/it/price.rs +++ b/tests/tests/it/price.rs @@ -1,5 +1,5 @@ use stripe_product::{CurrencyOptionTaxBehavior, Price}; -use stripe_types::Currency; +use stripe_types::{Currency, StripeDeserialize}; // Using fixture for this test because the stripe-mock server does not (currently [2023-05-25]) support the `currency_options` field. // See: https://github.com/stripe/stripe-mock/issues/420 @@ -49,10 +49,7 @@ fn deserialize_currency_options() { } "#; - let result: Result<Price, serde_json::Error> = serde_json::from_str(fixture); - assert!(result.is_ok()); - - let price = result.unwrap(); + let price = Price::deserialize(fixture).unwrap(); assert!(&price.currency_options.is_some()); let currency_options = price.currency_options.unwrap();